]> git.proxmox.com Git - rustc.git/blame - src/libstd/sys/cloudabi/mod.rs
New upstream version 1.32.0~beta.2+dfsg1
[rustc.git] / src / libstd / sys / cloudabi / mod.rs
CommitLineData
2c00a5a8
XL
1// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11use io;
12use libc;
13use mem;
14
a1dfa0c6
XL
15#[path = "../unix/alloc.rs"]
16pub mod alloc;
2c00a5a8
XL
17pub mod args;
18#[cfg(feature = "backtrace")]
19pub mod backtrace;
20#[path = "../unix/cmath.rs"]
21pub mod cmath;
22pub mod condvar;
23#[path = "../unix/memchr.rs"]
24pub mod memchr;
25pub mod mutex;
26pub mod os;
27#[path = "../unix/os_str.rs"]
28pub mod os_str;
29pub mod rwlock;
30pub mod stack_overflow;
31pub mod stdio;
32pub mod thread;
33#[path = "../unix/thread_local.rs"]
34pub mod thread_local;
35pub mod time;
36
37mod abi;
38
39mod shims;
40pub use self::shims::*;
41
42#[allow(dead_code)]
43pub fn init() {}
44
45pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
46 match errno {
47 x if x == abi::errno::ACCES as i32 => io::ErrorKind::PermissionDenied,
48 x if x == abi::errno::ADDRINUSE as i32 => io::ErrorKind::AddrInUse,
49 x if x == abi::errno::ADDRNOTAVAIL as i32 => io::ErrorKind::AddrNotAvailable,
50 x if x == abi::errno::AGAIN as i32 => io::ErrorKind::WouldBlock,
51 x if x == abi::errno::CONNABORTED as i32 => io::ErrorKind::ConnectionAborted,
52 x if x == abi::errno::CONNREFUSED as i32 => io::ErrorKind::ConnectionRefused,
53 x if x == abi::errno::CONNRESET as i32 => io::ErrorKind::ConnectionReset,
54 x if x == abi::errno::EXIST as i32 => io::ErrorKind::AlreadyExists,
55 x if x == abi::errno::INTR as i32 => io::ErrorKind::Interrupted,
56 x if x == abi::errno::INVAL as i32 => io::ErrorKind::InvalidInput,
57 x if x == abi::errno::NOENT as i32 => io::ErrorKind::NotFound,
58 x if x == abi::errno::NOTCONN as i32 => io::ErrorKind::NotConnected,
59 x if x == abi::errno::PERM as i32 => io::ErrorKind::PermissionDenied,
60 x if x == abi::errno::PIPE as i32 => io::ErrorKind::BrokenPipe,
61 x if x == abi::errno::TIMEDOUT as i32 => io::ErrorKind::TimedOut,
62 _ => io::ErrorKind::Other,
63 }
64}
65
66pub unsafe fn abort_internal() -> ! {
67 ::core::intrinsics::abort();
68}
69
70pub use libc::strlen;
71
72pub fn hashmap_random_keys() -> (u64, u64) {
73 unsafe {
74 let mut v = mem::uninitialized();
75 libc::arc4random_buf(&mut v as *mut _ as *mut libc::c_void, mem::size_of_val(&v));
76 v
77 }
78}