]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/solid/mod.rs
Rollup merge of #105443 - compiler-errors:move-more, r=oli-obk
[rust.git] / library / std / src / sys / solid / mod.rs
1 #![allow(dead_code)]
2 #![allow(missing_docs, nonstandard_style)]
3 #![deny(unsafe_op_in_unsafe_fn)]
4
5 mod abi;
6
7 #[path = "../itron"]
8 mod itron {
9     pub(super) mod abi;
10     pub mod condvar;
11     pub(super) mod error;
12     pub mod mutex;
13     pub(super) mod spin;
14     pub(super) mod task;
15     pub mod thread;
16     pub(super) mod time;
17     use super::unsupported;
18     pub mod wait_flag;
19 }
20
21 pub mod alloc;
22 #[path = "../unsupported/args.rs"]
23 pub mod args;
24 #[path = "../unix/cmath.rs"]
25 pub mod cmath;
26 pub mod env;
27 // `error` is `pub(crate)` so that it can be accessed by `itron/error.rs` as
28 // `crate::sys::error`
29 pub(crate) mod error;
30 pub mod fs;
31 pub mod io;
32 pub mod net;
33 pub mod os;
34 #[path = "../unix/os_str.rs"]
35 pub mod os_str;
36 pub mod path;
37 #[path = "../unsupported/pipe.rs"]
38 pub mod pipe;
39 #[path = "../unsupported/process.rs"]
40 pub mod process;
41 pub mod stdio;
42 pub use self::itron::thread;
43 pub mod memchr;
44 pub mod thread_local_dtor;
45 pub mod thread_local_key;
46 pub mod time;
47 pub use self::itron::wait_flag;
48
49 mod rwlock;
50
51 pub mod locks {
52     pub use super::itron::condvar::*;
53     pub use super::itron::mutex::*;
54     pub use super::rwlock::*;
55 }
56
57 // SAFETY: must be called only once during runtime initialization.
58 // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
59 pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
60
61 // SAFETY: must be called only once during runtime cleanup.
62 pub unsafe fn cleanup() {}
63
64 pub fn unsupported<T>() -> crate::io::Result<T> {
65     Err(unsupported_err())
66 }
67
68 pub fn unsupported_err() -> crate::io::Error {
69     crate::io::const_io_error!(
70         crate::io::ErrorKind::Unsupported,
71         "operation not supported on this platform",
72     )
73 }
74
75 pub fn decode_error_kind(code: i32) -> crate::io::ErrorKind {
76     error::decode_error_kind(code)
77 }
78
79 #[inline]
80 pub fn abort_internal() -> ! {
81     unsafe { libc::abort() }
82 }
83
84 pub fn hashmap_random_keys() -> (u64, u64) {
85     unsafe {
86         let mut out = crate::mem::MaybeUninit::<[u64; 2]>::uninit();
87         let result = abi::SOLID_RNG_SampleRandomBytes(out.as_mut_ptr() as *mut u8, 16);
88         assert_eq!(result, 0, "SOLID_RNG_SampleRandomBytes failed: {result}");
89         let [x1, x2] = out.assume_init();
90         (x1, x2)
91     }
92 }