]> git.lizzy.rs Git - rust.git/blob - src/libstd/sys/cloudabi/mod.rs
Rollup merge of #61157 - czipperz:BufReader-Seek-remove-extra-discard_buffer, r=nikom...
[rust.git] / src / libstd / sys / cloudabi / mod.rs
1 use crate::io::ErrorKind;
2 use crate::mem;
3
4 #[path = "../unix/alloc.rs"]
5 pub mod alloc;
6 pub mod args;
7 #[path = "../unix/cmath.rs"]
8 pub mod cmath;
9 pub mod condvar;
10 pub mod io;
11 #[path = "../unix/memchr.rs"]
12 pub mod memchr;
13 pub mod mutex;
14 pub mod os;
15 pub mod rwlock;
16 pub mod stack_overflow;
17 pub mod stdio;
18 pub mod thread;
19 #[path = "../unix/thread_local.rs"]
20 pub mod thread_local;
21 pub mod time;
22
23 pub use crate::sys_common::os_str_bytes as os_str;
24
25 mod abi;
26
27 mod shims;
28 pub use self::shims::*;
29
30 #[allow(dead_code)]
31 pub fn init() {}
32
33 pub fn decode_error_kind(errno: i32) -> ErrorKind {
34     match errno {
35         x if x == abi::errno::ACCES as i32 => ErrorKind::PermissionDenied,
36         x if x == abi::errno::ADDRINUSE as i32 => ErrorKind::AddrInUse,
37         x if x == abi::errno::ADDRNOTAVAIL as i32 => ErrorKind::AddrNotAvailable,
38         x if x == abi::errno::AGAIN as i32 => ErrorKind::WouldBlock,
39         x if x == abi::errno::CONNABORTED as i32 => ErrorKind::ConnectionAborted,
40         x if x == abi::errno::CONNREFUSED as i32 => ErrorKind::ConnectionRefused,
41         x if x == abi::errno::CONNRESET as i32 => ErrorKind::ConnectionReset,
42         x if x == abi::errno::EXIST as i32 => ErrorKind::AlreadyExists,
43         x if x == abi::errno::INTR as i32 => ErrorKind::Interrupted,
44         x if x == abi::errno::INVAL as i32 => ErrorKind::InvalidInput,
45         x if x == abi::errno::NOENT as i32 => ErrorKind::NotFound,
46         x if x == abi::errno::NOTCONN as i32 => ErrorKind::NotConnected,
47         x if x == abi::errno::PERM as i32 => ErrorKind::PermissionDenied,
48         x if x == abi::errno::PIPE as i32 => ErrorKind::BrokenPipe,
49         x if x == abi::errno::TIMEDOUT as i32 => ErrorKind::TimedOut,
50         _ => ErrorKind::Other,
51     }
52 }
53
54 pub unsafe fn abort_internal() -> ! {
55     core::intrinsics::abort();
56 }
57
58 pub use libc::strlen;
59
60 pub fn hashmap_random_keys() -> (u64, u64) {
61     unsafe {
62         let mut v = mem::uninitialized();
63         libc::arc4random_buf(&mut v as *mut _ as *mut libc::c_void, mem::size_of_val(&v));
64         v
65     }
66 }