From 7a3357aa0feebd6b6b0673edae6acb09cea03bd7 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 1 Jul 2023 11:24:35 +0100 Subject: [PATCH 01/27] android adding few more pthread api calls. --- libc-test/build.rs | 3 +++ libc-test/semver/android.txt | 2 ++ src/unix/linux_like/android/mod.rs | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index b1d2b9bc2b2e1..8cee7e596cb07 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1881,6 +1881,9 @@ fn test_android(target: &str) { // Added in API level 28, but some tests use level 24. "syncfs" => true, + // Added in API level 28, but some tests use level 24. + "pthread_attr_getinheritsched" | "pthread_attr_setinheritsched" => true, + _ => false, } }); diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 9dc691cb4009c..5153069559f68 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3375,8 +3375,10 @@ pthread_atfork pthread_attr_destroy pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_getstacksize pthread_attr_init pthread_attr_setdetachstate +pthread_attr_setguardsize pthread_attr_setstacksize pthread_attr_t pthread_barrierattr_destroy diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 40fbb607a99a0..34ff169cc006c 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1224,6 +1224,9 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_EXPLICIT_SCHED: ::c_int = 0; +pub const PTHREAD_INHERIT_SCHED: ::c_int = 1; + // stdio.h pub const RENAME_NOREPLACE: ::c_int = 1; pub const RENAME_EXCHANGE: ::c_int = 2; @@ -3494,6 +3497,16 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; + pub fn pthread_attr_getstacksize( + attr: *const ::pthread_attr_t, + stacksize: *mut ::size_t, + ) -> ::c_int; + pub fn pthread_attr_getinheritsched( + attr: *const ::pthread_attr_t, + flag: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_setinheritsched(attr: *mut ::pthread_attr_t, flag: ::c_int) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; pub fn pthread_condattr_getpshared( From cbeb1bde9f59cb560867f072eac3235c21b695fd Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 2 Aug 2023 20:56:16 +0100 Subject: [PATCH 02/27] linux glibc/musl and android adding PROT_BTI/PROT_MTE mmap flags for arm64. --- libc-test/semver/android-aarch64.txt | 2 ++ src/unix/linux_like/android/b64/aarch64/mod.rs | 3 +++ src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 3 +++ 3 files changed, 8 insertions(+) diff --git a/libc-test/semver/android-aarch64.txt b/libc-test/semver/android-aarch64.txt index 7a8868aa2c5de..9b4cc355e3f9e 100644 --- a/libc-test/semver/android-aarch64.txt +++ b/libc-test/semver/android-aarch64.txt @@ -7,6 +7,8 @@ HWCAP2_SVEBITPERM HWCAP2_SVEPMULL HWCAP2_SVESHA3 HWCAP2_SVESM4 +PROT_BTI +PROT_MTE SYS_arch_specific_syscall SYS_syscalls SYS_fcntl diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index e7247fbb6f5fd..ac67fddabecd4 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -412,6 +412,9 @@ pub const SYS_fsmount: ::c_long = 432; pub const SYS_fspick: ::c_long = 433; pub const SYS_syscalls: ::c_long = 436; +pub const PROT_BTI: ::c_int = 0x10; +pub const PROT_MTE: ::c_int = 0x20; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index fee3d1517f87a..f9aed99b2e788 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -902,6 +902,9 @@ pub const SYS_process_mrelease: ::c_long = 448; pub const SYS_futex_waitv: ::c_long = 449; pub const SYS_set_mempolicy_home_node: ::c_long = 450; +pub const PROT_BTI: ::c_int = 0x10; +pub const PROT_MTE: ::c_int = 0x20; + extern "C" { pub fn sysctl( name: *mut ::c_int, From 5841067de1341dd8744fdbb585c465b73ad07855 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 20 Aug 2023 10:48:50 +0200 Subject: [PATCH 03/27] CI: Update Node.js version to v16.20.0 By using the bundled Node from emsdk, which is no longer outdated. See: emscripten-core/emsdk@d7327b4 --- ci/emscripten-entry.sh | 4 ---- ci/emscripten.sh | 6 ------ 2 files changed, 10 deletions(-) diff --git a/ci/emscripten-entry.sh b/ci/emscripten-entry.sh index 80b091903b1fc..e950cbe33ab06 100755 --- a/ci/emscripten-entry.sh +++ b/ci/emscripten-entry.sh @@ -5,8 +5,4 @@ set -ex # shellcheck disable=SC1091 source /emsdk-portable/emsdk_env.sh &> /dev/null -# emsdk-portable provides a node binary, but we need version 8 to run wasm -# NOTE: Do not forget to sync Node.js version with `emscripten.sh`! -export PATH="/node-v14.17.0-linux-x64/bin:$PATH" - exec "$@" diff --git a/ci/emscripten.sh b/ci/emscripten.sh index 967b586b5f199..44da97c93ee68 100644 --- a/ci/emscripten.sh +++ b/ci/emscripten.sh @@ -20,9 +20,3 @@ rm -f a.* # Make emsdk usable by any user chmod a+rxw -R /emsdk-portable - -# node 8 is required to run wasm -# NOTE: Do not forget to sync Node.js version with `emscripten-entry.sh`! -cd / -curl --retry 5 -L https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz | \ - tar -xJ From 837159cdd1477a2e2dcd712878a435c06459cbe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Mon, 21 Aug 2023 11:00:40 +0900 Subject: [PATCH 04/27] add RTLD_MAIN_ONLY Apple's dynamic linker has this special handle called `RTLD_MAIN_ONLY` which you can feed to `dlsym(3)`. Their `dlfcn.h` says it has been around since Mac OS X 10.5. --- src/unix/bsd/apple/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 1602357366ee1..867a2814a2425 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4189,6 +4189,7 @@ pub const RTLD_FIRST: ::c_int = 0x100; pub const RTLD_NODELETE: ::c_int = 0x80; pub const RTLD_NOLOAD: ::c_int = 0x10; pub const RTLD_GLOBAL: ::c_int = 0x8; +pub const RTLD_MAIN_ONLY: *mut ::c_void = -5isize as *mut c_void; pub const _WSTOPPED: ::c_int = 0o177; From ff6a0c677bce23b632fe5f1c22d07b9d0028972f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Mon, 21 Aug 2023 11:31:33 +0900 Subject: [PATCH 05/27] properly modify the type with :: --- src/unix/bsd/apple/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 867a2814a2425..a2fbf876731ba 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4189,7 +4189,7 @@ pub const RTLD_FIRST: ::c_int = 0x100; pub const RTLD_NODELETE: ::c_int = 0x80; pub const RTLD_NOLOAD: ::c_int = 0x10; pub const RTLD_GLOBAL: ::c_int = 0x8; -pub const RTLD_MAIN_ONLY: *mut ::c_void = -5isize as *mut c_void; +pub const RTLD_MAIN_ONLY: *mut ::c_void = -5isize as *mut ::c_void; pub const _WSTOPPED: ::c_int = 0o177; From 7c952dceaad4cdc35e00884fcb12a713d41a87e0 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Wed, 26 Jul 2023 12:45:25 +0200 Subject: [PATCH 06/27] Fix compatibility with Emscripten >= 3.1.44 By aliasing all LFS64 symbols to their non-LFS64 counterparts. --- libc-test/build.rs | 20 ++- libc-test/semver/emscripten.txt | 1 + src/unix/linux_like/emscripten/lfs64.rs | 213 ++++++++++++++++++++++++ src/unix/linux_like/emscripten/mod.rs | 147 ++-------------- src/unix/linux_like/mod.rs | 6 +- 5 files changed, 251 insertions(+), 136 deletions(-) create mode 100644 src/unix/linux_like/emscripten/lfs64.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index bfe1ed16f3951..83c9c809d2279 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2625,13 +2625,19 @@ fn test_emscripten(target: &str) { "os_unfair_lock" => "struct os_unfair_lock_s".to_string(), - t if is_union => format!("union {}", t), + // LFS64 types have been removed in Emscripten 3.1.44+ + // https://github.com/emscripten-core/emscripten/pull/19812 + "off64_t" => "off_t".to_string(), + // typedefs don't need any keywords t if t.ends_with("_t") => t.to_string(), // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), + // put `union` in front of all unions: + t if is_union => format!("union {}", t), + t => t.to_string(), } }); @@ -2658,7 +2664,9 @@ fn test_emscripten(target: &str) { // FIXME: The size has been changed due to musl's time64 "time_t" => true, - _ => false, + // LFS64 types have been removed in Emscripten 3.1.44+ + // https://github.com/emscripten-core/emscripten/pull/19812 + t => t.ends_with("64") || t.ends_with("64_t"), } }); @@ -2687,7 +2695,9 @@ fn test_emscripten(target: &str) { "utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "sched_param" | "stat" | "stat64" | "shmid_ds" | "msqid_ds" => true, - _ => false, + // LFS64 types have been removed in Emscripten 3.1.44+ + // https://github.com/emscripten-core/emscripten/pull/19812 + ty => ty.ends_with("64") || ty.ends_with("64_t"), } }); @@ -2729,6 +2739,10 @@ fn test_emscripten(target: &str) { | "SIG_IGN" // -1 => true, + // LFS64 types have been removed in Emscripten 3.1.44+ + // https://github.com/emscripten-core/emscripten/pull/19812 + n if n.starts_with("RLIM64") => true, + _ => false, } }); diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 48882791e7c8d..6b1df1aab4c7f 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1 +1,2 @@ getentropy +posix_fallocate64 diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs new file mode 100644 index 0000000000000..1616cc90494be --- /dev/null +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -0,0 +1,213 @@ +// In-sync with ../linux/musl/lfs64.rs except for fallocate64, prlimit64 and sendfile64 + +#[inline] +pub unsafe extern "C" fn creat64(path: *const ::c_char, mode: ::mode_t) -> ::c_int { + ::creat(path, mode) +} + +#[inline] +pub unsafe extern "C" fn fgetpos64(stream: *mut ::FILE, pos: *mut ::fpos64_t) -> ::c_int { + ::fgetpos(stream, pos as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fopen64(pathname: *const ::c_char, mode: *const ::c_char) -> *mut ::FILE { + ::fopen(pathname, mode) +} + +#[inline] +pub unsafe extern "C" fn freopen64( + pathname: *const ::c_char, + mode: *const ::c_char, + stream: *mut ::FILE, +) -> *mut ::FILE { + ::freopen(pathname, mode, stream) +} + +#[inline] +pub unsafe extern "C" fn fseeko64( + stream: *mut ::FILE, + offset: ::off64_t, + whence: ::c_int, +) -> ::c_int { + ::fseeko(stream, offset, whence) +} + +#[inline] +pub unsafe extern "C" fn fsetpos64(stream: *mut ::FILE, pos: *const ::fpos64_t) -> ::c_int { + ::fsetpos(stream, pos as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstat64(fildes: ::c_int, buf: *mut ::stat64) -> ::c_int { + ::fstat(fildes, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstatat64( + fd: ::c_int, + path: *const ::c_char, + buf: *mut ::stat64, + flag: ::c_int, +) -> ::c_int { + ::fstatat(fd, path, buf as *mut _, flag) +} + +#[inline] +pub unsafe extern "C" fn fstatfs64(fd: ::c_int, buf: *mut ::statfs64) -> ::c_int { + ::fstatfs(fd, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstatvfs64(fd: ::c_int, buf: *mut ::statvfs64) -> ::c_int { + ::fstatvfs(fd, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn ftello64(stream: *mut ::FILE) -> ::off64_t { + ::ftello(stream) +} + +#[inline] +pub unsafe extern "C" fn ftruncate64(fd: ::c_int, length: ::off64_t) -> ::c_int { + ::ftruncate(fd, length) +} + +#[inline] +pub unsafe extern "C" fn getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int { + ::getrlimit(resource, rlim as *mut _) +} + +#[inline] +pub unsafe extern "C" fn lseek64(fd: ::c_int, offset: ::off64_t, whence: ::c_int) -> ::off64_t { + ::lseek(fd, offset, whence) +} + +#[inline] +pub unsafe extern "C" fn lstat64(path: *const ::c_char, buf: *mut ::stat64) -> ::c_int { + ::lstat(path, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn mmap64( + addr: *mut ::c_void, + length: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: ::off64_t, +) -> *mut ::c_void { + ::mmap(addr, length, prot, flags, fd, offset) +} + +// These functions are variadic in the C ABI since the `mode` argument is "optional". Variadic +// `extern "C"` functions are unstable in Rust so we cannot write a shim function for these +// entrypoints. See https://github.com/rust-lang/rust/issues/44930. +// +// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an +// argument, nor do their names clash with any declared types. +pub use open as open64; +pub use openat as openat64; + +#[inline] +pub unsafe extern "C" fn posix_fadvise64( + fd: ::c_int, + offset: ::off64_t, + len: ::off64_t, + advice: ::c_int, +) -> ::c_int { + ::posix_fadvise(fd, offset, len, advice) +} + +#[inline] +pub unsafe extern "C" fn posix_fallocate64( + fd: ::c_int, + offset: ::off64_t, + len: ::off64_t, +) -> ::c_int { + ::posix_fallocate(fd, offset, len) +} + +#[inline] +pub unsafe extern "C" fn pread64( + fd: ::c_int, + buf: *mut ::c_void, + count: ::size_t, + offset: ::off64_t, +) -> ::ssize_t { + ::pread(fd, buf, count, offset) +} + +#[inline] +pub unsafe extern "C" fn preadv64( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off64_t, +) -> ::ssize_t { + ::preadv(fd, iov, iovcnt, offset) +} + +#[inline] +pub unsafe extern "C" fn pwrite64( + fd: ::c_int, + buf: *const ::c_void, + count: ::size_t, + offset: ::off64_t, +) -> ::ssize_t { + ::pwrite(fd, buf, count, offset) +} + +#[inline] +pub unsafe extern "C" fn pwritev64( + fd: ::c_int, + iov: *const ::iovec, + iovcnt: ::c_int, + offset: ::off64_t, +) -> ::ssize_t { + ::pwritev(fd, iov, iovcnt, offset) +} + +#[inline] +pub unsafe extern "C" fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64 { + ::readdir(dirp) as *mut _ +} + +#[inline] +pub unsafe extern "C" fn readdir64_r( + dirp: *mut ::DIR, + entry: *mut ::dirent64, + result: *mut *mut ::dirent64, +) -> ::c_int { + ::readdir_r(dirp, entry as *mut _, result as *mut _) +} + +#[inline] +pub unsafe extern "C" fn setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int { + ::setrlimit(resource, rlim as *mut _) +} + +#[inline] +pub unsafe extern "C" fn stat64(pathname: *const ::c_char, statbuf: *mut ::stat64) -> ::c_int { + ::stat(pathname, statbuf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn statfs64(pathname: *const ::c_char, buf: *mut ::statfs64) -> ::c_int { + ::statfs(pathname, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn statvfs64(path: *const ::c_char, buf: *mut ::statvfs64) -> ::c_int { + ::statvfs(path, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn tmpfile64() -> *mut ::FILE { + ::tmpfile() +} + +#[inline] +pub unsafe extern "C" fn truncate64(path: *const ::c_char, length: ::off64_t) -> ::c_int { + ::truncate(path, length) +} diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index c0d7071840847..0457f5dadea70 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -5,10 +5,6 @@ pub type dev_t = u32; pub type socklen_t = u32; pub type pthread_t = c_ulong; pub type mode_t = u32; -pub type ino64_t = u64; -pub type off64_t = i64; -pub type blkcnt64_t = i32; -pub type rlim64_t = u64; pub type shmatt_t = ::c_ulong; pub type mqd_t = ::c_int; pub type msgqnum_t = ::c_ulong; @@ -29,11 +25,23 @@ pub type blkcnt_t = i32; pub type blksize_t = c_long; pub type fsblkcnt_t = u32; pub type fsfilcnt_t = u32; -pub type rlim_t = ::c_ulonglong; +pub type rlim_t = u64; pub type c_long = i32; pub type c_ulong = u32; pub type nlink_t = u32; +pub type ino64_t = ::ino_t; +pub type off64_t = ::off_t; +pub type blkcnt64_t = ::blkcnt_t; +pub type rlim64_t = ::rlim_t; + +pub type rlimit64 = ::rlimit; +pub type flock64 = ::flock; +pub type stat64 = ::stat; +pub type statfs64 = ::statfs; +pub type statvfs64 = ::statvfs; +pub type dirent64 = ::dirent; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // FIXME: fill this out with a struct impl ::Copy for fpos64_t {} @@ -44,11 +52,6 @@ impl ::Clone for fpos64_t { } s! { - pub struct rlimit64 { - pub rlim_cur: rlim64_t, - pub rlim_max: rlim64_t, - } - pub struct glob_t { pub gl_pathc: ::size_t, pub gl_pathv: *mut *mut c_char, @@ -223,14 +226,6 @@ s! { pub l_pid: ::pid_t, } - pub struct flock64 { - pub l_type: ::c_short, - pub l_whence: ::c_short, - pub l_start: ::off64_t, - pub l_len: ::off64_t, - pub l_pid: ::pid_t, - } - pub struct pthread_attr_t { __size: [u32; 11] } @@ -283,31 +278,6 @@ s! { pub st_ino: ::ino_t, } - pub struct stat64 { - pub st_dev: ::dev_t, - #[cfg(not(emscripten_new_stat_abi))] - __st_dev_padding: ::c_int, - #[cfg(not(emscripten_new_stat_abi))] - __st_ino_truncated: ::c_long, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - #[cfg(not(emscripten_new_stat_abi))] - __st_rdev_padding: ::c_int, - pub st_size: ::off_t, - pub st_blksize: ::blksize_t, - pub st_blocks: ::blkcnt_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_ino: ::ino_t, - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -370,37 +340,6 @@ s! { _align: [usize; 0], } - pub struct statfs64 { - pub f_type: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_fsid: ::fsid_t, - pub f_namelen: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_flags: ::c_ulong, - pub f_spare: [::c_ulong; 4], - } - - pub struct statvfs64 { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: u32, - pub f_bfree: u32, - pub f_bavail: u32, - pub f_files: u32, - pub f_ffree: u32, - pub f_favail: u32, - pub f_fsid: ::c_ulong, - __f_unused: ::c_int, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - __f_spare: [::c_int; 6], - } - pub struct arpd_request { pub req: ::c_ushort, pub ip: u32, @@ -420,14 +359,6 @@ s_no_extra_traits! { pub d_name: [::c_char; 256], } - pub struct dirent64 { - pub d_ino: ::ino64_t, - pub d_off: ::off64_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - pub struct sysinfo { pub uptime: ::c_ulong, pub loads: [::c_ulong; 3], @@ -491,41 +422,6 @@ cfg_if! { } } - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for dirent64 {} - impl ::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("dirent64") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } - } - impl ::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - impl PartialEq for sysinfo { fn eq(&self, other: &sysinfo) -> bool { self.uptime == other.uptime @@ -1763,8 +1659,6 @@ safe_f! { } extern "C" { - pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; - pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; @@ -1785,17 +1679,6 @@ extern "C" { pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn __errno_location() -> *mut ::c_int; - pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut ::FILE; - pub fn freopen64( - filename: *const c_char, - mode: *const c_char, - file: *mut ::FILE, - ) -> *mut ::FILE; - pub fn tmpfile64() -> *mut ::FILE; - pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; - pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; - pub fn fseeko64(stream: *mut ::FILE, offset: ::off64_t, whence: ::c_int) -> ::c_int; - pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; @@ -1892,6 +1775,10 @@ extern "C" { pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; } +// Alias to 64 to mimic glibc's LFS64 support +mod lfs64; +pub use self::lfs64::*; + cfg_if! { if #[cfg(libc_align)] { #[macro_use] diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 3117c18b86a1a..26fd68de49c7c 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1783,10 +1783,10 @@ extern "C" { // LFS64 extensions // -// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones +// * musl and Emscripten has 64-bit versions only so aliases the LFS64 symbols to the standard ones // * ulibc doesn't have preadv64/pwritev64 cfg_if! { - if #[cfg(not(target_env = "musl"))] { + if #[cfg(not(any(target_env = "musl", target_os = "emscripten")))] { extern "C" { pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int; pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int; @@ -1844,7 +1844,7 @@ cfg_if! { } cfg_if! { - if #[cfg(not(any(target_env = "uclibc", target_env = "musl")))] { + if #[cfg(not(any(target_env = "uclibc", target_env = "musl", target_os = "emscripten")))] { extern "C" { pub fn preadv64( fd: ::c_int, From bcb05a49f25ecf7d92279f82cd9d39958034db01 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 26 Aug 2023 18:14:50 +0100 Subject: [PATCH 07/27] freebsd adding few mmap constants related to page alignment --- libc-test/semver/freebsd.txt | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index e12a3642a8171..8dce49824aa94 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -721,6 +721,8 @@ MALLOCX_TCACHE MALLOCX_ZERO MAP_ALIGNED MAP_ALIGNED_SUPER +MAP_ALIGNMENT_MASK +MAP_ALIGNMENT_SHIFT MAP_COPY MAP_EXCL MAP_FILE diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4138af576e936..d737e86891ef9 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -2664,7 +2664,9 @@ pub const Q_SETQUOTA: ::c_int = 0x800; pub const MAP_GUARD: ::c_int = 0x00002000; pub const MAP_EXCL: ::c_int = 0x00004000; pub const MAP_PREFAULT_READ: ::c_int = 0x00040000; -pub const MAP_ALIGNED_SUPER: ::c_int = 1 << 24; +pub const MAP_ALIGNMENT_SHIFT: ::c_int = 24; +pub const MAP_ALIGNMENT_MASK: ::c_int = 0xff << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNED_SUPER: ::c_int = 1 << MAP_ALIGNMENT_SHIFT; pub const POSIX_FADV_NORMAL: ::c_int = 0; pub const POSIX_FADV_RANDOM: ::c_int = 1; From f054dcfe6e66d6ad18a88710db9bcbd00246dcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E6=B5=A9?= Date: Fri, 1 Sep 2023 11:59:05 +0800 Subject: [PATCH 08/27] Add teeos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 袁浩 --- src/lib.rs | 6 + src/teeos/mod.rs | 1377 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1383 insertions(+) create mode 100644 src/teeos/mod.rs diff --git a/src/lib.rs b/src/lib.rs index d9bd318d1dfb6..dc8f8312072e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,6 +139,12 @@ cfg_if! { mod hermit; pub use hermit::*; + } else if #[cfg(target_os = "teeos")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod teeos; + pub use teeos::*; } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { mod fixed_width_ints; pub use fixed_width_ints::*; diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs new file mode 100644 index 0000000000000..13d8ce1b8ffd2 --- /dev/null +++ b/src/teeos/mod.rs @@ -0,0 +1,1377 @@ +//! Libc bindings for teeos +//! +//! Apparently the loader just dynamically links it anyway, but fails +//! when linking is explicitly requested. +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +// only supported on Rust > 1.59, so we can directly reexport c_void from core. +pub use core::ffi::c_void; + +pub type c_schar = i8; + +pub type c_uchar = u8; + +pub type c_short = i16; + +pub type c_ushort = u16; + +pub type c_int = i32; + +pub type c_uint = u32; + +pub type c_bool = i32; + +pub type c_float = f32; + +pub type c_double = f64; + +pub type c_longlong = i64; + +pub type c_ulonglong = u64; + +pub type intmax_t = i64; + +pub type uintmax_t = u64; + +pub type size_t = usize; + +pub type ptrdiff_t = isize; + +pub type intptr_t = isize; + +pub type uintptr_t = usize; + +pub type ssize_t = isize; + +pub type pid_t = c_int; + +// aarch64 specifc +pub type c_char = u8; + +pub type wchar_t = u32; + +pub type c_long = i64; + +pub type c_ulong = u64; + +#[repr(align(16))] +pub struct _CLongDouble(pub u128); + +// long double in C means A float point value, which has 128bit length. +// but some bit maybe not used, so the really length of long double could be 80(x86) or 128(power pc/IEEE) +// this is different from f128(not stable and not inculded default) in Rust, so we use u128 for FFI(Rust to C). +// this is unstable and will couse to memfault/data abort. +pub type c_longdouble = _CLongDouble; + +pub type pthread_t = c_ulong; + +pub type pthread_key_t = c_uint; + +pub type pthread_spinlock_t = c_int; + +pub type off_t = i64; + +pub type time_t = c_long; + +pub type clock_t = c_long; + +pub type clockid_t = c_int; + +pub type suseconds_t = c_long; + +pub type once_fn = extern "C" fn() -> c_void; + +pub type pthread_once_t = c_int; + +pub type va_list = *mut c_char; + +pub type wint_t = c_uint; + +pub type wctype_t = c_ulong; + +pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; + +#[repr(align(8))] +#[repr(C)] +pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_COND_T], +} + +#[repr(align(8))] +#[repr(C)] +pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], +} + +#[repr(align(4))] +#[repr(C)] +pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], +} + +#[repr(align(4))] +#[repr(C)] +pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], +} + +#[repr(C)] +pub struct pthread_attr_t { + __size: [u64; 7], +} + +#[repr(C)] +pub struct cpu_set_t { + bits: [c_ulong; 128 / core::mem::size_of::()], +} + +#[repr(C)] +pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, +} + +#[repr(C)] +pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, +} + +#[repr(C)] +pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_long, + pub __tm_zone: *const c_char, +} + +#[repr(C)] +pub struct mbstate_t { + pub __opaque1: c_uint, + pub __opaque2: c_uint, +} + +#[repr(C)] +pub struct sem_t { + pub __val: [c_int; 4 * core::mem::size_of::() / core::mem::size_of::()], +} + +#[repr(C)] +pub struct div_t { + pub quot: c_int, + pub rem: c_int, +} + +// fcntl +pub const O_CREAT: u32 = 0100; + +pub const O_EXCL: u32 = 0200; + +pub const O_NOCTTY: u32 = 0400; + +pub const O_TRUNC: u32 = 01000; + +pub const O_APPEND: u32 = 02000; + +pub const O_NONBLOCK: u32 = 04000; + +pub const O_DSYNC: u32 = 010000; + +pub const O_SYNC: u32 = 04010000; + +pub const O_RSYNC: u32 = 04010000; + +pub const O_DIRECTORY: u32 = 0200000; + +pub const O_NOFOLLOW: u32 = 0400000; + +pub const O_CLOEXEC: u32 = 02000000; + +pub const O_ASYNC: u32 = 020000; + +pub const O_DIRECT: u32 = 040000; + +pub const O_LARGEFILE: u32 = 0100000; + +pub const O_NOATIME: u32 = 01000000; + +pub const O_PATH: u32 = 010000000; + +pub const O_TMPFILE: u32 = 020200000; + +pub const O_NDELAY: u32 = O_NONBLOCK; + +pub const F_DUPFD: u32 = 0; + +pub const F_GETFD: u32 = 1; + +pub const F_SETFD: u32 = 2; + +pub const F_GETFL: u32 = 3; + +pub const F_SETFL: u32 = 4; + +pub const F_SETOWN: u32 = 8; + +pub const F_GETOWN: u32 = 9; + +pub const F_SETSIG: u32 = 10; + +pub const F_GETSIG: u32 = 11; + +pub const F_GETLK: u32 = 12; + +pub const F_SETLK: u32 = 13; + +pub const F_SETLKW: u32 = 14; + +pub const F_SETOWN_EX: u32 = 15; + +pub const F_GETOWN_EX: u32 = 16; + +pub const F_GETOWNER_UIDS: u32 = 17; + +// mman +pub const MAP_FAILED: u64 = 0xffffffffffffffff; + +pub const MAP_FIXED_NOREPLACE: u32 = 0x100000; + +pub const MAP_SHARED_VALIDATE: u32 = 0x03; + +pub const MAP_SHARED: u32 = 0x01; + +pub const MAP_PRIVATE: u32 = 0x02; + +pub const MAP_TYPE: u32 = 0x0f; + +pub const MAP_FIXED: u32 = 0x10; + +pub const MAP_ANON: u32 = 0x20; + +pub const MAP_ANONYMOUS: u32 = MAP_ANON; + +pub const MAP_NORESERVE: u32 = 0x4000; + +pub const MAP_GROWSDOWN: u32 = 0x0100; + +pub const MAP_DENYWRITE: u32 = 0x0800; + +pub const MAP_EXECUTABLE: u32 = 0x1000; + +pub const MAP_LOCKED: u32 = 0x2000; + +pub const MAP_POPULATE: u32 = 0x8000; + +pub const MAP_NONBLOCK: u32 = 0x10000; + +pub const MAP_STACK: u32 = 0x20000; + +pub const MAP_HUGETLB: u32 = 0x40000; + +pub const MAP_SYNC: u32 = 0x80000; + +pub const MAP_FILE: u32 = 0; + +pub const MAP_HUGE_SHIFT: u32 = 26; + +pub const MAP_HUGE_MASK: u32 = 0x3f; + +pub const MAP_HUGE_16KB: u32 = 14 << 26; + +pub const MAP_HUGE_64KB: u32 = 16 << 26; + +pub const MAP_HUGE_512KB: u32 = 19 << 26; + +pub const MAP_HUGE_1MB: u32 = 20 << 26; + +pub const MAP_HUGE_2MB: u32 = 21 << 26; + +pub const MAP_HUGE_8MB: u32 = 23 << 26; + +pub const MAP_HUGE_16MB: u32 = 24 << 26; + +pub const MAP_HUGE_32MB: u32 = 25 << 26; + +pub const MAP_HUGE_256MB: u32 = 28 << 26; + +pub const MAP_HUGE_512MB: u32 = 29 << 26; + +pub const MAP_HUGE_1GB: u32 = 30 << 26; + +pub const MAP_HUGE_2GB: u32 = 31 << 26; + +pub const MAP_HUGE_16GB: u32 = 34u32 << 26; + +pub const PROT_NONE: u32 = 0; + +pub const PROT_READ: u32 = 1; + +pub const PROT_WRITE: u32 = 2; + +pub const PROT_EXEC: u32 = 4; + +pub const PROT_GROWSDOWN: u32 = 0x01000000; + +pub const PROT_GROWSUP: u32 = 0x02000000; + +pub const MS_ASYNC: u32 = 1; + +pub const MS_INVALIDATE: u32 = 2; + +pub const MS_SYNC: u32 = 4; + +pub const MCL_CURRENT: u32 = 1; + +pub const MCL_FUTURE: u32 = 2; + +pub const MCL_ONFAULT: u32 = 4; + +pub const POSIX_MADV_NORMAL: u32 = 0; + +pub const POSIX_MADV_RANDOM: u32 = 1; + +pub const POSIX_MADV_SEQUENTIAL: u32 = 2; + +pub const POSIX_MADV_WILLNEED: u32 = 3; + +pub const POSIX_MADV_DONTNEED: u32 = 4; + +// wctype +pub const WCTYPE_ALNUM: u64 = 1; + +pub const WCTYPE_ALPHA: u64 = 2; + +pub const WCTYPE_BLANK: u64 = 3; + +pub const WCTYPE_CNTRL: u64 = 4; + +pub const WCTYPE_DIGIT: u64 = 5; + +pub const WCTYPE_GRAPH: u64 = 6; + +pub const WCTYPE_LOWER: u64 = 7; + +pub const WCTYPE_PRINT: u64 = 8; + +pub const WCTYPE_PUNCT: u64 = 9; + +pub const WCTYPE_SPACE: u64 = 10; + +pub const WCTYPE_UPPER: u64 = 11; + +pub const WCTYPE_XDIGIT: u64 = 12; + +// locale +pub const LC_CTYPE: i32 = 0; + +pub const LC_NUMERIC: i32 = 1; + +pub const LC_TIME: i32 = 2; + +pub const LC_COLLATE: i32 = 3; + +pub const LC_MONETARY: i32 = 4; + +pub const LC_MESSAGES: i32 = 5; + +pub const LC_ALL: i32 = 6; + +// pthread +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; + +// errno.h +pub const EPERM: c_int = 1; + +pub const ENOENT: c_int = 2; + +pub const ESRCH: c_int = 3; + +pub const EINTR: c_int = 4; + +pub const EIO: c_int = 5; + +pub const ENXIO: c_int = 6; + +pub const E2BIG: c_int = 7; + +pub const ENOEXEC: c_int = 8; + +pub const EBADF: c_int = 9; + +pub const ECHILD: c_int = 10; + +pub const EAGAIN: c_int = 11; + +pub const ENOMEM: c_int = 12; + +pub const EACCES: c_int = 13; + +pub const EFAULT: c_int = 14; + +pub const ENOTBLK: c_int = 15; + +pub const EBUSY: c_int = 16; + +pub const EEXIST: c_int = 17; + +pub const EXDEV: c_int = 18; + +pub const ENODEV: c_int = 19; + +pub const ENOTDIR: c_int = 20; + +pub const EISDIR: c_int = 21; + +pub const EINVAL: c_int = 22; + +pub const ENFILE: c_int = 23; + +pub const EMFILE: c_int = 24; + +pub const ENOTTY: c_int = 25; + +pub const ETXTBSY: c_int = 26; + +pub const EFBIG: c_int = 27; + +pub const ENOSPC: c_int = 28; + +pub const ESPIPE: c_int = 29; + +pub const EROFS: c_int = 30; + +pub const EMLINK: c_int = 31; + +pub const EPIPE: c_int = 32; + +pub const EDOM: c_int = 33; + +pub const ERANGE: c_int = 34; + +pub const EDEADLK: c_int = 35; + +pub const ENAMETOOLONG: c_int = 36; + +pub const ENOLCK: c_int = 37; + +pub const ENOSYS: c_int = 38; + +pub const ENOTEMPTY: c_int = 39; + +pub const ELOOP: c_int = 40; + +pub const EWOULDBLOCK: c_int = EAGAIN; + +pub const ENOMSG: c_int = 42; + +pub const EIDRM: c_int = 43; + +pub const ECHRNG: c_int = 44; + +pub const EL2NSYNC: c_int = 45; + +pub const EL3HLT: c_int = 46; + +pub const EL3RST: c_int = 47; + +pub const ELNRNG: c_int = 48; + +pub const EUNATCH: c_int = 49; + +pub const ENOCSI: c_int = 50; + +pub const EL2HLT: c_int = 51; + +pub const EBADE: c_int = 52; + +pub const EBADR: c_int = 53; + +pub const EXFULL: c_int = 54; + +pub const ENOANO: c_int = 55; + +pub const EBADRQC: c_int = 56; + +pub const EBADSLT: c_int = 57; + +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EBFONT: c_int = 59; + +pub const ENOSTR: c_int = 60; + +pub const ENODATA: c_int = 61; + +pub const ETIME: c_int = 62; + +pub const ENOSR: c_int = 63; + +pub const ENONET: c_int = 64; + +pub const ENOPKG: c_int = 65; + +pub const EREMOTE: c_int = 66; + +pub const ENOLINK: c_int = 67; + +pub const EADV: c_int = 68; + +pub const ESRMNT: c_int = 69; + +pub const ECOMM: c_int = 70; + +pub const EPROTO: c_int = 71; + +pub const EMULTIHOP: c_int = 72; + +pub const EDOTDOT: c_int = 73; + +pub const EBADMSG: c_int = 74; + +pub const EOVERFLOW: c_int = 75; + +pub const ENOTUNIQ: c_int = 76; + +pub const EBADFD: c_int = 77; + +pub const EREMCHG: c_int = 78; + +pub const ELIBACC: c_int = 79; + +pub const ELIBBAD: c_int = 80; + +pub const ELIBSCN: c_int = 81; + +pub const ELIBMAX: c_int = 82; + +pub const ELIBEXEC: c_int = 83; + +pub const EILSEQ: c_int = 84; + +pub const ERESTART: c_int = 85; + +pub const ESTRPIPE: c_int = 86; + +pub const EUSERS: c_int = 87; + +pub const ENOTSOCK: c_int = 88; + +pub const EDESTADDRREQ: c_int = 89; + +pub const EMSGSIZE: c_int = 90; + +pub const EPROTOTYPE: c_int = 91; + +pub const ENOPROTOOPT: c_int = 92; + +pub const EPROTONOSUPPOR: c_int = 93; + +pub const ESOCKTNOSUPPOR: c_int = 94; + +pub const EOPNOTSUPP: c_int = 95; + +pub const ENOTSUP: c_int = EOPNOTSUPP; + +pub const EPFNOSUPPORT: c_int = 96; + +pub const EAFNOSUPPORT: c_int = 97; + +pub const EADDRINUSE: c_int = 98; + +pub const EADDRNOTAVAIL: c_int = 99; + +pub const ENETDOWN: c_int = 100; + +pub const ENETUNREACH: c_int = 101; + +pub const ENETRESET: c_int = 102; + +pub const ECONNABORTED: c_int = 103; + +pub const ECONNRESET: c_int = 104; + +pub const ENOBUFS: c_int = 105; + +pub const EISCONN: c_int = 106; + +pub const ENOTCONN: c_int = 107; + +pub const ESHUTDOWN: c_int = 108; + +pub const ETOOMANYREFS: c_int = 109; + +pub const ETIMEDOUT: c_int = 110; + +pub const ECONNREFUSED: c_int = 111; + +pub const EHOSTDOWN: c_int = 112; + +pub const EHOSTUNREACH: c_int = 113; + +pub const EALREADY: c_int = 114; + +pub const EINPROGRESS: c_int = 115; + +pub const ESTALE: c_int = 116; + +pub const EUCLEAN: c_int = 117; + +pub const ENOTNAM: c_int = 118; + +pub const ENAVAIL: c_int = 119; + +pub const EISNAM: c_int = 120; + +pub const EREMOTEIO: c_int = 121; + +pub const EDQUOT: c_int = 122; + +pub const ENOMEDIUM: c_int = 123; + +pub const EMEDIUMTYPE: c_int = 124; + +pub const ECANCELED: c_int = 125; + +pub const ENOKEY: c_int = 126; + +pub const EKEYEXPIRED: c_int = 127; + +pub const EKEYREVOKED: c_int = 128; + +pub const EKEYREJECTED: c_int = 129; + +pub const EOWNERDEAD: c_int = 130; + +pub const ENOTRECOVERABLE: c_int = 131; + +pub const ERFKILL: c_int = 132; + +pub const EHWPOISON: c_int = 133; + +// pthread_attr.h +pub const TEESMP_THREAD_ATTR_CA_WILDCARD: c_int = 0; + +pub const TEESMP_THREAD_ATTR_CA_INHERIT: c_int = -1; + +pub const TEESMP_THREAD_ATTR_TASK_ID_INHERIT: c_int = -1; + +pub const TEESMP_THREAD_ATTR_HAS_SHADOW: c_int = 0x1; + +pub const TEESMP_THREAD_ATTR_NO_SHADOW: c_int = 0x0; + +// unistd.h +pub const _SC_ARG_MAX: c_int = 0; + +pub const _SC_CHILD_MAX: c_int = 1; + +pub const _SC_CLK_TCK: c_int = 2; + +pub const _SC_NGROUPS_MAX: c_int = 3; + +pub const _SC_OPEN_MAX: c_int = 4; + +pub const _SC_STREAM_MAX: c_int = 5; + +pub const _SC_TZNAME_MAX: c_int = 6; + +pub const _SC_JOB_CONTROL: c_int = 7; + +pub const _SC_SAVED_IDS: c_int = 8; + +pub const _SC_REALTIME_SIGNALS: c_int = 9; + +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; + +pub const _SC_TIMERS: c_int = 11; + +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; + +pub const _SC_PRIORITIZED_IO: c_int = 13; + +pub const _SC_SYNCHRONIZED_IO: c_int = 14; + +pub const _SC_FSYNC: c_int = 15; + +pub const _SC_MAPPED_FILES: c_int = 16; + +pub const _SC_MEMLOCK: c_int = 17; + +pub const _SC_MEMLOCK_RANGE: c_int = 18; + +pub const _SC_MEMORY_PROTECTION: c_int = 19; + +pub const _SC_MESSAGE_PASSING: c_int = 20; + +pub const _SC_SEMAPHORES: c_int = 21; + +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; + +pub const _SC_AIO_LISTIO_MAX: c_int = 23; + +pub const _SC_AIO_MAX: c_int = 24; + +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; + +pub const _SC_DELAYTIMER_MAX: c_int = 26; + +pub const _SC_MQ_OPEN_MAX: c_int = 27; + +pub const _SC_MQ_PRIO_MAX: c_int = 28; + +pub const _SC_VERSION: c_int = 29; + +pub const _SC_PAGE_SIZE: c_int = 30; + +pub const _SC_PAGESIZE: c_int = 30; /* !! */ + +pub const _SC_RTSIG_MAX: c_int = 31; + +pub const _SC_SEM_NSEMS_MAX: c_int = 32; + +pub const _SC_SEM_VALUE_MAX: c_int = 33; + +pub const _SC_SIGQUEUE_MAX: c_int = 34; + +pub const _SC_TIMER_MAX: c_int = 35; + +pub const _SC_BC_BASE_MAX: c_int = 36; + +pub const _SC_BC_DIM_MAX: c_int = 37; + +pub const _SC_BC_SCALE_MAX: c_int = 38; + +pub const _SC_BC_STRING_MAX: c_int = 39; + +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; + +pub const _SC_EXPR_NEST_MAX: c_int = 42; + +pub const _SC_LINE_MAX: c_int = 43; + +pub const _SC_RE_DUP_MAX: c_int = 44; + +pub const _SC_2_VERSION: c_int = 46; + +pub const _SC_2_C_BIND: c_int = 47; + +pub const _SC_2_C_DEV: c_int = 48; + +pub const _SC_2_FORT_DEV: c_int = 49; + +pub const _SC_2_FORT_RUN: c_int = 50; + +pub const _SC_2_SW_DEV: c_int = 51; + +pub const _SC_2_LOCALEDEF: c_int = 52; + +pub const _SC_UIO_MAXIOV: c_int = 60; /* !! */ + +pub const _SC_IOV_MAX: c_int = 60; + +pub const _SC_THREADS: c_int = 67; + +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; + +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; + +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; + +pub const _SC_LOGIN_NAME_MAX: c_int = 71; + +pub const _SC_TTY_NAME_MAX: c_int = 72; + +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; + +pub const _SC_THREAD_KEYS_MAX: c_int = 74; + +pub const _SC_THREAD_STACK_MIN: c_int = 75; + +pub const _SC_THREAD_THREADS_MAX: c_int = 76; + +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; + +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; + +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; + +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; + +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; + +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; + +pub const _SC_NPROCESSORS_CONF: c_int = 83; + +pub const _SC_NPROCESSORS_ONLN: c_int = 84; + +pub const _SC_PHYS_PAGES: c_int = 85; + +pub const _SC_AVPHYS_PAGES: c_int = 86; + +pub const _SC_ATEXIT_MAX: c_int = 87; + +pub const _SC_PASS_MAX: c_int = 88; + +pub const _SC_XOPEN_VERSION: c_int = 89; + +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; + +pub const _SC_XOPEN_UNIX: c_int = 91; + +pub const _SC_XOPEN_CRYPT: c_int = 92; + +pub const _SC_XOPEN_ENH_I18N: c_int = 93; + +pub const _SC_XOPEN_SHM: c_int = 94; + +pub const _SC_2_CHAR_TERM: c_int = 95; + +pub const _SC_2_UPE: c_int = 97; + +pub const _SC_XOPEN_XPG2: c_int = 98; + +pub const _SC_XOPEN_XPG3: c_int = 99; + +pub const _SC_XOPEN_XPG4: c_int = 100; + +pub const _SC_NZERO: c_int = 109; + +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; + +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; + +pub const _SC_XBS5_LP64_OFF64: c_int = 127; + +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; + +pub const _SC_XOPEN_LEGACY: c_int = 129; + +pub const _SC_XOPEN_REALTIME: c_int = 130; + +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; + +pub const _SC_ADVISORY_INFO: c_int = 132; + +pub const _SC_BARRIERS: c_int = 133; + +pub const _SC_CLOCK_SELECTION: c_int = 137; + +pub const _SC_CPUTIME: c_int = 138; + +pub const _SC_THREAD_CPUTIME: c_int = 139; + +pub const _SC_MONOTONIC_CLOCK: c_int = 149; + +pub const _SC_READER_WRITER_LOCKS: c_int = 153; + +pub const _SC_SPIN_LOCKS: c_int = 154; + +pub const _SC_REGEXP: c_int = 155; + +pub const _SC_SHELL: c_int = 157; + +pub const _SC_SPAWN: c_int = 159; + +pub const _SC_SPORADIC_SERVER: c_int = 160; + +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; + +pub const _SC_TIMEOUTS: c_int = 164; + +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; + +pub const _SC_2_PBS: c_int = 168; + +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; + +pub const _SC_2_PBS_LOCATE: c_int = 170; + +pub const _SC_2_PBS_MESSAGE: c_int = 171; + +pub const _SC_2_PBS_TRACK: c_int = 172; + +pub const _SC_SYMLOOP_MAX: c_int = 173; + +pub const _SC_STREAMS: c_int = 174; + +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; + +pub const _SC_V6_ILP32_OFF32: c_int = 176; + +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; + +pub const _SC_V6_LP64_OFF64: c_int = 178; + +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; + +pub const _SC_HOST_NAME_MAX: c_int = 180; + +pub const _SC_TRACE: c_int = 181; + +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; + +pub const _SC_TRACE_INHERIT: c_int = 183; + +pub const _SC_TRACE_LOG: c_int = 184; + +pub const _SC_IPV6: c_int = 235; + +pub const _SC_RAW_SOCKETS: c_int = 236; + +pub const _SC_V7_ILP32_OFF32: c_int = 237; + +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; + +pub const _SC_V7_LP64_OFF64: c_int = 239; + +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; + +pub const _SC_SS_REPL_MAX: c_int = 241; + +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; + +pub const _SC_TRACE_NAME_MAX: c_int = 243; + +pub const _SC_TRACE_SYS_MAX: c_int = 244; + +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; + +pub const _SC_XOPEN_STREAMS: c_int = 246; + +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; + +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + +// limits.h +pub const PTHREAD_KEYS_MAX: c_int = 128; + +pub const PTHREAD_STACK_MIN: c_int = 2048; + +pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_int = 4; + +pub const SEM_VALUE_MAX: c_int = 0x7fffffff; + +pub const SEM_NSEMS_MAX: c_int = 256; + +pub const DELAYTIMER_MAX: c_int = 0x7fffffff; + +pub const MQ_PRIO_MAX: c_int = 32768; + +pub const LOGIN_NAME_MAX: c_int = 256; + +// time.h +pub const CLOCK_REALTIME: clockid_t = 0; + +pub const CLOCK_MONOTONIC: clockid_t = 1; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; + +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; + +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; + +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; + +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +pub const PTHREAD_MUTEX_STALLED: c_int = 0; + +pub const PTHREAD_MUTEX_ROBUST: c_int = 1; + +extern "C" { + // ---- ALLOC ----------------------------------------------------------------------------- + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + + pub fn malloc(size: size_t) -> *mut c_void; + + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + + pub fn aligned_alloc(align: size_t, len: size_t) -> *mut c_void; + + pub fn free(p: *mut c_void); + + pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; + + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + // ----- PTHREAD --------------------------------------------------------------------------- + pub fn pthread_self() -> pthread_t; + + pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int; + + // detach or pthread_attr_setdetachstate must not be called! + //pub fn pthread_detach(thread: pthread_t) -> c_int; + + pub fn pthread_exit(value: *mut c_void) -> !; + + pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + + pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; + + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + + pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, size: *mut size_t) -> c_int; + + pub fn pthread_attr_settee( + attr: *mut pthread_attr_t, + ca: c_int, + task_id: c_int, + shadow: c_int, + ) -> c_int; + + // C-TA API do not include this interface, but TA can use. + pub fn sched_yield() -> c_int; + + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: c_int) -> c_int; + + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_setschedprio(native: pthread_t, priority: c_int) -> c_int; + + pub fn pthread_once(pot: *mut pthread_once_t, f: Option) -> c_int; + + pub fn pthread_equal(p1: pthread_t, p2: pthread_t) -> c_int; + + pub fn pthread_mutexattr_setprotocol(a: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + + pub fn pthread_attr_setstack( + attr: *mut pthread_attr_t, + stack: *mut c_void, + size: size_t, + ) -> c_int; + + pub fn pthread_setaffinity_np(td: pthread_t, size: size_t, set: *const cpu_set_t) -> c_int; + + pub fn pthread_getaffinity_np(td: pthread_t, size: size_t, set: *mut cpu_set_t) -> c_int; + + // stdio.h + pub fn printf(fmt: *const c_char, ...) -> c_int; + + pub fn scanf(fmt: *const c_char, ...) -> c_int; + + pub fn snprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ...) -> c_int; + + pub fn sprintf(s: *mut c_char, fmt: *const c_char, ...) -> c_int; + + pub fn vsnprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ap: va_list) -> c_int; + + pub fn vsprintf(s: *mut c_char, fmt: *const c_char, ap: va_list) -> c_int; + + // Not available. + //pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> c_int; + + pub fn abort() -> !; + + // Not available. + //pub fn prctl(op: c_int, ...) -> c_int; + + pub fn sched_getaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *mut cpu_set_t) -> c_int; + + pub fn sched_setaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *const cpu_set_t) -> c_int; + + // sysconf is currently only implemented as a stub. + pub fn sysconf(name: c_int) -> c_long; + + // mman.h + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + // errno.h + pub fn __errno_location() -> *mut c_int; + + pub fn strerror(e: c_int) -> *mut c_char; + + // time.h + pub fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int; + + // unistd + pub fn getpid() -> pid_t; + + // time + pub fn gettimeofday(tv: *mut timeval, tz: *mut c_void) -> c_int; + + pub fn strftime( + restrict: *mut c_char, + sz: size_t, + _restrict: *const c_char, + __restrict: *const tm, + ) -> size_t; + + pub fn time(t: *mut time_t) -> time_t; + + // sem + pub fn sem_close(sem: *mut sem_t) -> c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + + pub fn sem_getvalue(sem: *mut sem_t, valp: *mut c_int) -> c_int; + + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn sem_open(name: *const c_char, flags: c_int, ...) -> *mut sem_t; + + pub fn sem_post(sem: *mut sem_t) -> c_int; + + pub fn sem_unlink(name: *const c_char) -> c_int; + + pub fn sem_wait(sem: *mut sem_t) -> c_int; + + // locale + pub fn setlocale(cat: c_int, name: *const c_char) -> *mut c_char; + + pub fn strcoll(l: *const c_char, r: *const c_char) -> c_int; + + pub fn strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t; + + pub fn strtod(s: *const c_char, p: *mut *mut c_char) -> c_double; + + // multibyte + pub fn mbrtowc(wc: *mut wchar_t, src: *const c_char, n: size_t, st: *mut mbstate_t) -> size_t; + + pub fn wcrtomb(s: *mut c_char, wc: wchar_t, st: *mut mbstate_t) -> size_t; + + pub fn wctob(c: wint_t) -> c_int; + + // prng + pub fn srandom(seed: c_uint); + + pub fn initstate(seed: c_uint, state: *mut c_char, size: size_t) -> *mut c_char; + + pub fn setstate(state: *mut c_char) -> *mut c_char; + + pub fn random() -> c_long; + + // string + pub fn strchr(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn strlen(cs: *const c_char) -> size_t; + + pub fn strcmp(l: *const c_char, r: *const c_char) -> c_int; + + pub fn strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char; + + pub fn strncmp(_l: *const c_char, r: *const c_char, n: size_t) -> c_int; + + pub fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + + pub fn strnlen(cs: *const c_char, n: size_t) -> size_t; + + pub fn strrchr(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn strstr(h: *const c_char, n: *const c_char) -> *mut c_char; + + pub fn wcschr(s: *const wchar_t, c: wchar_t) -> *mut wchar_t; + + pub fn wcslen(s: *const wchar_t) -> size_t; + + // ctype + pub fn isalpha(c: c_int) -> c_int; + + pub fn isascii(c: c_int) -> c_int; + + pub fn isdigit(c: c_int) -> c_int; + + pub fn islower(c: c_int) -> c_int; + + pub fn isprint(c: c_int) -> c_int; + + pub fn isspace(c: c_int) -> c_int; + + pub fn iswctype(wc: wint_t, ttype: wctype_t) -> c_int; + + pub fn iswdigit(wc: wint_t) -> c_int; + + pub fn iswlower(wc: wint_t) -> c_int; + + pub fn iswspace(wc: wint_t) -> c_int; + + pub fn iswupper(wc: wint_t) -> c_int; + + pub fn towupper(wc: wint_t) -> wint_t; + + pub fn towlower(wc: wint_t) -> wint_t; + + // cmath + pub fn atan(x: c_double) -> c_double; + + pub fn ceil(x: c_double) -> c_double; + + pub fn ceilf(x: c_float) -> c_float; + + pub fn exp(x: c_double) -> c_double; + + pub fn fabs(x: c_double) -> c_double; + + pub fn floor(x: c_double) -> c_double; + + pub fn frexp(x: c_double, e: *mut c_int) -> c_double; + + pub fn log(x: c_double) -> c_double; + + pub fn log2(x: c_double) -> c_double; + + pub fn pow(x: c_double, y: c_double) -> c_double; + + pub fn roundf(x: c_float) -> c_float; + + pub fn scalbn(x: c_double, n: c_int) -> c_double; + + pub fn sqrt(x: c_double) -> c_double; + + // stdlib + pub fn abs(x: c_int) -> c_int; + + pub fn atof(s: *const c_char) -> c_double; + + pub fn atoi(s: *const c_char) -> c_int; + + pub fn atol(s: *const c_char) -> c_long; + + pub fn atoll(s: *const c_char) -> c_longlong; + + pub fn bsearch( + key: *const c_void, + base: *const c_void, + nel: size_t, + width: size_t, + cmp: cmpfunc, + ) -> *mut c_void; + + pub fn div(num: c_int, den: c_int) -> div_t; + + pub fn ecvt(x: c_double, n: c_int, dp: *mut c_int, sign: *mut c_int) -> *mut c_char; + + pub fn imaxabs(a: intmax_t) -> intmax_t; + + pub fn llabs(a: c_longlong) -> c_longlong; + + pub fn qsort(base: *mut c_void, nel: size_t, width: size_t, cmp: cmpfunc); + + pub fn strtoul(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_ulong; + + pub fn strtol(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_long; + + pub fn wcstod(s: *const wchar_t, p: *mut *mut wchar_t) -> c_double; +} + +pub fn errno() -> c_int { + unsafe { *__errno_location() } +} + +pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { + let mut s: u32 = 0; + let size_of_mask = core::mem::size_of_val(&cpuset.bits[0]); + + for i in cpuset.bits[..(size / size_of_mask)].iter() { + s += i.count_ones(); + } + s as c_int +} + +pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { + CPU_COUNT_S(core::mem::size_of::(), cpuset) +} From 53e039beaa76e9bdd976fd0b6564b0787190b2c0 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 6 Sep 2023 21:20:48 +0100 Subject: [PATCH 09/27] linux MADV_COLLAPSE addition --- libc-test/build.rs | 3 +++ libc-test/semver/linux-gnu.txt | 1 + src/unix/linux_like/linux/gnu/mod.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index bfe1ed16f3951..507f6bf9fb319 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3791,6 +3791,9 @@ fn test_linux(target: &str) { | "MADV_POPULATE_WRITE" if musl => true, + // kernel 6.1 minimum + "MADV_COLLAPSE" => true, + // FIXME: Requires more recent kernel headers | "IFLA_PARENT_DEV_NAME" // linux v5.13+ | "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+ diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 07f6365826275..422ca4311c802 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -118,6 +118,7 @@ LM_ID_BASE LM_ID_NEWLM LOGIN_PROCESS Lmid_t +MADV_COLLAPSE MAXTC MAX_LINKS MINIX2_SUPER_MAGIC diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 2d74087e930f6..222634f33bc7f 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1093,6 +1093,8 @@ pub const GLOB_TILDE: ::c_int = 1 << 12; pub const GLOB_ONLYDIR: ::c_int = 1 << 13; pub const GLOB_TILDE_CHECK: ::c_int = 1 << 14; +pub const MADV_COLLAPSE: ::c_int = 25; + cfg_if! { if #[cfg(any( target_arch = "arm", From 0f66767255eb7ce29974d013d147d872cea8fad1 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Sat, 9 Sep 2023 11:36:32 +0100 Subject: [PATCH 10/27] copyfile apple api update --- libc-test/semver/apple.txt | 18 ++++++++++++++++++ src/unix/bsd/apple/mod.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 7c4356432f5a7..10e505ed46dd0 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -245,6 +245,19 @@ COPYFILE_SECURITY COPYFILE_SKIP COPYFILE_START COPYFILE_STAT +COPYFILE_STATE_BSIZE +COPYFILE_STATE_COPIED +COPYFILE_STATE_DST_BSIZE +COPYFILE_STATE_DST_FD +COPYFILE_STATE_DST_FILENAME +COPYFILE_STATE_QUARANTINE +COPYFILE_STATE_SRC_BSIZE +COPYFILE_STATE_SRC_FD +COPYFILE_STATE_SRC_FILENAME +COPYFILE_STATE_STATUS_CB +COPYFILE_STATE_STATUS_CTX +COPYFILE_STATE_XATTRNAME +COPYFILE_STATE_WAS_CLONED COPYFILE_VERBOSE COPYFILE_UNLINK COPYFILE_XATTR @@ -1844,7 +1857,12 @@ cmsghdr confstr connectx copyfile +copyfile_callback_t copyfile_flags_t +copyfile_state_alloc +copyfile_state_free +copyfile_state_get +copyfile_state_set cpu_subtype_t cpu_type_t ctime diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index a2fbf876731ba..bf571aeb738ff 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -145,6 +145,16 @@ pub type CCRNGStatus = ::CCCryptorStatus; pub type copyfile_state_t = *mut ::c_void; pub type copyfile_flags_t = u32; +pub type copyfile_callback_t = ::Option< + extern "C" fn( + ::c_int, + ::c_int, + copyfile_state_t, + *const ::c_char, + *const ::c_char, + *mut ::c_void, + ) -> ::c_int, +>; pub type attrgroup_t = u32; pub type vol_capabilities_set_t = [u32; 4]; @@ -4911,6 +4921,19 @@ pub const COPYFILE_PROGRESS: ::c_int = 4; pub const COPYFILE_CONTINUE: ::c_int = 0; pub const COPYFILE_SKIP: ::c_int = 1; pub const COPYFILE_QUIT: ::c_int = 2; +pub const COPYFILE_STATE_SRC_FD: ::c_int = 1; +pub const COPYFILE_STATE_SRC_FILENAME: ::c_int = 2; +pub const COPYFILE_STATE_DST_FD: ::c_int = 3; +pub const COPYFILE_STATE_DST_FILENAME: ::c_int = 4; +pub const COPYFILE_STATE_QUARANTINE: ::c_int = 5; +pub const COPYFILE_STATE_STATUS_CB: ::c_int = 6; +pub const COPYFILE_STATE_STATUS_CTX: ::c_int = 7; +pub const COPYFILE_STATE_COPIED: ::c_int = 8; +pub const COPYFILE_STATE_XATTRNAME: ::c_int = 9; +pub const COPYFILE_STATE_WAS_CLONED: ::c_int = 10; +pub const COPYFILE_STATE_SRC_BSIZE: ::c_int = 11; +pub const COPYFILE_STATE_DST_BSIZE: ::c_int = 12; +pub const COPYFILE_STATE_BSIZE: ::c_int = 13; // pub const ATTR_BIT_MAP_COUNT: ::c_ushort = 5; @@ -5819,6 +5842,10 @@ extern "C" { state: copyfile_state_t, flags: copyfile_flags_t, ) -> ::c_int; + pub fn copyfile_state_free(s: copyfile_state_t) -> ::c_int; + pub fn copyfile_state_alloc() -> copyfile_state_t; + pub fn copyfile_state_get(s: copyfile_state_t, flags: u32, dst: *mut ::c_void) -> ::c_int; + pub fn copyfile_state_set(s: copyfile_state_t, flags: u32, src: *const ::c_void) -> ::c_int; // Added in macOS 10.13 // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 From 27f5eba6aa20bc5557543d126503cbda36ced242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Mon, 11 Sep 2023 15:45:04 +0200 Subject: [PATCH 11/27] Remove unix variant of Hermit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This code has been dead for a few years now. Signed-off-by: Martin Kröning --- src/unix/hermit/aarch64.rs | 2 - src/unix/hermit/mod.rs | 1023 ------------------------------------ src/unix/hermit/x86_64.rs | 2 - src/unix/mod.rs | 8 - 4 files changed, 1035 deletions(-) delete mode 100644 src/unix/hermit/aarch64.rs delete mode 100644 src/unix/hermit/mod.rs delete mode 100644 src/unix/hermit/x86_64.rs diff --git a/src/unix/hermit/aarch64.rs b/src/unix/hermit/aarch64.rs deleted file mode 100644 index 1a92e3b4fa341..0000000000000 --- a/src/unix/hermit/aarch64.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_char = u8; -pub type wchar_t = u32; diff --git a/src/unix/hermit/mod.rs b/src/unix/hermit/mod.rs deleted file mode 100644 index 6a656a8598f21..0000000000000 --- a/src/unix/hermit/mod.rs +++ /dev/null @@ -1,1023 +0,0 @@ -// liblibc port for HermitCore (https://hermitcore.org) -// HermitCore is a unikernel based on lwIP, newlib, and -// pthread-embedded. -// Consider these definitions when porting liblibc to another -// lwIP/newlib/pte-based target. -// -// Ported by Colin Finck - -pub type c_long = i64; -pub type c_ulong = u64; - -pub type speed_t = ::c_uint; -pub type mode_t = u32; -pub type dev_t = i16; -pub type nfds_t = ::c_ulong; -pub type socklen_t = u32; -pub type sa_family_t = u8; -pub type clock_t = c_ulong; -pub type time_t = c_long; -pub type suseconds_t = c_long; -pub type off_t = i64; -pub type rlim_t = ::c_ulonglong; -pub type sigset_t = ::c_ulong; -pub type ino_t = u16; -pub type nlink_t = u16; -pub type blksize_t = c_long; -pub type blkcnt_t = c_long; -pub type stat64 = stat; -pub type clockid_t = c_ulong; -pub type pthread_t = pte_handle_t; -pub type pthread_attr_t = usize; -pub type pthread_cond_t = usize; -pub type pthread_condattr_t = usize; -pub type pthread_key_t = usize; -pub type pthread_mutex_t = usize; -pub type pthread_mutexattr_t = usize; -pub type pthread_rwlock_t = usize; -pub type pthread_rwlockattr_t = usize; - -s_no_extra_traits! { - pub struct dirent { - pub d_ino: ::c_long, - pub d_off: off_t, - pub d_reclen: u16, - pub d_name: [::c_char; 256], - } - - // Dummy - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [::c_char; 108], - } - - pub struct sockaddr { - pub sa_len: u8, - pub sa_family: sa_family_t, - pub sa_data: [::c_char; 14], - } - - pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: sa_family_t, - pub sin_port: ::in_port_t, - pub sin_addr: ::in_addr, - pub sin_zero: [::c_char; 8], - } - - pub struct fd_set { - fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], - } - - pub struct sockaddr_storage { - pub s2_len: u8, - pub ss_family: sa_family_t, - pub s2_data1: [::c_char; 2], - pub s2_data2: [u32; 3], - pub s2_data3: [u32; 3], - } - - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: dev_t, - pub st_size: off_t, - pub st_atime: time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: time_t, - pub st_ctime_nsec: ::c_long, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_spare4: [::c_long; 2], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for dirent {} - impl ::fmt::Debug for dirent { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - // FIXME: .field("d_name", &self.d_name) - .finish() - } - } - impl ::hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl ::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) - .finish() - } - } - impl ::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr { - fn eq(&self, other: &sockaddr) -> bool { - self.sa_len == other.sa_len - && self.sa_family == other.sa_family - && self - .sa_data - .iter() - .zip(other.sa_data.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for sockaddr {} - impl ::fmt::Debug for sockaddr { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("sockaddr") - .field("sa_len", &self.sa_len) - .field("sa_family", &self.sa_family) - // FIXME: .field("sa_data", &self.sa_data) - .finish() - } - } - impl ::hash::Hash for sockaddr { - fn hash(&self, state: &mut H) { - self.sa_len.hash(state); - self.sa_family.hash(state); - self.sa_data.hash(state); - } - } - - impl PartialEq for sockaddr_in { - fn eq(&self, other: &sockaddr_in) -> bool { - self.sin_len == other.sin_len - && self.sin_family == other.sin_family - && self.sin_port == other.sin_port - && self.sin_addr == other.sin_addr - && self - .sin_zero - .iter() - .zip(other.sin_zero.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for sockaddr_in {} - impl ::fmt::Debug for sockaddr_in { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("sockaddr_in") - .field("sin_len", &self.sin_len) - .field("sin_family", &self.sin_family) - .field("sin_port", &self.sin_port) - .field("sin_addr", &self.sin_addr) - // FIXME: .field("sin_zero", &self.sin_zero) - .finish() - } - } - impl ::hash::Hash for sockaddr_in { - fn hash(&self, state: &mut H) { - self.sin_len.hash(state); - self.sin_family.hash(state); - self.sin_port.hash(state); - self.sin_addr.hash(state); - self.sin_zero.hash(state); - } - } - - impl PartialEq for fd_set { - fn eq(&self, other: &fd_set) -> bool { - self.fds_bits - .iter() - .zip(other.fds_bits.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for fd_set {} - impl ::fmt::Debug for fd_set { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("fd_set") - // FIXME: .field("fds_bits", &self.fds_bits) - .finish() - } - } - impl ::hash::Hash for fd_set { - fn hash(&self, state: &mut H) { - self.fds_bits.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.s2_len == other.s2_len - && self.ss_family == other.ss_family - && self.s2_data1 - .iter() - .zip(other.s2_data1.iter()) - .all(|(a,b)| a == b) - && self.s2_data2 - .iter() - .zip(other.s2_data2.iter()) - .all(|(a,b)| a == b) - && self.s2_data3 - .iter() - .zip(other.s2_data3.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl ::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("sockaddr_storage") - .field("s2_len", &self.s2_len) - .field("ss_family", &self.ss_family) - // FIXME: .field("s2_data1", &self.s2_data1) - // FIXME: .field("s2_data2", &self.s2_data2) - // FIXME: .field("s2_data3", &self.s2_data3) - .finish() - } - } - impl ::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.s2_len.hash(state); - self.ss_family.hash(state); - self.s2_data1.hash(state); - self.s2_data2.hash(state); - self.s2_data3.hash(state); - } - } - - impl PartialEq for stat { - fn eq(&self, other: &stat) -> bool { - self.st_dev == other.st_dev - && self.st_ino == other.st_ino - && self.st_mode == other.st_mode - && self.st_nlink == other.st_nlink - && self.st_uid == other.st_uid - && self.st_gid == other.st_gid - && self.st_rdev == other.st_rdev - && self.st_size == other.st_size - && self.st_atime == other.st_atime - && self.st_atime_nsec == other.st_atime_nsec - && self.st_mtime == other.st_mtime - && self.st_mtime_nsec == other.st_mtime_nsec - && self.st_ctime == other.st_ctime - && self.st_ctime_nsec == other.st_ctime_nsec - && self.st_blksize == other.st_blksize - && self.st_blocks == other.st_blocks - && self - .st_spare4 - .iter() - .zip(other.st_spare4.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for stat {} - impl ::fmt::Debug for stat { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("stat") - .field("st_dev", &self.st_dev) - .field("st_ino", &self.st_ino) - .field("st_mode", &self.st_mode) - .field("st_nlink", &self.st_nlink) - .field("st_uid", &self.st_uid) - .field("st_gid", &self.st_gid) - .field("st_rdev", &self.st_rdev) - .field("st_size", &self.st_size) - .field("st_atime", &self.st_atime) - .field("st_atime_nsec", &self.st_atime_nsec) - .field("st_mtime", &self.st_mtime) - .field("st_mtime_nsec", &self.st_mtime_nsec) - .field("st_ctime", &self.st_ctime) - .field("st_ctime_nsec", &self.st_ctime_nsec) - .field("st_blksize", &self.st_blksize) - .field("st_blocks", &self.st_blocks) - // FIXME: .field("st_spare4", &self.st_spare4) - .finish() - } - } - impl ::hash::Hash for stat { - fn hash(&self, state: &mut H) { - self.st_dev.hash(state); - self.st_ino.hash(state); - self.st_mode.hash(state); - self.st_nlink.hash(state); - self.st_uid.hash(state); - self.st_gid.hash(state); - self.st_rdev.hash(state); - self.st_size.hash(state); - self.st_atime.hash(state); - self.st_atime_nsec.hash(state); - self.st_mtime.hash(state); - self.st_mtime_nsec.hash(state); - self.st_ctime.hash(state); - self.st_ctime_nsec.hash(state); - self.st_blksize.hash(state); - self.st_blocks.hash(state); - self.st_spare4.hash(state); - } - } - } -} - -s! { - pub struct in_addr { - pub s_addr: ::in_addr_t, - } - - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - pub struct addrinfo { - pub ai_flags: ::c_int, - pub ai_family: ::c_int, - pub ai_socktype: ::c_int, - pub ai_protocol: ::c_int, - pub ai_addrlen: socklen_t, - pub ai_addr: *mut ::sockaddr, - pub ai_canonname: *mut c_char, - pub ai_next: *mut addrinfo, - } - - pub struct Dl_info {} - - pub struct lconv { - pub decimal_point: *mut ::c_char, - pub thousands_sep: *mut ::c_char, - pub grouping: *mut ::c_char, - pub int_curr_symbol: *mut ::c_char, - pub currency_symbol: *mut ::c_char, - pub mon_decimal_point: *mut ::c_char, - pub mon_thousands_sep: *mut ::c_char, - pub mon_grouping: *mut ::c_char, - pub positive_sign: *mut ::c_char, - pub negative_sign: *mut ::c_char, - pub int_frac_digits: ::c_char, - pub frac_digits: ::c_char, - pub p_cs_precedes: ::c_char, - pub p_sep_by_space: ::c_char, - pub n_cs_precedes: ::c_char, - pub n_sep_by_space: ::c_char, - pub p_sign_posn: ::c_char, - pub n_sign_posn: ::c_char, - pub int_p_cs_precedes: ::c_char, - pub int_p_sep_by_space: ::c_char, - pub int_n_cs_precedes: ::c_char, - pub int_n_sep_by_space: ::c_char, - pub int_p_sign_posn: ::c_char, - pub int_n_sign_posn: ::c_char, - } - - pub struct passwd { // Unverified - pub pw_name: *mut ::c_char, - pub pw_passwd: *mut ::c_char, - pub pw_uid: ::uid_t, - pub pw_gid: ::gid_t, - pub pw_gecos: *mut ::c_char, - pub pw_dir: *mut ::c_char, - pub pw_shell: *mut ::c_char, - } - - pub struct pte_handle_t { - pub p: usize, - pub x: ::c_uint, - } - - pub struct sched_param { - pub sched_priority: ::c_int, - } - - pub struct sem_t { - pub value: i32, - pub lock: usize, - pub sem: usize, - } - - pub struct sigaction { - pub sa_flags: ::c_int, - pub sa_mask: sigset_t, - pub sa_handler: usize, - } - - pub struct sockaddr_in6 { - pub sin6_len: u8, - pub sin6_family: sa_family_t, - pub sin6_port: ::in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: ::in6_addr, - pub sin6_scope_id: u32, - } - - pub struct statvfs {} - - pub struct tm { - pub tm_sec: ::c_int, - pub tm_min: ::c_int, - pub tm_hour: ::c_int, - pub tm_mday: ::c_int, - pub tm_mon: ::c_int, - pub tm_year: ::c_int, - pub tm_wday: ::c_int, - pub tm_yday: ::c_int, - pub tm_isdst: ::c_int, - } - - pub struct tms { - pub tms_utime: ::clock_t, - pub tms_stime: ::clock_t, - pub tms_cutime: ::clock_t, - pub tms_cstime: ::clock_t, - } - - pub struct termios {} - - pub struct utsname {} -} - -pub const AF_UNSPEC: ::c_int = 0; -pub const AF_INET: ::c_int = 2; -pub const AF_INET6: ::c_int = 10; - -// Dummy -pub const AF_UNIX: ::c_int = 1; - -pub const CLOCK_REALTIME: ::clockid_t = 1; -pub const CLOCK_MONOTONIC: ::clockid_t = 4; - -// Dummy -pub const EAI_SYSTEM: ::c_int = -11; - -pub const EPERM: ::c_int = 1; -pub const ENOENT: ::c_int = 2; -pub const ESRCH: ::c_int = 3; -pub const EINTR: ::c_int = 4; -pub const EIO: ::c_int = 5; -pub const ENXIO: ::c_int = 6; -pub const E2BIG: ::c_int = 7; -pub const ENOEXEC: ::c_int = 8; -pub const EBADF: ::c_int = 9; -pub const ECHILD: ::c_int = 10; -pub const EAGAIN: ::c_int = 11; -pub const ENOMEM: ::c_int = 12; -pub const EACCES: ::c_int = 13; -pub const EFAULT: ::c_int = 14; -pub const EBUSY: ::c_int = 16; -pub const EEXIST: ::c_int = 17; -pub const EXDEV: ::c_int = 18; -pub const ENODEV: ::c_int = 19; -pub const ENOTDIR: ::c_int = 20; -pub const EISDIR: ::c_int = 21; -pub const EINVAL: ::c_int = 22; -pub const ENFILE: ::c_int = 23; -pub const EMFILE: ::c_int = 24; -pub const ENOTTY: ::c_int = 25; -pub const ETXTBSY: ::c_int = 26; -pub const EFBIG: ::c_int = 27; -pub const ENOSPC: ::c_int = 28; -pub const ESPIPE: ::c_int = 29; -pub const EROFS: ::c_int = 30; -pub const EMLINK: ::c_int = 31; -pub const EPIPE: ::c_int = 32; -pub const EDOM: ::c_int = 33; -pub const ERANGE: ::c_int = 34; -pub const EDEADLK: ::c_int = 35; -pub const ENAMETOOLONG: ::c_int = 36; -pub const ENOLCK: ::c_int = 37; -pub const ENOSYS: ::c_int = 38; -pub const ENOTEMPTY: ::c_int = 39; -pub const ELOOP: ::c_int = 40; -pub const EWOULDBLOCK: ::c_int = EAGAIN; -pub const ENOMSG: ::c_int = 42; -pub const EIDRM: ::c_int = 43; -pub const ECHRNG: ::c_int = 44; -pub const EL2NSYNC: ::c_int = 45; -pub const EL3HLT: ::c_int = 46; -pub const EL3RST: ::c_int = 47; -pub const ELNRNG: ::c_int = 48; -pub const EUNATCH: ::c_int = 49; -pub const ENOCSI: ::c_int = 50; -pub const EL2HLT: ::c_int = 51; -pub const EBADE: ::c_int = 52; -pub const EBADR: ::c_int = 53; -pub const EXFULL: ::c_int = 54; -pub const ENOANO: ::c_int = 55; -pub const EBADRQC: ::c_int = 56; -pub const EBADSLT: ::c_int = 57; -pub const EDEADLOCK: ::c_int = EDEADLK; -pub const EBFONT: ::c_int = 59; -pub const ENOSTR: ::c_int = 60; -pub const ENODATA: ::c_int = 61; -pub const ETIME: ::c_int = 62; -pub const ENOSR: ::c_int = 63; -pub const ENONET: ::c_int = 64; -pub const ENOPKG: ::c_int = 65; -pub const EREMOTE: ::c_int = 66; -pub const ENOLINK: ::c_int = 67; -pub const EADV: ::c_int = 68; -pub const ESRMNT: ::c_int = 69; -pub const ECOMM: ::c_int = 70; -pub const EPROTO: ::c_int = 71; -pub const EMULTIHOP: ::c_int = 72; -pub const EDOTDOT: ::c_int = 73; -pub const EBADMSG: ::c_int = 74; -pub const EOVERFLOW: ::c_int = 75; -pub const ENOTUNIQ: ::c_int = 76; -pub const EBADFD: ::c_int = 77; -pub const EREMCHG: ::c_int = 78; -pub const ELIBACC: ::c_int = 79; -pub const ELIBBAD: ::c_int = 80; -pub const ELIBSCN: ::c_int = 81; -pub const ELIBMAX: ::c_int = 82; -pub const ELIBEXEC: ::c_int = 83; -pub const EILSEQ: ::c_int = 84; -pub const ERESTART: ::c_int = 85; -pub const ESTRPIPE: ::c_int = 86; -pub const EUSERS: ::c_int = 87; -pub const ENOTSOCK: ::c_int = 88; -pub const EDESTADDRREQ: ::c_int = 89; -pub const EMSGSIZE: ::c_int = 90; -pub const EPROTOTYPE: ::c_int = 91; -pub const ENOPROTOOPT: ::c_int = 92; -pub const EPROTONOSUPPORT: ::c_int = 93; -pub const ESOCKTNOSUPPORT: ::c_int = 94; -pub const EOPNOTSUPP: ::c_int = 95; -pub const EPFNOSUPPORT: ::c_int = 96; -pub const EAFNOSUPPORT: ::c_int = 97; -pub const EADDRINUSE: ::c_int = 98; -pub const EADDRNOTAVAIL: ::c_int = 99; -pub const ENETDOWN: ::c_int = 100; -pub const ENETUNREACH: ::c_int = 101; -pub const ENETRESET: ::c_int = 102; -pub const ECONNABORTED: ::c_int = 103; -pub const ECONNRESET: ::c_int = 104; -pub const ENOBUFS: ::c_int = 105; -pub const EISCONN: ::c_int = 106; -pub const ENOTCONN: ::c_int = 107; -pub const ESHUTDOWN: ::c_int = 108; -pub const ETOOMANYREFS: ::c_int = 109; -pub const ETIMEDOUT: ::c_int = 110; -pub const ECONNREFUSED: ::c_int = 111; -pub const EHOSTDOWN: ::c_int = 112; -pub const EHOSTUNREACH: ::c_int = 113; -pub const EALREADY: ::c_int = 114; -pub const EINPROGRESS: ::c_int = 115; -pub const ESTALE: ::c_int = 116; -pub const EUCLEAN: ::c_int = 117; -pub const ENOTNAM: ::c_int = 118; -pub const ENAVAIL: ::c_int = 119; -pub const EISNAM: ::c_int = 120; -pub const EREMOTEIO: ::c_int = 121; -pub const EDQUOT: ::c_int = 122; -pub const ENOMEDIUM: ::c_int = 123; -pub const EMEDIUMTYPE: ::c_int = 124; -pub const ECANCELED: ::c_int = 125; -pub const ENOKEY: ::c_int = 126; -pub const EKEYEXPIRED: ::c_int = 127; -pub const EKEYREVOKED: ::c_int = 128; -pub const EKEYREJECTED: ::c_int = 129; -pub const EOWNERDEAD: ::c_int = 130; -pub const ENOTRECOVERABLE: ::c_int = 131; -pub const ERFKILL: ::c_int = 132; -pub const EHWPOISON: ::c_int = 133; - -pub const EXIT_FAILURE: ::c_int = 1; -pub const EXIT_SUCCESS: ::c_int = 0; - -pub const F_DUPFD: ::c_int = 0; -pub const F_GETFD: ::c_int = 1; -pub const F_SETFD: ::c_int = 2; -pub const F_GETFL: ::c_int = 3; -pub const F_SETFL: ::c_int = 4; -pub const F_GETOWN: ::c_int = 5; -pub const F_SETOWN: ::c_int = 6; -pub const F_GETLK: ::c_int = 7; -pub const F_SETLK: ::c_int = 8; -pub const F_SETLKW: ::c_int = 9; -pub const F_RGETLK: ::c_int = 10; -pub const F_RSETLK: ::c_int = 11; -pub const F_CNVT: ::c_int = 12; -pub const F_RSETLKW: ::c_int = 13; -pub const F_DUPFD_CLOEXEC: ::c_int = 14; - -pub const FD_SETSIZE: usize = 1024; - -// Dummy -pub const FIOCLEX: ::c_int = 0x5451; - -pub const FIONBIO: ::c_int = 0x8004667e; -pub const FIONREAD: ::c_int = 0x4004667f; - -pub const IP_ADD_MEMBERSHIP: ::c_int = 3; -pub const IP_DROP_MEMBERSHIP: ::c_int = 4; - -pub const IP_TOS: ::c_int = 1; -pub const IP_TTL: ::c_int = 2; - -pub const IP_MULTICAST_TTL: ::c_int = 5; -pub const IP_MULTICAST_IF: ::c_int = 6; -pub const IP_MULTICAST_LOOP: ::c_int = 7; - -pub const IPV6_JOIN_GROUP: ::c_int = 12; -pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; -pub const IPV6_LEAVE_GROUP: ::c_int = 13; -pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; -pub const IPV6_V6ONLY: ::c_int = 27; - -// Dummy -pub const IPV6_MULTICAST_LOOP: ::c_int = 7; - -pub const MSG_PEEK: ::c_int = 0x01; -pub const MSG_WAITALL: ::c_int = 0x02; -pub const MSG_OOB: ::c_int = 0x04; -pub const MSG_DONTWAIT: ::c_int = 0x08; -pub const MSG_MORE: ::c_int = 0x10; - -pub const O_ACCMODE: ::c_int = 3; -pub const O_RDONLY: ::c_int = 0; -pub const O_WRONLY: ::c_int = 1; -pub const O_RDWR: ::c_int = 2; -pub const O_APPEND: ::c_int = 1024; -pub const O_CREAT: ::c_int = 64; -pub const O_EXCL: ::c_int = 128; -pub const O_NOCTTY: ::c_int = 256; -pub const O_NONBLOCK: ::c_int = 2048; -pub const O_TRUNC: ::c_int = 512; -pub const O_CLOEXEC: ::c_int = 524288; - -pub const POLLIN: ::c_short = 0x1; -pub const POLLPRI: ::c_short = 0x2; -pub const POLLOUT: ::c_short = 0x4; -pub const POLLERR: ::c_short = 0x8; -pub const POLLHUP: ::c_short = 0x10; -pub const POLLNVAL: ::c_short = 0x20; - -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = usize::max_value(); -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = usize::max_value(); -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = usize::max_value(); - -pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; -pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; -pub const PTHREAD_STACK_MIN: ::size_t = 0; - -// Dummy -pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; - -pub const _SC_ARG_MAX: ::c_int = 0; -pub const _SC_CHILD_MAX: ::c_int = 1; -pub const _SC_CLK_TCK: ::c_int = 2; -pub const _SC_NGROUPS_MAX: ::c_int = 3; -pub const _SC_OPEN_MAX: ::c_int = 4; -pub const _SC_JOB_CONTROL: ::c_int = 5; -pub const _SC_SAVED_IDS: ::c_int = 6; -pub const _SC_VERSION: ::c_int = 7; -pub const _SC_PAGESIZE: ::c_int = 8; -pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; -pub const _SC_NPROCESSORS_CONF: ::c_int = 9; -pub const _SC_NPROCESSORS_ONLN: ::c_int = 10; -pub const _SC_PHYS_PAGES: ::c_int = 11; -pub const _SC_AVPHYS_PAGES: ::c_int = 12; -pub const _SC_MQ_OPEN_MAX: ::c_int = 13; -pub const _SC_MQ_PRIO_MAX: ::c_int = 14; -pub const _SC_RTSIG_MAX: ::c_int = 15; -pub const _SC_SEM_NSEMS_MAX: ::c_int = 16; -pub const _SC_SEM_VALUE_MAX: ::c_int = 17; -pub const _SC_SIGQUEUE_MAX: ::c_int = 18; -pub const _SC_TIMER_MAX: ::c_int = 19; -pub const _SC_TZNAME_MAX: ::c_int = 20; -pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21; -pub const _SC_FSYNC: ::c_int = 22; -pub const _SC_MAPPED_FILES: ::c_int = 23; -pub const _SC_MEMLOCK: ::c_int = 24; -pub const _SC_MEMLOCK_RANGE: ::c_int = 25; -pub const _SC_MEMORY_PROTECTION: ::c_int = 26; -pub const _SC_MESSAGE_PASSING: ::c_int = 27; -pub const _SC_PRIORITIZED_IO: ::c_int = 28; -pub const _SC_REALTIME_SIGNALS: ::c_int = 29; -pub const _SC_SEMAPHORES: ::c_int = 30; -pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 31; -pub const _SC_SYNCHRONIZED_IO: ::c_int = 32; -pub const _SC_TIMERS: ::c_int = 33; -pub const _SC_AIO_LISTIO_MAX: ::c_int = 34; -pub const _SC_AIO_MAX: ::c_int = 35; -pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 36; -pub const _SC_DELAYTIMER_MAX: ::c_int = 37; -pub const _SC_THREAD_KEYS_MAX: ::c_int = 38; -pub const _SC_THREAD_STACK_MIN: ::c_int = 39; -pub const _SC_THREAD_THREADS_MAX: ::c_int = 40; -pub const _SC_TTY_NAME_MAX: ::c_int = 41; -pub const _SC_THREADS: ::c_int = 42; -pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 43; -pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 44; -pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 45; -pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 46; -pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 47; -pub const _SC_THREAD_PRIO_CEILING: ::c_int = _SC_THREAD_PRIO_PROTECT; -pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 48; -pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 49; -pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 50; -pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; -pub const _SC_LOGIN_NAME_MAX: ::c_int = 52; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 53; -pub const _SC_ADVISORY_INFO: ::c_int = 54; -pub const _SC_ATEXIT_MAX: ::c_int = 55; -pub const _SC_BARRIERS: ::c_int = 56; -pub const _SC_BC_BASE_MAX: ::c_int = 57; -pub const _SC_BC_DIM_MAX: ::c_int = 58; -pub const _SC_BC_SCALE_MAX: ::c_int = 59; -pub const _SC_BC_STRING_MAX: ::c_int = 60; -pub const _SC_CLOCK_SELECTION: ::c_int = 61; -pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 62; -pub const _SC_CPUTIME: ::c_int = 63; -pub const _SC_EXPR_NEST_MAX: ::c_int = 64; -pub const _SC_HOST_NAME_MAX: ::c_int = 65; -pub const _SC_IOV_MAX: ::c_int = 66; -pub const _SC_IPV6: ::c_int = 67; -pub const _SC_LINE_MAX: ::c_int = 68; -pub const _SC_MONOTONIC_CLOCK: ::c_int = 69; -pub const _SC_RAW_SOCKETS: ::c_int = 70; -pub const _SC_READER_WRITER_LOCKS: ::c_int = 71; -pub const _SC_REGEXP: ::c_int = 72; -pub const _SC_RE_DUP_MAX: ::c_int = 73; -pub const _SC_SHELL: ::c_int = 74; -pub const _SC_SPAWN: ::c_int = 75; -pub const _SC_SPIN_LOCKS: ::c_int = 76; -pub const _SC_SPORADIC_SERVER: ::c_int = 77; -pub const _SC_SS_REPL_MAX: ::c_int = 78; -pub const _SC_SYMLOOP_MAX: ::c_int = 79; -pub const _SC_THREAD_CPUTIME: ::c_int = 80; -pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 81; -pub const _SC_TIMEOUTS: ::c_int = 82; -pub const _SC_TRACE: ::c_int = 83; -pub const _SC_TRACE_EVENT_FILTER: ::c_int = 84; -pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 85; -pub const _SC_TRACE_INHERIT: ::c_int = 86; -pub const _SC_TRACE_LOG: ::c_int = 87; -pub const _SC_TRACE_NAME_MAX: ::c_int = 88; -pub const _SC_TRACE_SYS_MAX: ::c_int = 89; -pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 90; -pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 91; -pub const _SC_V7_ILP32_OFF32: ::c_int = 92; -pub const _SC_V6_ILP32_OFF32: ::c_int = _SC_V7_ILP32_OFF32; -pub const _SC_XBS5_ILP32_OFF32: ::c_int = _SC_V7_ILP32_OFF32; -pub const _SC_V7_ILP32_OFFBIG: ::c_int = 93; -pub const _SC_V6_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG; -pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = _SC_V7_ILP32_OFFBIG; -pub const _SC_V7_LP64_OFF64: ::c_int = 94; -pub const _SC_V6_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64; -pub const _SC_XBS5_LP64_OFF64: ::c_int = _SC_V7_LP64_OFF64; -pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 95; -pub const _SC_V6_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG; -pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = _SC_V7_LPBIG_OFFBIG; -pub const _SC_XOPEN_CRYPT: ::c_int = 96; -pub const _SC_XOPEN_ENH_I18N: ::c_int = 97; -pub const _SC_XOPEN_LEGACY: ::c_int = 98; -pub const _SC_XOPEN_REALTIME: ::c_int = 99; -pub const _SC_STREAM_MAX: ::c_int = 100; -pub const _SC_PRIORITY_SCHEDULING: ::c_int = 101; -pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 102; -pub const _SC_XOPEN_SHM: ::c_int = 103; -pub const _SC_XOPEN_STREAMS: ::c_int = 104; -pub const _SC_XOPEN_UNIX: ::c_int = 105; -pub const _SC_XOPEN_VERSION: ::c_int = 106; -pub const _SC_2_CHAR_TERM: ::c_int = 107; -pub const _SC_2_C_BIND: ::c_int = 108; -pub const _SC_2_C_DEV: ::c_int = 109; -pub const _SC_2_FORT_DEV: ::c_int = 110; -pub const _SC_2_FORT_RUN: ::c_int = 111; -pub const _SC_2_LOCALEDEF: ::c_int = 112; -pub const _SC_2_PBS: ::c_int = 113; -pub const _SC_2_PBS_ACCOUNTING: ::c_int = 114; -pub const _SC_2_PBS_CHECKPOINT: ::c_int = 115; -pub const _SC_2_PBS_LOCATE: ::c_int = 116; -pub const _SC_2_PBS_MESSAGE: ::c_int = 117; -pub const _SC_2_PBS_TRACK: ::c_int = 118; -pub const _SC_2_SW_DEV: ::c_int = 119; -pub const _SC_2_UPE: ::c_int = 120; -pub const _SC_2_VERSION: ::c_int = 121; -pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 122; -pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 123; -pub const _SC_XOPEN_UUCP: ::c_int = 124; -pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 125; -pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 126; -pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 127; -pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 128; -pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 129; -pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 130; -pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 131; -pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 132; -pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 133; -pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 134; -pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 135; -pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 136; -pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 137; -pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 138; -pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 139; - -pub const S_BLKSIZE: ::mode_t = 1024; -pub const S_IREAD: ::mode_t = 256; -pub const S_IWRITE: ::mode_t = 128; -pub const S_IEXEC: ::mode_t = 64; -pub const S_ENFMT: ::mode_t = 1024; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IROTH: ::mode_t = 4; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IXOTH: ::mode_t = 1; - -pub const SEEK_SET: ::c_int = 0; -pub const SEEK_CUR: ::c_int = 1; -pub const SEEK_END: ::c_int = 2; - -pub const SHUT_RD: ::c_int = 0; -pub const SHUT_WR: ::c_int = 1; -pub const SHUT_RDWR: ::c_int = 2; - -pub const SIG_SETMASK: ::c_int = 0; - -pub const SIGHUP: ::c_int = 1; -pub const SIGINT: ::c_int = 2; -pub const SIGQUIT: ::c_int = 3; -pub const SIGILL: ::c_int = 4; -pub const SIGABRT: ::c_int = 6; -pub const SIGEMT: ::c_int = 7; -pub const SIGFPE: ::c_int = 8; -pub const SIGKILL: ::c_int = 9; -pub const SIGSEGV: ::c_int = 11; -pub const SIGPIPE: ::c_int = 13; -pub const SIGALRM: ::c_int = 14; -pub const SIGTERM: ::c_int = 15; - -pub const SO_DEBUG: ::c_int = 0x0001; -pub const SO_ACCEPTCONN: ::c_int = 0x0002; -pub const SO_REUSEADDR: ::c_int = 0x0004; -pub const SO_KEEPALIVE: ::c_int = 0x0008; -pub const SO_DONTROUTE: ::c_int = 0x0010; -pub const SO_BROADCAST: ::c_int = 0x0020; -pub const SO_USELOOPBACK: ::c_int = 0x0040; -pub const SO_LINGER: ::c_int = 0x0080; -pub const SO_OOBINLINE: ::c_int = 0x0100; -pub const SO_REUSEPORT: ::c_int = 0x0200; -pub const SO_SNDBUF: ::c_int = 0x1001; -pub const SO_RCVBUF: ::c_int = 0x1002; -pub const SO_SNDLOWAT: ::c_int = 0x1003; -pub const SO_RCVLOWAT: ::c_int = 0x1004; -pub const SO_SNDTIMEO: ::c_int = 0x1005; -pub const SO_RCVTIMEO: ::c_int = 0x1006; -pub const SO_ERROR: ::c_int = 0x1007; -pub const SO_TYPE: ::c_int = 0x1008; -pub const SO_CONTIMEO: ::c_int = 0x1009; -pub const SO_NO_CHECK: ::c_int = 0x100a; - -pub const SOCK_STREAM: ::c_int = 1; -pub const SOCK_DGRAM: ::c_int = 2; -pub const SOCK_RAW: ::c_int = 3; - -pub const SOL_SOCKET: ::c_int = 0xfff; - -pub const STDIN_FILENO: ::c_int = 0; -pub const STDOUT_FILENO: ::c_int = 1; -pub const STDERR_FILENO: ::c_int = 2; - -pub const TCP_NODELAY: ::c_int = 0x01; -pub const TCP_KEEPALIVE: ::c_int = 0x02; -pub const TCP_KEEPIDLE: ::c_int = 0x03; -pub const TCP_KEEPINTVL: ::c_int = 0x04; -pub const TCP_KEEPCNT: ::c_int = 0x05; - -const ULONG_SIZE: usize = 64; - -pub const WNOHANG: ::c_int = 0x00000001; - -pub const PRIO_PROCESS: ::c_int = 0; -pub const PRIO_PGRP: ::c_int = 1; -pub const PRIO_USER: ::c_int = 2; - -safe_f! { - pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { - (status >> 8) & 0xff - } - - pub {const} fn WIFEXITED(status: ::c_int) -> bool { - (status & 0xff) == 0 - } - - pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { - status & 0x7f - } -} - -extern "C" { - pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; - pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; - pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; - - pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; - pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int; - - pub fn abs(i: ::c_int) -> ::c_int; - pub fn labs(i: ::c_long) -> ::c_long; - pub fn rand() -> ::c_int; - pub fn srand(seed: ::c_uint); - - pub fn bind(s: ::c_int, name: *const ::sockaddr, namelen: ::socklen_t) -> ::c_int; - - pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - - pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; - pub fn getpwuid_r( - uid: ::uid_t, - pwd: *mut passwd, - buf: *mut ::c_char, - buflen: ::size_t, - result: *mut *mut passwd, - ) -> ::c_int; - - // Dummy - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; - - pub fn memalign(align: ::size_t, nbytes: ::size_t) -> *mut ::c_void; - - pub fn pthread_create( - tid: *mut ::pthread_t, - attr: *const ::pthread_attr_t, - start: extern "C" fn(*mut ::c_void) -> *mut ::c_void, - arg: *mut ::c_void, - ) -> ::c_int; - - pub fn pthread_sigmask(how: ::c_int, set: *const ::sigset_t, oset: *mut ::sigset_t) -> ::c_int; - - pub fn recvfrom( - s: ::c_int, - mem: *mut ::c_void, - len: ::size_t, - flags: ::c_int, - from: *mut ::sockaddr, - fromlen: *mut ::socklen_t, - ) -> ::c_int; - - pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int; - pub fn uname(buf: *mut ::utsname) -> ::c_int; -} - -cfg_if! { - if #[cfg(target_arch = "aarch64")] { - mod aarch64; - pub use self::aarch64::*; - } else if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else { - // Unknown target_arch - } -} diff --git a/src/unix/hermit/x86_64.rs b/src/unix/hermit/x86_64.rs deleted file mode 100644 index 76ec3ce823e8f..0000000000000 --- a/src/unix/hermit/x86_64.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type c_char = i8; -pub type wchar_t = i32; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 9b5ce0fceaafb..9697d20fe558f 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -388,11 +388,6 @@ cfg_if! { #[link(name = "c")] #[link(name = "m")] extern {} - } else if #[cfg(target_os = "hermit")] { - // no_default_libraries is set to false for HermitCore, so only a link - // to "pthread" needs to be added. - #[link(name = "pthread")] - extern {} } else if #[cfg(target_env = "illumos")] { #[link(name = "c")] #[link(name = "m")] @@ -1582,9 +1577,6 @@ cfg_if! { } else if #[cfg(target_os = "haiku")] { mod haiku; pub use self::haiku::*; - } else if #[cfg(target_os = "hermit")] { - mod hermit; - pub use self::hermit::*; } else if #[cfg(target_os = "redox")] { mod redox; pub use self::redox::*; From bc533d0ce3a734de628102eabbefdfd82bc26fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Mon, 11 Sep 2023 15:46:36 +0200 Subject: [PATCH 12/27] Update hermit docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/hermit/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/hermit/mod.rs b/src/hermit/mod.rs index bffcefdd89ce4..7543c825782e2 100644 --- a/src/hermit/mod.rs +++ b/src/hermit/mod.rs @@ -1,7 +1,4 @@ -// libc port for HermitCore (https://hermitcore.org) -// -// Ported by Colin Fink -// and Stefan Lankes +//! Hermit C types definition pub type c_schar = i8; pub type c_uchar = u8; From 54f63b79654c41c6084ca9891f19b5144e16a29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Mon, 11 Sep 2023 15:48:44 +0200 Subject: [PATCH 13/27] Add `riscv64gc-unknown-hermit` to docs and CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- Cargo.toml | 1 + ci/build.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3e5ca175cd078..897ff33b29188 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,7 @@ targets = [ "riscv32imac-unknown-none-elf", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-freebsd", + "riscv64gc-unknown-hermit", "riscv64gc-unknown-linux-gnu", "riscv64gc-unknown-linux-musl", "riscv64gc-unknown-none-elf", diff --git a/ci/build.sh b/ci/build.sh index 81d1f6cc2b725..6ed839c896119 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -253,6 +253,7 @@ riscv32imac-unknown-none-elf \ riscv32imc-unknown-none-elf \ riscv32gc-unknown-linux-gnu \ riscv64gc-unknown-freebsd \ +riscv64gc-unknown-hermit \ riscv64gc-unknown-linux-musl \ riscv64gc-unknown-none-elf \ riscv64imac-unknown-none-elf \ From a778abaf218bfa174bc0ad2f9f3fa14ea3f0a7a1 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Fri, 14 Apr 2023 10:34:13 +0200 Subject: [PATCH 14/27] Update redox pthread and sigset definitions. --- src/unix/redox/mod.rs | 88 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 11 deletions(-) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 5003cda0accfa..900337b4f7e21 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -28,20 +28,13 @@ pub type nfds_t = ::c_ulong; pub type nlink_t = ::c_ulong; pub type off_t = ::c_longlong; pub type pthread_t = *mut ::c_void; -pub type pthread_attr_t = *mut ::c_void; -pub type pthread_cond_t = *mut ::c_void; -pub type pthread_condattr_t = *mut ::c_void; // Must be usize due to libstd/sys_common/thread_local.rs, // should technically be *mut ::c_void pub type pthread_key_t = usize; -pub type pthread_mutex_t = *mut ::c_void; -pub type pthread_mutexattr_t = *mut ::c_void; -pub type pthread_rwlock_t = *mut ::c_void; -pub type pthread_rwlockattr_t = *mut ::c_void; pub type rlim_t = ::c_ulonglong; pub type sa_family_t = u16; pub type sem_t = *mut ::c_void; -pub type sigset_t = ::c_ulong; +pub type sigset_t = ::c_ulonglong; pub type socklen_t = u32; pub type speed_t = u32; pub type suseconds_t = ::c_int; @@ -265,7 +258,74 @@ s! { pub uid: uid_t, pub gid: gid_t, } + + #[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] + pub struct pthread_attr_t { + bytes: [u8; _PTHREAD_ATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_barrier_t { + bytes: [u8; _PTHREAD_BARRIER_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_barrierattr_t { + bytes: [u8; _PTHREAD_BARRIERATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_mutex_t { + bytes: [u8; _PTHREAD_MUTEX_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_rwlock_t { + bytes: [u8; _PTHREAD_RWLOCK_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_mutexattr_t { + bytes: [u8; _PTHREAD_MUTEXATTR_SIZE], + } + #[repr(C)] + #[repr(align(1))] + pub struct pthread_rwlockattr_t { + bytes: [u8; _PTHREAD_RWLOCKATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_cond_t { + bytes: [u8; _PTHREAD_COND_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_condattr_t { + bytes: [u8; _PTHREAD_CONDATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_once_t { + bytes: [u8; _PTHREAD_ONCE_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_spinlock_t { + bytes: [u8; _PTHREAD_SPINLOCK_SIZE], + } } +const _PTHREAD_ATTR_SIZE: usize = 32; +const _PTHREAD_RWLOCKATTR_SIZE: usize = 1; +const _PTHREAD_RWLOCK_SIZE: usize = 4; +const _PTHREAD_BARRIER_SIZE: usize = 24; +const _PTHREAD_BARRIERATTR_SIZE: usize = 4; +const _PTHREAD_CONDATTR_SIZE: usize = 8; +const _PTHREAD_COND_SIZE: usize = 8; +const _PTHREAD_MUTEX_SIZE: usize = 12; +const _PTHREAD_MUTEXATTR_SIZE: usize = 20; +const _PTHREAD_ONCE_SIZE: usize = 4; +const _PTHREAD_SPINLOCK_SIZE: usize = 4; pub const UTSLENGTH: usize = 65; @@ -549,9 +609,15 @@ pub const POLLWRBAND: ::c_short = 0x200; // pthread.h pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; -pub const PTHREAD_MUTEX_INITIALIZER: ::pthread_mutex_t = -1isize as *mut _; -pub const PTHREAD_COND_INITIALIZER: ::pthread_cond_t = -1isize as *mut _; -pub const PTHREAD_RWLOCK_INITIALIZER: ::pthread_rwlock_t = -1isize as *mut _; +pub const PTHREAD_MUTEX_INITIALIZER: ::pthread_mutex_t = ::pthread_mutex_t { + bytes: [0; _PTHREAD_MUTEX_SIZE], +}; +pub const PTHREAD_COND_INITIALIZER: ::pthread_cond_t = ::pthread_cond_t { + bytes: [0; _PTHREAD_COND_SIZE], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: ::pthread_rwlock_t = ::pthread_rwlock_t { + bytes: [0; _PTHREAD_RWLOCK_SIZE], +}; pub const PTHREAD_STACK_MIN: ::size_t = 4096; // signal.h From c89f7474a6a8ee613928f78d5f9c8f58737a8ce7 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 13 Sep 2023 02:47:57 -0700 Subject: [PATCH 15/27] libc 0.2.148 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3e5ca175cd078..c06e0931d52f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.147" +version = "0.2.148" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" From 6491ffdcf3269d01fefd5097b37fbb05b460b961 Mon Sep 17 00:00:00 2001 From: Henry Chen Date: Thu, 3 Aug 2023 14:15:54 +0800 Subject: [PATCH 16/27] update crate version to 0.2.148 --- libc-test/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 5e54c63007e26..87efab5d0542b 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc-test" -version = "0.2.147" +version = "0.2.148" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" build = "build.rs" @@ -12,7 +12,7 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.147" +version = "0.2.148" default-features = false [build-dependencies] From 49c8a1d5cab0795b0b7022ea1e0a907a0df54c5e Mon Sep 17 00:00:00 2001 From: Brijesh Krishna <63464137+Brijeshkrishna@users.noreply.github.com> Date: Sat, 16 Sep 2023 17:31:10 +0530 Subject: [PATCH 17/27] Added SIOCSIFNAME SIOCSIFNAME with 0x8923 is missing,it is use to set interface name. --- src/unix/linux_like/linux/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 4f9ae623a843a..187c73815e599 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2766,6 +2766,7 @@ pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; pub const SIOCSIFMEM: ::c_ulong = 0x00008920; pub const SIOCGIFMTU: ::c_ulong = 0x00008921; pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFNAME: ::c_ulong = 0x00008923; pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; From d9324642217c7126fa9ee59ed3dcecad85bd1b48 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 21 Sep 2023 21:25:12 +0900 Subject: [PATCH 18/27] Disable 1.13 CI --- .github/workflows/bors.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index 677d96b4bfb0b..228663ec42196 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -237,7 +237,9 @@ jobs: stable, beta, nightly, - 1.13.0, + # FIXME: Disabled due to: + # error: failed to parse registry's information for: serde + #1.13.0, 1.19.0, 1.24.0, 1.25.0, @@ -270,7 +272,9 @@ jobs: - { toolchain: beta, os: macos-12 } - { toolchain: nightly, os: macos-12 } # Use macOS 11 for older toolchains as newer Xcode donesn't work well. - - { toolchain: 1.13.0, os: macos-11 } + # FIXME: Disabled due to: + # error: failed to parse registry's information for: serde + #- { toolchain: 1.13.0, os: macos-11 } - { toolchain: 1.19.0, os: macos-11 } - { toolchain: 1.24.0, os: macos-11 } - { toolchain: 1.25.0, os: macos-11 } From bc2bc230158f52de48377b22efaf33ecc8a4667f Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 21 Sep 2023 21:44:11 +0900 Subject: [PATCH 19/27] Disable `x86_64-unknown-linux-gnux32` CI --- .github/workflows/bors.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index 228663ec42196..cc0bb667bdf20 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -156,7 +156,8 @@ jobs: sparc64-unknown-linux-gnu, wasm32-unknown-emscripten, x86_64-linux-android, - x86_64-unknown-linux-gnux32, + # FIXME: Exec format error (os error 8) + #x86_64-unknown-linux-gnux32, x86_64-unknown-linux-musl, # FIXME: It seems some items in `src/unix/mod.rs` # aren't defined on redox actually. From dcc5c92ebca1b8ba78d97f35cf3ad70085058eb6 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Thu, 7 Sep 2023 16:51:38 +0800 Subject: [PATCH 20/27] Add the LoongArch64 HWCAP values Link: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/loongarch/include/uapi/asm/hwcap.h?h=v6.5 --- .../linux_like/linux/gnu/b64/loongarch64/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index ea59181bcd42a..3e1719a76db79 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -264,6 +264,21 @@ align_const! { }; } +pub const HWCAP_CPUCFG: ::c_ulong = 1 << 0; +pub const HWCAP_LAM: ::c_ulong = 1 << 1; +pub const HWCAP_UAL: ::c_ulong = 1 << 2; +pub const HWCAP_FPU: ::c_ulong = 1 << 3; +pub const HWCAP_LSX: ::c_ulong = 1 << 4; +pub const HWCAP_LASX: ::c_ulong = 1 << 5; +pub const HWCAP_CRC32: ::c_ulong = 1 << 6; +pub const HWCAP_COMPLEX: ::c_ulong = 1 << 7; +pub const HWCAP_CRYPTO: ::c_ulong = 1 << 8; +pub const HWCAP_LVZ: ::c_ulong = 1 << 9; +pub const HWCAP_LBT_X86: ::c_ulong = 1 << 10; +pub const HWCAP_LBT_ARM: ::c_ulong = 1 << 11; +pub const HWCAP_LBT_MIPS: ::c_ulong = 1 << 12; +pub const HWCAP_PTW: ::c_ulong = 1 << 13; + pub const SYS_io_setup: ::c_long = 0; pub const SYS_io_destroy: ::c_long = 1; pub const SYS_io_submit: ::c_long = 2; From 06148e171bf33b769c267b48d0fb4ea853a1bacb Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 4 Sep 2023 12:22:09 +1000 Subject: [PATCH 21/27] Add F_PUNCHHOLE and fpunchhole_t Closes #3336. --- src/unix/bsd/apple/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index bf571aeb738ff..e53cf3f197537 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -378,6 +378,13 @@ s! { pub fst_bytesalloc: ::off_t, } + pub struct fpunchhole_t { + pub fp_flags: ::c_uint, /* unused */ + pub reserved: ::c_uint, /* (to maintain 8-byte alignment) */ + pub fp_offset: ::off_t, /* IN: start of the region */ + pub fp_length: ::off_t, /* IN: size of the region */ + } + pub struct radvisory { pub ra_offset: ::off_t, pub ra_count: ::c_int, @@ -3241,6 +3248,7 @@ pub const F_GLOBAL_NOCACHE: ::c_int = 55; pub const F_NODIRECT: ::c_int = 62; pub const F_LOG2PHYS_EXT: ::c_int = 65; pub const F_BARRIERFSYNC: ::c_int = 85; +pub const F_PUNCHHOLE: ::c_int = 99; pub const F_GETPATH_NOFIRMLINK: ::c_int = 102; pub const F_ALLOCATECONTIG: ::c_uint = 0x02; From ca15272e89bef98d51071967e890564e75be9af3 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 4 Sep 2023 12:25:45 +1000 Subject: [PATCH 22/27] Update semver for apple Also I sorted it. --- libc-test/semver/apple.txt | 80 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 10e505ed46dd0..64d0269d45eb9 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -193,10 +193,10 @@ BUFSIZ BUS_ADRALN BUS_ADRERR BUS_OBJERR -CCStatus CCCryptorStatus -CCRandomGenerateBytes CCRNGStatus +CCRandomGenerateBytes +CCStatus CIGNORE CLD_CONTINUED CLD_DUMPED @@ -442,6 +442,7 @@ F_NOCACHE F_NODIRECT F_PEOFPOSMODE F_PREALLOCATE +F_PUNCHHOLE F_RDADVISE F_RDAHEAD F_RDLCK @@ -640,8 +641,8 @@ IPV6_PKTINFO IPV6_RECVPKTINFO IPV6_RECVTCLASS IPV6_TCLASS -IP_HDRINCL IP_BOUND_IF +IP_HDRINCL IP_PKTINFO IP_RECVDSTADDR IP_RECVIF @@ -677,7 +678,6 @@ KERN_FAILURE KERN_FILE KERN_HOSTID KERN_HOSTNAME -KERN_IPC KERN_INSUFFICIENT_BUFFER_SIZE KERN_INVALID_ADDRESS KERN_INVALID_ARGUMENT @@ -685,12 +685,13 @@ KERN_INVALID_HOST KERN_INVALID_LEDGER KERN_INVALID_MEMORY_CONTROL KERN_INVALID_NAME -KERN_INVALID_POLICY KERN_INVALID_OBJECT +KERN_INVALID_POLICY +KERN_INVALID_RIGHT KERN_INVALID_SECURITY KERN_INVALID_TASK -KERN_INVALID_RIGHT KERN_INVALID_VALUE +KERN_IPC KERN_JOB_CONTROL KERN_KDBUFWAIT KERN_KDCPUMAP @@ -714,11 +715,11 @@ KERN_KDSET_TYPEFILTER KERN_KDTHRMAP KERN_KDWRITEMAP KERN_KDWRITETR -KERN_LOGSIGEXIT KERN_LOCK_OWNED KERN_LOCK_OWNED_SELF KERN_LOCK_SET_DESTROYED KERN_LOCK_UNSTABLE +KERN_LOGSIGEXIT KERN_LOW_PRI_DELAY KERN_LOW_PRI_WINDOW KERN_MAXFILES @@ -780,9 +781,9 @@ KERN_SAFEBOOT KERN_SAVED_IDS KERN_SECURELVL KERN_SEMAPHORE_DESTROYED -KERN_SUCCESS KERN_SHREG_PRIVATIZABLE KERN_SPECULATIVE_READS +KERN_SUCCESS KERN_SUGID_COREDUMP KERN_SYMFILE KERN_SYSV @@ -1272,8 +1273,8 @@ SAE_ASSOCID_ANY SAE_CONNID_ALL SAE_CONNID_ANY SCALE_PPM -SCHED_OTHER SCHED_FIFO +SCHED_OTHER SCHED_RR SCM_CREDS SCM_RIGHTS @@ -1369,12 +1370,12 @@ TCP_MAXSEG TCP_NOOPT TCP_NOPUSH THOUSEP -THREAD_BACKGROUND_POLICY -THREAD_BACKGROUND_POLICY_DARWIN_BG -THREAD_BACKGROUND_POLICY_COUNT THREAD_AFFINITY_POLICY THREAD_AFFINITY_POLICY_COUNT THREAD_AFFINITY_TAG_NULL +THREAD_BACKGROUND_POLICY +THREAD_BACKGROUND_POLICY_COUNT +THREAD_BACKGROUND_POLICY_DARWIN_BG THREAD_BASIC_INFO THREAD_BASIC_INFO_COUNT THREAD_EXTENDED_INFO @@ -1671,10 +1672,10 @@ XATTR_SHOWCOMPRESSION XUCRED_VERSION YESEXPR YESSTR -_CS_PATH +_CS_DARWIN_USER_CACHE_DIR _CS_DARWIN_USER_DIR _CS_DARWIN_USER_TEMP_DIR -_CS_DARWIN_USER_CACHE_DIR +_CS_PATH _IOFBF _IOLBF _IONBF @@ -1742,8 +1743,8 @@ _SC_PRIORITY_SCHEDULING _SC_RAW_SOCKETS _SC_READER_WRITER_LOCKS _SC_REALTIME_SIGNALS -_SC_RE_DUP_MAX _SC_REGEXP +_SC_RE_DUP_MAX _SC_RTSIG_MAX _SC_SAVED_IDS _SC_SEMAPHORES @@ -1843,6 +1844,7 @@ backtrace_from_fp backtrace_image_offsets backtrace_symbols backtrace_symbols_fd +basename boolean_t bpf_hdr brk @@ -1870,6 +1872,7 @@ ctime_r ctl_info difftime dirfd +dirname disconnectx dqblk duplocale @@ -1889,6 +1892,7 @@ flistxattr fmemopen fmount forkpty +fpunchhole_t freadlink freeifaddrs freelocale @@ -2004,13 +2008,13 @@ malloc_zone_t malloc_zone_valloc max_align_t mcontext_t -memory_object_t +mem_entry_name_port_t memory_object_offset_t +memory_object_t +memset_pattern16 memset_pattern4 memset_pattern8 -memset_pattern16 memset_s -mem_entry_name_port_t mincore mkdirat mkfifoat @@ -2032,21 +2036,21 @@ openat openpty os_log_create os_log_t -os_log_type_t os_log_type_enabled +os_log_type_t os_signpost_enabled os_signpost_id_generate os_signpost_id_make_with_pointer os_signpost_id_t os_signpost_type_t os_unfair_lock +os_unfair_lock_assert_not_owner +os_unfair_lock_assert_owner +os_unfair_lock_lock os_unfair_lock_s os_unfair_lock_t -os_unfair_lock_lock os_unfair_lock_trylock os_unfair_lock_unlock -os_unfair_lock_assert_owner -os_unfair_lock_assert_not_owner pause policy_t popen @@ -2077,21 +2081,21 @@ posix_spawnp preadv proc_bsdinfo proc_kmsgbuf +proc_libversion proc_listallpids proc_listchildpids proc_listpgrppids proc_listpids -proc_libversion proc_name -proc_pidinfo proc_pidfdinfo proc_pidfileportinfo +proc_pidinfo proc_pidpath proc_regionfilename -proc_set_no_smt -proc_setthread_no_smt proc_set_csm +proc_set_no_smt proc_setthread_csm +proc_setthread_no_smt proc_taskallinfo proc_taskinfo proc_threadinfo @@ -2102,26 +2106,25 @@ pseudo_AF_RTIP pseudo_AF_XTP pthread_attr_getschedparam pthread_attr_setschedparam +pthread_cancel +pthread_condattr_getpshared +pthread_condattr_setpshared pthread_cpu_number_np pthread_create_from_mach_thread +pthread_from_mach_thread_np +pthread_get_stackaddr_np +pthread_get_stacksize_np +pthread_getname_np pthread_getschedparam pthread_introspection_getspecific_np -pthread_introspection_hook_t pthread_introspection_hook_install +pthread_introspection_hook_t pthread_introspection_setspecific_np pthread_jit_write_callback_t pthread_jit_write_freeze_callbacks_np pthread_jit_write_protect_np pthread_jit_write_protect_supported_np pthread_jit_write_with_callback_np -pthread_setschedparam -pthread_cancel -pthread_condattr_getpshared -pthread_condattr_setpshared -pthread_from_mach_thread_np -pthread_get_stackaddr_np -pthread_get_stacksize_np -pthread_getname_np pthread_kill pthread_main_np pthread_mutexattr_getpshared @@ -2129,6 +2132,7 @@ pthread_mutexattr_setpshared pthread_rwlockattr_getpshared pthread_rwlockattr_setpshared pthread_setname_np +pthread_setschedparam pthread_stack_frame_decode_np ptrace pututxline @@ -2236,11 +2240,11 @@ thread_identifier_info_t thread_info thread_info_t thread_inspect_t -thread_policy_set thread_policy_get +thread_policy_set +time_value_t timeval32 timex -time_value_t truncate ttyname_r ucontext_t @@ -2261,5 +2265,3 @@ wait4 waitid xsw_usage xucred -dirname -basename From 2b156c9f757067f9c2eda22fe2e2bdb92b564541 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 30 Aug 2023 09:56:19 -0700 Subject: [PATCH 23/27] Declare `pthread_attr_setguardsize` and `pthread_attr_getstacksize`. Declare `pthread_attr_setguardsize` and `pthread_attr_getstacksize` on all platforms which have `pthread_attr_getguardsize` and `pthread_attr_setstacksize`, respectively. --- libc-test/semver/dragonfly.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/fuchsia.txt | 1 + libc-test/semver/linux.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + libc-test/semver/unix.txt | 1 + src/fuchsia/mod.rs | 5 +++++ src/unix/aix/mod.rs | 1 + src/unix/bsd/freebsdlike/mod.rs | 1 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 + src/unix/bsd/netbsdlike/openbsd/mod.rs | 1 + src/unix/haiku/mod.rs | 1 + src/unix/linux_like/linux/mod.rs | 1 + src/unix/mod.rs | 4 ++++ src/unix/nto/mod.rs | 1 + 16 files changed, 23 insertions(+) diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index e27bfa41831a8..1e1261cad8803 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1437,6 +1437,7 @@ pseudo_AF_XTP pthread_attr_get_np pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_setguardsize pthread_barrierattr_destroy pthread_barrierattr_getpshared pthread_barrierattr_init diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 8dce49824aa94..0adb0dcf736e3 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2010,6 +2010,7 @@ pseudo_AF_XTP pthread_attr_get_np pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_setguardsize pthread_barrierattr_destroy pthread_barrierattr_getpshared pthread_barrierattr_init diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index 5e7213c0bea25..429d59e626ce4 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1294,6 +1294,7 @@ ppoll preadv pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_setguardsize pthread_cancel pthread_condattr_getclock pthread_condattr_setclock diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index e818d2dce675e..b4091a707047d 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3333,6 +3333,7 @@ pread64 preadv pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_setguardsize pthread_cancel pthread_condattr_getclock pthread_condattr_getpshared diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 6150dbb81c41c..21a4cb7adcbb1 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1425,6 +1425,7 @@ pseudo_AF_XTP pthread_attr_get_np pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_setguardsize pthread_cancel pthread_condattr_setclock pthread_getattr_np diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index ea9cda0659ce4..e56760a9e8118 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1146,6 +1146,7 @@ pseudo_AF_RTIP pseudo_AF_XTP pthread_attr_getguardsize pthread_attr_getstack +pthread_attr_setguardsize pthread_cancel pthread_condattr_setclock pthread_get_name_np diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 8928c27feff9f..5e84434b46bf4 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -671,6 +671,7 @@ protoent pselect pthread_attr_destroy pthread_attr_init +pthread_attr_getstacksize pthread_attr_setdetachstate pthread_attr_setstacksize pthread_attr_t diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 3e922e766cba4..772ffda68e10f 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3687,6 +3687,10 @@ extern "C" { pub fn pthread_exit(value: *mut ::c_void) -> !; pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_getstacksize( + attr: *const ::pthread_attr_t, + stacksize: *mut ::size_t, + ) -> ::c_int; pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stack_size: ::size_t) -> ::c_int; pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int; pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; @@ -4161,6 +4165,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 325d7d654fd7e..bc02b108dc412 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2669,6 +2669,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn pthread_attr_getschedparam( attr: *const ::pthread_attr_t, param: *mut sched_param, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index fe69ca42044ca..8eb4a8e7bf480 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1590,6 +1590,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 46035df31188c..3beb8c68dea7a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2727,6 +2727,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 5455bd344b657..38fa29c97e02b 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1827,6 +1827,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 24aa599c07070..d8ecf4985d0d1 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1679,6 +1679,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn pthread_attr_getstack( attr: *const ::pthread_attr_t, stackaddr: *mut *mut ::c_void, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 187c73815e599..067fe07c71f2f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4582,6 +4582,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; pub fn pthread_condattr_getpshared( diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 9697d20fe558f..088e4fd30abb7 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1076,6 +1076,10 @@ extern "C" { pub fn pthread_exit(value: *mut ::c_void) -> !; pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_getstacksize( + attr: *const ::pthread_attr_t, + stacksize: *mut ::size_t, + ) -> ::c_int; pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, stack_size: ::size_t) -> ::c_int; pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, state: ::c_int) -> ::c_int; pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index a79450f4e1fd2..ed6f6df41368e 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -3092,6 +3092,7 @@ extern "C" { attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, ) -> ::c_int; + pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; pub fn pthread_condattr_getpshared( From 756580397d5b03a9bee3a97204a91723ed4689b4 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sat, 23 Sep 2023 16:37:12 -0700 Subject: [PATCH 24/27] Delete a now-redundant `pthread_attr_getstacksize` declaration. --- src/unix/linux_like/android/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 34ff169cc006c..cdac6c32ee3f4 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3498,10 +3498,6 @@ extern "C" { guardsize: *mut ::size_t, ) -> ::c_int; pub fn pthread_attr_setguardsize(attr: *mut ::pthread_attr_t, guardsize: ::size_t) -> ::c_int; - pub fn pthread_attr_getstacksize( - attr: *const ::pthread_attr_t, - stacksize: *mut ::size_t, - ) -> ::c_int; pub fn pthread_attr_getinheritsched( attr: *const ::pthread_attr_t, flag: *mut ::c_int, From b9c8323b171cdba65857c4c4ad79d0047dcf6047 Mon Sep 17 00:00:00 2001 From: Aphek Date: Sun, 25 Jun 2023 19:18:05 -0300 Subject: [PATCH 25/27] Add missing and fix PS Vita definitions Combination of 10 commits: * Add missing PS Vita definitions, fix some unused ones * Fix cfg's target_os * Move conflicting EAI_* definitions back to vita-specific file * Remove out-of-order pub uses * Added padding to dirent and fixed clockid_t * Use repr(align()) instead of zero field * Fixed sockaddr structs * Fixup * socketpair is not available on vita * Lint Co-authored-by: Nikolay Arhipov --- src/unix/mod.rs | 30 ++++++++++------ src/unix/newlib/dirent.rs | 7 ++++ src/unix/newlib/mod.rs | 70 +++++++++++++++++++++++-------------- src/unix/newlib/vita/mod.rs | 35 +++++++++++++++++-- 4 files changed, 102 insertions(+), 40 deletions(-) create mode 100644 src/unix/newlib/dirent.rs diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 088e4fd30abb7..5126940146d6a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -678,17 +678,6 @@ extern "C" { value: *const ::c_void, option_len: socklen_t, ) -> ::c_int; - #[cfg_attr( - all(target_os = "macos", target_arch = "x86"), - link_name = "socketpair$UNIX2003" - )] - #[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")] - pub fn socketpair( - domain: ::c_int, - type_: ::c_int, - protocol: ::c_int, - socket_vector: *mut ::c_int, - ) -> ::c_int; #[cfg(not(all( libc_cfg_target_vendor, target_arch = "powerpc", @@ -1412,6 +1401,25 @@ extern "C" { pub fn lockf(fd: ::c_int, cmd: ::c_int, len: ::off_t) -> ::c_int; } + +cfg_if! { + if #[cfg(not(target_os = "vita"))] { + extern "C" { + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "socketpair$UNIX2003" + )] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_socketpair")] + pub fn socketpair( + domain: ::c_int, + type_: ::c_int, + protocol: ::c_int, + socket_vector: *mut ::c_int, + ) -> ::c_int; + } + } +} + cfg_if! { if #[cfg(not(any(target_os = "emscripten", target_os = "android", diff --git a/src/unix/newlib/dirent.rs b/src/unix/newlib/dirent.rs new file mode 100644 index 0000000000000..664ca066e8947 --- /dev/null +++ b/src/unix/newlib/dirent.rs @@ -0,0 +1,7 @@ +s! { + pub struct dirent { + pub d_ino: ::ino_t, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256usize], + } +} diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ce84f1421f0ea..faa87659b6030 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -1,13 +1,7 @@ pub type blkcnt_t = i32; pub type blksize_t = i32; -cfg_if! { - if #[cfg(target_os = "vita")] { - pub type clockid_t = ::c_uint; - } else { - pub type clockid_t = ::c_ulong; - } -} +pub type clockid_t = ::c_ulong; cfg_if! { if #[cfg(any(target_os = "espidf"))] { @@ -170,16 +164,6 @@ s! { pub sa_flags: ::c_int, } - pub struct dirent { - #[cfg(not(target_os = "vita"))] - pub d_ino: ino_t, - #[cfg(not(target_os = "vita"))] - pub d_type: ::c_uchar, - #[cfg(target_os = "vita")] - __offset: [u8; 88], - pub d_name: [::c_char; 256usize], - } - pub struct stack_t { pub ss_sp: *mut ::c_void, pub ss_flags: ::c_int, @@ -546,8 +530,16 @@ pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast -pub const TCP_NODELAY: ::c_int = 8193; -pub const TCP_MAXSEG: ::c_int = 8194; +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const TCP_NODELAY: ::c_int = 1; + pub const TCP_MAXSEG: ::c_int = 2; + } else { + pub const TCP_NODELAY: ::c_int = 8193; + pub const TCP_MAXSEG: ::c_int = 8194; + } +} + pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; pub const TCP_KEEPIDLE: ::c_int = 256; @@ -561,13 +553,25 @@ cfg_if! { pub const IP_TOS: ::c_int = 3; } } -pub const IP_TTL: ::c_int = 8; +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const IP_TTL: ::c_int = 4; + } else { + pub const IP_TTL: ::c_int = 8; + } +} pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; pub const IP_MULTICAST_LOOP: ::c_int = 11; -pub const IP_ADD_MEMBERSHIP: ::c_int = 11; -pub const IP_DROP_MEMBERSHIP: ::c_int = 12; - +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const IP_ADD_MEMBERSHIP: ::c_int = 12; + pub const IP_DROP_MEMBERSHIP: ::c_int = 13; + } else { + pub const IP_ADD_MEMBERSHIP: ::c_int = 11; + pub const IP_DROP_MEMBERSHIP: ::c_int = 12; + } +} pub const IPV6_UNICAST_HOPS: ::c_int = 4; pub const IPV6_MULTICAST_IF: ::c_int = 9; pub const IPV6_MULTICAST_HOPS: ::c_int = 10; @@ -598,10 +602,15 @@ pub const NI_NAMEREQD: ::c_int = 4; pub const NI_NUMERICSERV: ::c_int = 0; pub const NI_DGRAM: ::c_int = 0; -pub const EAI_FAMILY: ::c_int = -303; -pub const EAI_MEMORY: ::c_int = -304; -pub const EAI_NONAME: ::c_int = -305; -pub const EAI_SOCKTYPE: ::c_int = -307; +cfg_if! { + // Defined in vita/mod.rs for "vita" + if #[cfg(not(target_os = "vita"))] { + pub const EAI_FAMILY: ::c_int = -303; + pub const EAI_MEMORY: ::c_int = -304; + pub const EAI_NONAME: ::c_int = -305; + pub const EAI_SOCKTYPE: ::c_int = -307; + } +} pub const EXIT_SUCCESS: ::c_int = 0; pub const EXIT_FAILURE: ::c_int = 1; @@ -777,6 +786,13 @@ cfg_if! { } } +cfg_if! { + if #[cfg(not(target_os = "vita"))] { + mod dirent; + pub use self::dirent::*; + } +} + cfg_if! { if #[cfg(libc_align)] { #[macro_use] diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 6e2e4d3ebe89f..51d45f67c9989 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -9,6 +9,16 @@ pub type c_ulong = u32; pub type sigset_t = ::c_ulong; s! { + pub struct msghdr { + pub msg_name: *mut ::c_void, + pub msg_namelen: ::socklen_t, + pub msg_iov: *mut ::iovec, + pub msg_iovlen: ::c_int, + pub msg_control: *mut ::c_void, + pub msg_controllen: ::socklen_t, + pub msg_flags: ::c_int, + } + pub struct sockaddr { pub sa_len: u8, pub sa_family: ::sa_family_t, @@ -35,6 +45,7 @@ s! { } pub struct sockaddr_un { + pub ss_len: u8, pub sun_family: ::sa_family_t, pub sun_path: [::c_char; 108usize], } @@ -42,9 +53,9 @@ s! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: ::sa_family_t, - pub __ss_pad1: [u8; 4], + pub __ss_pad1: [u8; 2], pub __ss_align: i64, - pub __ss_pad2: [u8; 4], + pub __ss_pad2: [u8; 116], } pub struct sched_param { @@ -67,16 +78,31 @@ s! { pub st_blocks: ::blkcnt_t, pub st_spare4: [::c_long; 2usize], } + + #[repr(align(8))] + pub struct dirent { + __offset: [u8; 88], + pub d_name: [::c_char; 256usize], + __pad: [u8; 8], + } } pub const AF_UNIX: ::c_int = 1; pub const AF_INET6: ::c_int = 24; +pub const SOCK_RAW: ::c_int = 3; +pub const SOCK_RDM: ::c_int = 4; +pub const SOCK_SEQPACKET: ::c_int = 5; + pub const FIONBIO: ::c_ulong = 1; pub const POLLIN: ::c_short = 0x0001; pub const POLLPRI: ::c_short = POLLIN; pub const POLLOUT: ::c_short = 0x0004; +pub const POLLRDNORM: ::c_short = POLLIN; +pub const POLLRDBAND: ::c_short = POLLIN; +pub const POLLWRNORM: ::c_short = POLLOUT; +pub const POLLWRBAND: ::c_short = POLLOUT; pub const POLLERR: ::c_short = 0x0008; pub const POLLHUP: ::c_short = 0x0010; pub const POLLNVAL: ::c_short = 0x0020; @@ -141,11 +167,16 @@ pub const _SC_PAGESIZE: ::c_int = 8; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; pub const PTHREAD_STACK_MIN: ::size_t = 32 * 1024; +pub const IP_HDRINCL: ::c_int = 2; + extern "C" { pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; + pub fn sendmsg(s: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn recvmsg(s: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; + pub fn pthread_create( native: *mut ::pthread_t, attr: *const ::pthread_attr_t, From 53c6b31638bc10065e9adb698ec622840459e0d3 Mon Sep 17 00:00:00 2001 From: Nikolay Arhipov Date: Sun, 24 Sep 2023 10:20:37 +0300 Subject: [PATCH 26/27] Moved dirent to generic.rs --- src/unix/newlib/aarch64/mod.rs | 2 +- src/unix/newlib/arm/mod.rs | 2 +- src/unix/newlib/dirent.rs | 7 ------- src/unix/newlib/espidf/mod.rs | 2 +- src/unix/newlib/generic.rs | 6 ++++++ src/unix/newlib/horizon/mod.rs | 2 ++ src/unix/newlib/mod.rs | 7 ------- src/unix/newlib/powerpc/mod.rs | 2 +- 8 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 src/unix/newlib/dirent.rs diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index d686b3692d86d..2b4713c9a364e 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -51,4 +51,4 @@ pub const MSG_WAITALL: ::c_int = 0; pub const MSG_MORE: ::c_int = 0; pub const MSG_NOSIGNAL: ::c_int = 0; -pub use crate::unix::newlib::generic::{sigset_t, stat}; +pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index f644349cb997f..23b75977e63ec 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -53,4 +53,4 @@ pub const MSG_WAITALL: ::c_int = 0; pub const MSG_MORE: ::c_int = 0; pub const MSG_NOSIGNAL: ::c_int = 0; -pub use crate::unix::newlib::generic::{sigset_t, stat}; +pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; diff --git a/src/unix/newlib/dirent.rs b/src/unix/newlib/dirent.rs deleted file mode 100644 index 664ca066e8947..0000000000000 --- a/src/unix/newlib/dirent.rs +++ /dev/null @@ -1,7 +0,0 @@ -s! { - pub struct dirent { - pub d_ino: ::ino_t, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256usize], - } -} diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 804cd66454f46..409d7ad9bd784 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -107,4 +107,4 @@ extern "C" { pub fn eventfd(initval: ::c_uint, flags: ::c_int) -> ::c_int; } -pub use crate::unix::newlib::generic::{sigset_t, stat}; +pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs index db7797f17c297..e45413a7a9e2c 100644 --- a/src/unix/newlib/generic.rs +++ b/src/unix/newlib/generic.rs @@ -24,4 +24,10 @@ s! { pub st_blocks: ::blkcnt_t, pub st_spare4: [::c_long; 2usize], } + + pub struct dirent { + pub d_ino: ::ino_t, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256usize], + } } diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index bcb93ad9df4f1..9c70f7b031b63 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -266,3 +266,5 @@ extern "C" { pub fn gethostid() -> ::c_long; } + +pub use crate::unix::newlib::generic::dirent; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index faa87659b6030..a572cc38bfda9 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -786,13 +786,6 @@ cfg_if! { } } -cfg_if! { - if #[cfg(not(target_os = "vita"))] { - mod dirent; - pub use self::dirent::*; - } -} - cfg_if! { if #[cfg(libc_align)] { #[macro_use] diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index 6bed1ce27acbf..10faadbdf8c0a 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -5,7 +5,7 @@ pub type wchar_t = ::c_int; pub type c_long = i32; pub type c_ulong = u32; -pub use crate::unix::newlib::generic::{sigset_t, stat}; +pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; // the newlib shipped with devkitPPC does not support the following components: // - sockaddr From 77448a661501dad378f1c7abe742fb91e88350ac Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 26 Sep 2023 00:14:53 +0900 Subject: [PATCH 27/27] Drop `armv7-apple-ios` target support --- ci/build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 81d1f6cc2b725..2cf28aad4abb6 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -285,7 +285,6 @@ if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then fi RUST_APPLE_NO_CORE_TARGETS="\ -armv7-apple-ios \ armv7s-apple-ios \ i686-apple-darwin \ i386-apple-ios \