]> git.lizzy.rs Git - rust.git/blob - library/std/src/sys/unsupported/common.rs
Auto merge of #84411 - m-ou-se:rollup-9btsp2t, r=m-ou-se
[rust.git] / library / std / src / sys / unsupported / common.rs
1 use crate::io as std_io;
2
3 pub mod memchr {
4     pub use core::slice::memchr::{memchr, memrchr};
5 }
6
7 pub use crate::sys_common::os_str_bytes as os_str;
8
9 // This is not necessarily correct. May want to consider making it part of the
10 // spec definition?
11 use crate::os::raw::c_char;
12
13 #[cfg(not(test))]
14 pub fn init() {}
15
16 pub fn unsupported<T>() -> std_io::Result<T> {
17     Err(unsupported_err())
18 }
19
20 pub fn unsupported_err() -> std_io::Error {
21     std_io::Error::new_const(
22         std_io::ErrorKind::Unsupported,
23         &"operation not supported on this platform",
24     )
25 }
26
27 pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
28     crate::io::ErrorKind::Other
29 }
30
31 pub fn abort_internal() -> ! {
32     core::intrinsics::abort();
33 }
34
35 pub fn hashmap_random_keys() -> (u64, u64) {
36     (1, 2)
37 }
38
39 pub unsafe fn strlen(mut s: *const c_char) -> usize {
40     // SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
41     unsafe {
42         let mut n = 0;
43         while *s != 0 {
44             n += 1;
45             s = s.offset(1);
46         }
47         n
48     }
49 }