rust/src/libstd/sys/cloudabi/mod.rs
Alex Crichton cc7590341a std: Delete the alloc_system crate
This commit deletes the `alloc_system` crate from the standard
distribution. This unstable crate is no longer needed in the modern
stable global allocator world, but rather its functionality is folded
directly into the standard library. The standard library was already the
only stable location to access this crate, and as a result this should
not affect any stable code.
2018-11-11 09:22:28 -08:00

78 lines
2.5 KiB
Rust

// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use io;
use libc;
use mem;
#[path = "../unix/alloc.rs"]
pub mod alloc;
pub mod args;
#[cfg(feature = "backtrace")]
pub mod backtrace;
#[path = "../unix/cmath.rs"]
pub mod cmath;
pub mod condvar;
#[path = "../unix/memchr.rs"]
pub mod memchr;
pub mod mutex;
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
pub mod rwlock;
pub mod stack_overflow;
pub mod stdio;
pub mod thread;
#[path = "../unix/thread_local.rs"]
pub mod thread_local;
pub mod time;
mod abi;
mod shims;
pub use self::shims::*;
#[allow(dead_code)]
pub fn init() {}
pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
match errno {
x if x == abi::errno::ACCES as i32 => io::ErrorKind::PermissionDenied,
x if x == abi::errno::ADDRINUSE as i32 => io::ErrorKind::AddrInUse,
x if x == abi::errno::ADDRNOTAVAIL as i32 => io::ErrorKind::AddrNotAvailable,
x if x == abi::errno::AGAIN as i32 => io::ErrorKind::WouldBlock,
x if x == abi::errno::CONNABORTED as i32 => io::ErrorKind::ConnectionAborted,
x if x == abi::errno::CONNREFUSED as i32 => io::ErrorKind::ConnectionRefused,
x if x == abi::errno::CONNRESET as i32 => io::ErrorKind::ConnectionReset,
x if x == abi::errno::EXIST as i32 => io::ErrorKind::AlreadyExists,
x if x == abi::errno::INTR as i32 => io::ErrorKind::Interrupted,
x if x == abi::errno::INVAL as i32 => io::ErrorKind::InvalidInput,
x if x == abi::errno::NOENT as i32 => io::ErrorKind::NotFound,
x if x == abi::errno::NOTCONN as i32 => io::ErrorKind::NotConnected,
x if x == abi::errno::PERM as i32 => io::ErrorKind::PermissionDenied,
x if x == abi::errno::PIPE as i32 => io::ErrorKind::BrokenPipe,
x if x == abi::errno::TIMEDOUT as i32 => io::ErrorKind::TimedOut,
_ => io::ErrorKind::Other,
}
}
pub unsafe fn abort_internal() -> ! {
::core::intrinsics::abort();
}
pub use libc::strlen;
pub fn hashmap_random_keys() -> (u64, u64) {
unsafe {
let mut v = mem::uninitialized();
libc::arc4random_buf(&mut v as *mut _ as *mut libc::c_void, mem::size_of_val(&v));
v
}
}