From 083499ae1ea8e9a8cc91515ec08f9e5746378a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Fri, 24 May 2024 15:17:34 +0000 Subject: [PATCH 01/45] Add iopl/ioperm to musl x86_64 Note that I think this is available on more than x86_64, but that is all that I have to test. This also matches what was done for glibc systems. --- libc-test/semver/linux-i686.txt | 2 ++ libc-test/semver/linux-x86_64.txt | 2 ++ src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 2 -- src/unix/linux_like/linux/mod.rs | 10 ++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libc-test/semver/linux-i686.txt b/libc-test/semver/linux-i686.txt index aa379e1dcec62..8d1c48b82ce94 100644 --- a/libc-test/semver/linux-i686.txt +++ b/libc-test/semver/linux-i686.txt @@ -215,6 +215,8 @@ fsblkcnt64_t fsfilcnt64_t getcontext greg_t +ioperm +iopl makecontext max_align_t mcontext_t diff --git a/libc-test/semver/linux-x86_64.txt b/libc-test/semver/linux-x86_64.txt index 8ae1037764e84..8142fdf548b20 100644 --- a/libc-test/semver/linux-x86_64.txt +++ b/libc-test/semver/linux-x86_64.txt @@ -140,6 +140,8 @@ TIOCGRS485 TIOCSBRK TIOCSRS485 greg_t +ioperm +iopl max_align_t mcontext_t ucontext_t diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 86536f185750f..88d70d7deb5da 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -802,8 +802,6 @@ extern "C" { pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: ::c_int, ...); pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; - pub fn iopl(level: ::c_int) -> ::c_int; - pub fn ioperm(from: ::c_ulong, num: ::c_ulong, turn_on: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 2ce09ed168df8..71f4bbf04cb35 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1777,6 +1777,16 @@ cfg_if! { } } +cfg_if! { + if #[cfg(all(any(target_env = "gnu", target_env = "musl", target_env = "ohos"), + any(target_arch = "x86_64", target_arch = "x86")))] { + extern "C" { + pub fn iopl(level: ::c_int) -> ::c_int; + pub fn ioperm(from: ::c_ulong, num: ::c_ulong, turn_on: ::c_int) -> ::c_int; + } + } +} + cfg_if! { if #[cfg(any(target_env = "gnu", target_env = "musl", target_env = "ohos"))] { pub const ABDAY_1: ::nl_item = 0x20000; From 2c6ad421956cf282d2c6c22402ee7c8683cba161 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 24 Aug 2024 08:12:27 +0100 Subject: [PATCH 02/45] adding new illumos ptsname_r call. --- libc-test/semver/illumos.txt | 1 + src/unix/solarish/illumos.rs | 2 ++ src/unix/solarish/mod.rs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index d0ef608456d54..02cf4e75d688d 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -1,3 +1,4 @@ pthread_attr_get_np pthread_attr_getstackaddr pthread_attr_setstack +ptsname_r diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index ef3862ee41b34..6e96272352bee 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -100,4 +100,6 @@ extern "C" { pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn getpagesizes2(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; + + pub fn ptsname_r(fildes: ::c_int, name: *mut ::c_char, namelen: ::size_t) -> ::c_int; } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 27f3bf920c116..4d2c6503c5808 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2154,7 +2154,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 4; -pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = ::PTHREAD_MUTEX_NORMAL; pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void; pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; From 133d9d0aa84519dc999c45a2c1fabe3c62b1a37c Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 13 Sep 2024 10:07:43 +0200 Subject: [PATCH 03/45] fix: Update ESP-IDF constants --- src/unix/newlib/espidf/mod.rs | 16 ++-- src/unix/newlib/mod.rs | 134 ++++++++++++++++++++++++++++------ 2 files changed, 120 insertions(+), 30 deletions(-) diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 1a2a907d83191..a73e85315971f 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -89,15 +89,15 @@ pub const MSG_EOR: ::c_int = 0x08; pub const PTHREAD_STACK_MIN: ::size_t = 768; -pub const SIGABRT: ::c_int = 1; -pub const SIGFPE: ::c_int = 1; -pub const SIGILL: ::c_int = 1; -pub const SIGINT: ::c_int = 1; -pub const SIGSEGV: ::c_int = 1; -pub const SIGTERM: ::c_int = 1; +pub const SIGABRT: ::c_int = 6; +pub const SIGFPE: ::c_int = 8; +pub const SIGILL: ::c_int = 4; +pub const SIGINT: ::c_int = 2; +pub const SIGSEGV: ::c_int = 11; +pub const SIGTERM: ::c_int = 15; pub const SIGHUP: ::c_int = 1; -pub const SIGQUIT: ::c_int = 1; -pub const NSIG: ::size_t = 2; +pub const SIGQUIT: ::c_int = 3; +pub const NSIG: ::size_t = 32; extern "C" { pub fn pthread_create( diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 0a241c21baf2d..80748fb333680 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -42,7 +42,13 @@ cfg_if! { pub type socklen_t = u32; pub type speed_t = u32; pub type suseconds_t = i32; -pub type tcflag_t = ::c_uint; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub type tcflag_t = u16; + } else { + pub type tcflag_t = ::c_uint; + } +} pub type useconds_t = u32; cfg_if! { @@ -241,7 +247,14 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], }; -pub const NCCS: usize = 32; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const NCCS: usize = 11; + } else { + pub const NCCS: usize = 32; + } +} cfg_if! { if #[cfg(target_os = "espidf")] { @@ -410,7 +423,13 @@ pub const O_SYNC: ::c_int = 8192; pub const O_NONBLOCK: ::c_int = 16384; pub const O_ACCMODE: ::c_int = 3; -pub const O_CLOEXEC: ::c_int = 0x80000; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const O_CLOEXEC: ::c_int = 0x40000; + } else { + pub const O_CLOEXEC: ::c_int = 0x80000; + } +} pub const RTLD_LAZY: ::c_int = 0x1; @@ -452,7 +471,13 @@ pub const SOL_TCP: ::c_int = 6; pub const PF_UNSPEC: ::c_int = 0; pub const PF_INET: ::c_int = 2; -pub const PF_INET6: ::c_int = 23; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const PF_INET6: ::c_int = 10; + } else { + pub const PF_INET6: ::c_int = 23; + } +} pub const AF_UNSPEC: ::c_int = 0; pub const AF_INET: ::c_int = 2; @@ -537,6 +562,9 @@ cfg_if! { if #[cfg(target_os = "vita")] { pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; + } else if #[cfg(target_os = "espidf")] { + pub const TCP_NODELAY: ::c_int = 1; + pub const TCP_MAXSEG: ::c_int = 8194; } else { pub const TCP_NODELAY: ::c_int = 8193; pub const TCP_MAXSEG: ::c_int = 8194; @@ -545,13 +573,23 @@ cfg_if! { pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; -pub const TCP_KEEPIDLE: ::c_int = 256; -pub const TCP_KEEPINTVL: ::c_int = 512; -pub const TCP_KEEPCNT: ::c_int = 1024; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const TCP_KEEPIDLE: ::c_int = 3; + pub const TCP_KEEPINTVL: ::c_int = 4; + pub const TCP_KEEPCNT: ::c_int = 5; + } else { + pub const TCP_KEEPIDLE: ::c_int = 256; + pub const TCP_KEEPINTVL: ::c_int = 512; + pub const TCP_KEEPCNT: ::c_int = 1024; + } +} cfg_if! { if #[cfg(target_os = "horizon")] { pub const IP_TOS: ::c_int = 7; + } else if #[cfg(target_os = "espidf")] { + pub const IP_TOS: ::c_int = 1; } else { pub const IP_TOS: ::c_int = 3; } @@ -559,55 +597,107 @@ cfg_if! { cfg_if! { if #[cfg(target_os = "vita")] { pub const IP_TTL: ::c_int = 4; + } else if #[cfg(target_os = "espidf")] { + pub const IP_TTL: ::c_int = 2; } 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; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const IP_MULTICAST_IF: ::c_int = 6; + pub const IP_MULTICAST_TTL: ::c_int = 5; + pub const IP_MULTICAST_LOOP: ::c_int = 7; + } else { + pub const IP_MULTICAST_IF: ::c_int = 9; + pub const IP_MULTICAST_TTL: ::c_int = 10; + pub const IP_MULTICAST_LOOP: ::c_int = 11; + } +} + cfg_if! { if #[cfg(target_os = "vita")] { pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; + } else if #[cfg(target_os = "espidf")] { + pub const IP_ADD_MEMBERSHIP: ::c_int = 3; + pub const IP_DROP_MEMBERSHIP: ::c_int = 4; } 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; -pub const IPV6_MULTICAST_LOOP: ::c_int = 11; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const IPV6_MULTICAST_IF: ::c_int = 768; + pub const IPV6_MULTICAST_HOPS: ::c_int = 769; + pub const IPV6_MULTICAST_LOOP: ::c_int = 770; + } else { + pub const IPV6_MULTICAST_IF: ::c_int = 9; + pub const IPV6_MULTICAST_HOPS: ::c_int = 10; + pub const IPV6_MULTICAST_LOOP: ::c_int = 11; + } +} pub const IPV6_V6ONLY: ::c_int = 27; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; -pub const HOST_NOT_FOUND: ::c_int = 1; -pub const NO_DATA: ::c_int = 2; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const HOST_NOT_FOUND: ::c_int = 210; + pub const NO_DATA: ::c_int = 211; + pub const NO_RECOVERY: ::c_int = 212; + pub const TRY_AGAIN: ::c_int = 213; + + } else { + pub const HOST_NOT_FOUND: ::c_int = 1; + pub const NO_DATA: ::c_int = 2; + pub const NO_RECOVERY: ::c_int = 3; + pub const TRY_AGAIN: ::c_int = 4; + } +} pub const NO_ADDRESS: ::c_int = 2; -pub const NO_RECOVERY: ::c_int = 3; -pub const TRY_AGAIN: ::c_int = 4; pub const AI_PASSIVE: ::c_int = 1; pub const AI_CANONNAME: ::c_int = 2; pub const AI_NUMERICHOST: ::c_int = 4; -pub const AI_NUMERICSERV: ::c_int = 0; -pub const AI_ADDRCONFIG: ::c_int = 0; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const AI_NUMERICSERV: ::c_int = 8; + pub const AI_ADDRCONFIG: ::c_int = 64; + } else { + pub const AI_NUMERICSERV: ::c_int = 0; + pub const AI_ADDRCONFIG: ::c_int = 0; + } +} pub const NI_MAXHOST: ::c_int = 1025; pub const NI_MAXSERV: ::c_int = 32; pub const NI_NOFQDN: ::c_int = 1; pub const NI_NUMERICHOST: ::c_int = 2; pub const NI_NAMEREQD: ::c_int = 4; -pub const NI_NUMERICSERV: ::c_int = 0; -pub const NI_DGRAM: ::c_int = 0; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const NI_NUMERICSERV: ::c_int = 8; + pub const NI_DGRAM: ::c_int = 16; + } else { + pub const NI_NUMERICSERV: ::c_int = 0; + pub const NI_DGRAM: ::c_int = 0; + } +} cfg_if! { // Defined in vita/mod.rs for "vita" - if #[cfg(not(target_os = "vita"))] { + if #[cfg(target_os = "espidf")] { + pub const EAI_FAMILY: ::c_int = 204; + pub const EAI_MEMORY: ::c_int = 203; + pub const EAI_NONAME: ::c_int = 200; + pub const EAI_SOCKTYPE: ::c_int = 10; + } else 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; From 6a78b021c099d5ef41760eafcf4f32132aaa46fd Mon Sep 17 00:00:00 2001 From: Jan Sommer Date: Sun, 20 Aug 2023 23:00:31 +0200 Subject: [PATCH 04/45] Add port for RTEMS --- build.rs | 5 +- src/unix/newlib/mod.rs | 17 +++++ src/unix/newlib/rtems/mod.rs | 141 +++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/unix/newlib/rtems/mod.rs diff --git a/build.rs b/build.rs index 01dec47c82f7f..fb0341ef88c11 100644 --- a/build.rs +++ b/build.rs @@ -22,7 +22,10 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ // Extra values to allow for check-cfg. const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ - ("target_os", &["switch", "aix", "ohos", "hurd", "visionos"]), + ( + "target_os", + &["switch", "aix", "ohos", "hurd", "rtems", "visionos"], + ), ("target_env", &["illumos", "wasi", "aix", "ohos"]), ( "target_arch", diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 0a241c21baf2d..3602c957d70dd 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -264,6 +264,16 @@ cfg_if! { pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 4; + } else if #[cfg(target_os = "rtems")] { + const __PTHREAD_INITIALIZER_BYTE: u8 = 0x00; + pub const __SIZEOF_PTHREAD_ATTR_T: usize = 96; + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 64; + pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 24; + pub const __SIZEOF_PTHREAD_COND_T: usize = 28; + pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 24; + pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; + pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; } else { const __PTHREAD_INITIALIZER_BYTE: u8 = 0; pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56; @@ -773,6 +783,13 @@ cfg_if! { } } +cfg_if! { + if #[cfg(target_os = "rtems")] { + mod rtems; + pub use self::rtems::*; + } +} + #[macro_use] mod align; expand_align!(); diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs new file mode 100644 index 0000000000000..36f4820c92f4f --- /dev/null +++ b/src/unix/newlib/rtems/mod.rs @@ -0,0 +1,141 @@ +// defined in architecture specific module +use c_long; + +s! { + pub struct sockaddr_un { + pub sun_family: ::sa_family_t, + pub sun_path: [::c_char; 108usize], + } +} + +pub const AF_UNIX: ::c_int = 1; + +pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; + +pub const UTIME_OMIT: c_long = -1; +pub const AT_FDCWD: ::c_int = -2; + +pub const O_DIRECTORY: ::c_int = 0x200000; +pub const O_NOFOLLOW: ::c_int = 0x100000; + +pub const AT_EACCESS: ::c_int = 1; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 2; +pub const AT_SYMLINK_FOLLOW: ::c_int = 4; +pub const AT_REMOVEDIR: ::c_int = 8; + +// signal.h +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::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 SIGTRAP: ::c_int = 5; +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 SIGBUS: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGSYS: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGURG: ::c_int = 16; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGCONT: ::c_int = 19; +pub const SIGCHLD: ::c_int = 20; +pub const SIGCLD: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGIO: ::c_int = 23; +pub const SIGWINCH: ::c_int = 24; +pub const SIGUSR1: ::c_int = 25; +pub const SIGUSR2: ::c_int = 26; +pub const SIGRTMIN: ::c_int = 27; +pub const SIGRTMAX: ::c_int = 31; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; + +pub const SA_NOCLDSTOP: ::c_ulong = 0x00000001; +pub const SA_SIGINFO: ::c_ulong = 0x00000002; +pub const SA_ONSTACK: ::c_ulong = 0x00000004; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_OVERFLOW: ::c_int = 14; + +pub const _SC_PAGESIZE: ::c_int = 8; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; +pub const PTHREAD_STACK_MIN: ::size_t = 0; + +// sys/wait.h +pub const WNOHANG: ::c_int = 1; +pub const WUNTRACED: ::c_int = 2; + +// sys/socket.h +pub const SOMAXCONN: ::c_int = 128; + +safe_f! { + pub {const} fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub {const} fn WSTOPSIG(status: ::c_int) -> ::c_int { + // (status >> 8) & 0xff + WEXITSTATUS(status) + } + + pub {const} fn WIFSIGNALED(status: ::c_int) -> bool { + ((status & 0x7f) > 0) && ((status & 0x7f) < 0x7f) + } + + pub {const} fn WTERMSIG(status: ::c_int) -> ::c_int { + status & 0x7f + } + + pub {const} fn WIFEXITED(status: ::c_int) -> bool { + (status & 0xff) == 0 + } + + pub {const} fn WEXITSTATUS(status: ::c_int) -> ::c_int { + (status >> 8) & 0xff + } + + // RTEMS doesn't have native WIFCONTINUED. + pub {const} fn WIFCONTINUED(_status: ::c_int) -> bool { + true + } + + // RTEMS doesn't have native WCOREDUMP. + pub {const} fn WCOREDUMP(_status: ::c_int) -> bool { + false + } +} + +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 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_condattr_setclock( + attr: *mut ::pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + + pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int; +} From 6f2b73a294d929120f328edffc076fab919f87b0 Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Fri, 13 Sep 2024 14:25:37 +0200 Subject: [PATCH 05/45] fix: Update ESP-IDF structs --- src/unix/newlib/generic.rs | 3 +++ src/unix/newlib/mod.rs | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs index e45413a7a9e2c..d716dec19f0f8 100644 --- a/src/unix/newlib/generic.rs +++ b/src/unix/newlib/generic.rs @@ -2,7 +2,10 @@ s! { pub struct sigset_t { + #[cfg(target_os = "horizon")] __val: [::c_ulong; 16], + #[cfg(not(target_os = "horizon"))] + __val: u32, } pub struct stat { diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 80748fb333680..b6d8b6ada2737 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -203,6 +203,10 @@ s! { pub c_lflag: ::tcflag_t, pub c_line: ::cc_t, pub c_cc: [::cc_t; ::NCCS], + #[cfg(target_os = "espidf")] + pub c_ispeed: u32, + #[cfg(target_os = "espidf")] + pub c_ospeed: u32, } pub struct sem_t { // Unverified @@ -230,7 +234,24 @@ s! { } pub struct pthread_attr_t { // Unverified - __size: [u8; __SIZEOF_PTHREAD_ATTR_T] + #[cfg(not(target_os = "espidf"))] + __size: [u8; __SIZEOF_PTHREAD_ATTR_T], + #[cfg(target_os = "espidf")] + pub is_initialized: i32, + #[cfg(target_os = "espidf")] + pub stackaddr: *mut crate::c_void, + #[cfg(target_os = "espidf")] + pub stacksize: i32, + #[cfg(target_os = "espidf")] + pub contentionscope: i32, + #[cfg(target_os = "espidf")] + pub inheritsched: i32, + #[cfg(target_os = "espidf")] + pub schedpolicy: i32, + #[cfg(target_os = "espidf")] + pub schedparam: i32, + #[cfg(target_os = "espidf")] + pub detachstate: i32, } pub struct pthread_rwlockattr_t { // Unverified From ea9548ae341631a38b6486b4f6991350400176aa Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 17 Sep 2024 18:04:07 +0200 Subject: [PATCH 06/45] Remove temporary file that was added by accident --- build-tmp.rs | 374 --------------------------------------------------- 1 file changed, 374 deletions(-) delete mode 100644 build-tmp.rs diff --git a/build-tmp.rs b/build-tmp.rs deleted file mode 100644 index 101f45ac262e9..0000000000000 --- a/build-tmp.rs +++ /dev/null @@ -1,374 +0,0 @@ -use std::env; -use std::ffi::{OsStr, OsString}; -use std::process::{Command, Output}; -use std::str; - -// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we -// need to know all the possible cfgs that this script will set. If you need to set another cfg -// make sure to add it to this list as well. -const ALLOWED_CFGS: &'static [&'static str] = &[ - "emscripten_new_stat_abi", - "espidf_time64", - "freebsd10", - "freebsd11", - "freebsd12", - "freebsd13", - "freebsd14", - "freebsd15", - "libc_align", - "libc_cfg_target_vendor", - "libc_const_extern_fn", - "libc_const_extern_fn_unstable", - "libc_const_size_of", - "libc_core_cvoid", - "libc_deny_warnings", - "libc_int128", - "libc_long_array", - "libc_non_exhaustive", - "libc_packedN", - "libc_priv_mod_use", - "libc_ptr_addr_of", - "libc_thread_local", - "libc_underscore_const_names", - "libc_union", - "libc_ctest", -]; - -// Extra values to allow for check-cfg. -const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ - ("target_os", &["switch", "aix", "ohos", "hurd", "visionos"]), - ("target_env", &["illumos", "wasi", "aix", "ohos"]), - ( - "target_arch", - &["loongarch64", "mips32r6", "mips64r6", "csky"], - ), -]; - -fn main() { - // Avoid unnecessary re-building. - println!("cargo:rerun-if-changed=build.rs"); - - let (rustc_minor_ver, is_nightly) = rustc_minor_nightly(); - let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); - let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); - let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); - let libc_ci = env::var("LIBC_CI").is_ok(); - let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; - - if env::var("CARGO_FEATURE_USE_STD").is_ok() { - println!( - "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ - please consider using the `std` cargo feature instead\"" - ); - } - - // The ABI of libc used by std is backward compatible with FreeBSD 12. - // The ABI of libc from crates.io is backward compatible with FreeBSD 11. - // - // On CI, we detect the actual FreeBSD version and match its ABI exactly, - // running tests to ensure that the ABI is correct. - let which_freebsd = if libc_ci { - which_freebsd().unwrap_or(11) - } else if rustc_dep_of_std { - 12 - } else { - 11 - }; - match which_freebsd { - x if x < 10 => panic!("FreeBSD older than 10 is not supported"), - 10 => set_cfg("freebsd10"), - 11 => set_cfg("freebsd11"), - 12 => set_cfg("freebsd12"), - 13 => set_cfg("freebsd13"), - 14 => set_cfg("freebsd14"), - _ => set_cfg("freebsd15"), - } - - match emcc_version_code() { - Some(v) if (v >= 30142) => set_cfg("emscripten_new_stat_abi"), - // Non-Emscripten or version < 3.1.42. - Some(_) | None => (), - } - - // On CI: deny all warnings - if libc_ci { - set_cfg("libc_deny_warnings"); - } - - // Rust >= 1.15 supports private module use: - if rustc_minor_ver >= 15 || rustc_dep_of_std { - set_cfg("libc_priv_mod_use"); - } - - // Rust >= 1.19 supports unions: - if rustc_minor_ver >= 19 || rustc_dep_of_std { - set_cfg("libc_union"); - } - - // Rust >= 1.24 supports const mem::size_of: - if rustc_minor_ver >= 24 || rustc_dep_of_std { - set_cfg("libc_const_size_of"); - } - - // Rust >= 1.25 supports repr(align): - if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature { - set_cfg("libc_align"); - } - - // Rust >= 1.26 supports i128 and u128: - if rustc_minor_ver >= 26 || rustc_dep_of_std { - set_cfg("libc_int128"); - } - - // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it. - // Otherwise, it defines an incompatible type to retaining - // backwards-compatibility. - if rustc_minor_ver >= 30 || rustc_dep_of_std { - set_cfg("libc_core_cvoid"); - } - - // Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor). - if rustc_minor_ver >= 33 || rustc_dep_of_std { - set_cfg("libc_packedN"); - set_cfg("libc_cfg_target_vendor"); - } - - // Rust >= 1.40 supports #[non_exhaustive]. - if rustc_minor_ver >= 40 || rustc_dep_of_std { - set_cfg("libc_non_exhaustive"); - } - - // Rust >= 1.47 supports long array: - if rustc_minor_ver >= 47 || rustc_dep_of_std { - set_cfg("libc_long_array"); - } - - if rustc_minor_ver >= 51 || rustc_dep_of_std { - set_cfg("libc_ptr_addr_of"); - } - - // Rust >= 1.37.0 allows underscores as anonymous constant names. - if rustc_minor_ver >= 37 || rustc_dep_of_std { - set_cfg("libc_underscore_const_names"); - } - - // #[thread_local] is currently unstable - if rustc_dep_of_std { - set_cfg("libc_thread_local"); - } - - // Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C". - if rustc_minor_ver >= 62 { - set_cfg("libc_const_extern_fn"); - } else { - // Rust < 1.62.0 requires a crate feature and feature gate. - if const_extern_fn_cargo_feature { - if !is_nightly || rustc_minor_ver < 40 { - panic!("const-extern-fn requires a nightly compiler >= 1.40"); - } - set_cfg("libc_const_extern_fn_unstable"); - set_cfg("libc_const_extern_fn"); - } - } - - // check-cfg is a nightly cargo/rustc feature to warn when unknown cfgs are used across the - // codebase. libc can configure it if the appropriate environment variable is passed. Since - // rust-lang/rust enforces it, this is useful when using a custom libc fork there. - // - // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg - if libc_check_cfg { - for cfg in ALLOWED_CFGS { - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({})", cfg); - } else { - println!("cargo:rustc-check-cfg=values({})", cfg); - } - } - for &(name, values) in CHECK_CFG_EXTRA { - let values = values.join("\",\""); - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values); - } else { - println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values); - } - } - } -} - -fn rustc_version_cmd(is_clippy_driver: bool) -> Output { - let rustc_wrapper = env::var_os("RUSTC_WRAPPER").filter(|w| !w.is_empty()); - let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env"); - - let mut cmd = if let Some(wrapper) = rustc_wrapper { - let mut cmd = Command::new(wrapper); - cmd.arg(rustc); - if is_clippy_driver { - cmd.arg("--rustc"); - } - - cmd - } else { - Command::new(rustc) - }; - - cmd.arg("--version"); - - let output = cmd.output().expect("Failed to get rustc version"); - - if !output.status.success() { - panic!( - "failed to run rustc: {}", - String::from_utf8_lossy(output.stderr.as_slice()) - ); - } - - output -} - -fn rustc_minor_nightly() -> (u32, bool) { - macro_rules! otry { - ($e:expr) => { - match $e { - Some(e) => e, - None => panic!("Failed to get rustc version"), - } - }; - } - -<<<<<<< HEAD - let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env"); - let mut cmd = match env::var_os("RUSTC_WRAPPER").as_ref() { - Some(wrapper) if !wrapper.is_empty() => { - let mut cmd = Command::new(wrapper); - cmd.arg(rustc); - cmd - } - _ => Command::new(rustc), - }; -||||||| parent of 18b8da967 (Handle rustc version output correctly when `clippy-driver` used) - let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env"); - let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER").filter(|w| !w.is_empty()) { - let mut cmd = Command::new(wrapper); - cmd.arg(rustc); - cmd - } else { - Command::new(rustc) - }; -======= - let mut output = rustc_version_cmd(false); ->>>>>>> 18b8da967 (Handle rustc version output correctly when `clippy-driver` used) - -<<<<<<< HEAD - let output = cmd - .arg("--version") - .output() - .ok() - .expect("Failed to get rustc version"); - if !output.status.success() { - panic!( - "failed to run rustc: {}", - String::from_utf8_lossy(output.stderr.as_slice()) - ); -||||||| parent of 18b8da967 (Handle rustc version output correctly when `clippy-driver` used) - let output = cmd - .arg("--version") - .output() - .expect("Failed to get rustc version"); - if !output.status.success() { - panic!( - "failed to run rustc: {}", - String::from_utf8_lossy(output.stderr.as_slice()) - ); -======= - if otry!(str::from_utf8(&output.stdout).ok()).starts_with("clippy") { - output = rustc_version_cmd(true); ->>>>>>> 18b8da967 (Handle rustc version output correctly when `clippy-driver` used) - } - - let version = otry!(str::from_utf8(&output.stdout).ok()); - - let mut pieces = version.split('.'); - - if pieces.next() != Some("rustc 1") { - panic!("Failed to get rustc version"); - } - - let minor = pieces.next(); - - // If `rustc` was built from a tarball, its version string - // will have neither a git hash nor a commit date - // (e.g. "rustc 1.39.0"). Treat this case as non-nightly, - // since a nightly build should either come from CI - // or a git checkout - let nightly_raw = otry!(pieces.next()).split('-').nth(1); - let nightly = nightly_raw - .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly")) - .unwrap_or(false); - let minor = otry!(otry!(minor).parse().ok()); - - (minor, nightly) -} - -fn which_freebsd() -> Option { - let output = std::process::Command::new("freebsd-version").output().ok(); - if output.is_none() { - return None; - } - let output = output.unwrap(); - if !output.status.success() { - return None; - } - - let stdout = String::from_utf8(output.stdout).ok(); - if stdout.is_none() { - return None; - } - let stdout = stdout.unwrap(); - - match &stdout { - s if s.starts_with("10") => Some(10), - s if s.starts_with("11") => Some(11), - s if s.starts_with("12") => Some(12), - s if s.starts_with("13") => Some(13), - s if s.starts_with("14") => Some(14), - s if s.starts_with("15") => Some(15), - _ => None, - } -} - -fn emcc_version_code() -> Option { - let output = std::process::Command::new("emcc") - .arg("-dumpversion") - .output() - .ok(); - if output.is_none() { - return None; - } - let output = output.unwrap(); - if !output.status.success() { - return None; - } - - let stdout = String::from_utf8(output.stdout).ok(); - if stdout.is_none() { - return None; - } - let version = stdout.unwrap(); - - // Some Emscripten versions come with `-git` attached, so split the - // version string also on the `-` char. - let mut pieces = version.trim().split(|c| c == '.' || c == '-'); - - let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); - let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); - let patch = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); - - Some(major * 10000 + minor * 100 + patch) -} - -fn set_cfg(cfg: &str) { - if !ALLOWED_CFGS.contains(&cfg) { - panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg); - } - println!("cargo:rustc-cfg={}", cfg); -} From 52e81a8c2abf553b3319169ccc8d2e95a0e98e92 Mon Sep 17 00:00:00 2001 From: Rain Date: Fri, 20 Sep 2024 03:05:09 +0000 Subject: [PATCH 07/45] [solarish/freebsd] add a few missing constants and functions Add: * `O_RSYNC` on Solaris and illumos, based on the source code at [1]. This was added a long time ago, and the blame indicates that the constant is shared with Solaris. * `POLLRDHUP` on illumos, based on the source code at [2]. This was also added a long time ago, but is not in the man page (I'll track that down separately, but it has been supported and used for many years). I cannot verify whether this is in Solaris. * `POLLRDHUP` on FreeBSD, based on this man page [3]. This was added in 2021 [4]. * `posix_fadvise` on illumos, based on this man page [5]. The related constants are on GitHub [6]. `posix_fadvise` seems to exist on Solaris [7] but I haven't been able to verify any of the constants so I've left it out of this PR. * `posix_fallocate` on illumos (man page [8]) and Solaris (man page [9]). [1]: https://github.com/illumos/illumos-gate/blame/f389e29fb4a3b48598f4e25151eb570247c6deed/usr/src/uts/common/sys/fcntl.h#L70 [2]: https://github.com/illumos/illumos-gate/blame/f389e29fb4a3b48598f4e25151eb570247c6deed/usr/src/uts/common/sys/poll.h#L66 [3]: https://man.freebsd.org/cgi/man.cgi?poll [4]: https://cgit.freebsd.org/src/commit/sys/sys/poll.h?id=3aaaa2efde896e19d229ee2cf09fe7e6ab0fbf6e [5]: https://illumos.org/man/3C/posix_fadvise [6]: https://github.com/illumos/illumos-gate/blob/f389e29fb4a3b48598f4e25151eb570247c6deed/usr/src/uts/common/sys/fcntl.h#L407-L412 [7]: https://docs.oracle.com/cd/E88353_01/html/E37843/posix-fadvise-3c.html [8]: https://illumos.org/man/3C/posix_fallocate [9]: https://docs.oracle.com/cd/E88353_01/html/E37843/posix-fallocate-3c.html --- libc-test/semver/freebsd.txt | 1 + libc-test/semver/illumos.txt | 10 ++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 1 + src/unix/solarish/illumos.rs | 10 ++++++++++ src/unix/solarish/mod.rs | 2 ++ 5 files changed, 24 insertions(+) diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 933fea0e63e94..0aec7377d7efb 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1027,6 +1027,7 @@ PL_FLAG_SI PM_STR POLLINIGNEOF POLLRDBAND +POLLRDHUP POLLRDNORM POLLSTANDARD POLLWRBAND diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index d0ef608456d54..8a182b791cb45 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -1,3 +1,13 @@ +O_RSYNC +POLLRDHUP +POSIX_FADV_DONTNEED +POSIX_FADV_NOREUSE +POSIX_FADV_NORMAL +POSIX_FADV_RANDOM +POSIX_FADV_SEQUENTIAL +POSIX_FADV_WILLNEED +posix_fadvise +posix_fallocate pthread_attr_get_np pthread_attr_getstackaddr pthread_attr_setstack diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3cf1fc1aeeef3..3fbf981888683 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -2830,6 +2830,7 @@ pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; pub const POLLINIGNEOF: ::c_short = 0x2000; +pub const POLLRDHUP: ::c_short = 0x4000; pub const EVFILT_READ: i16 = -1; pub const EVFILT_WRITE: i16 = -2; diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index ef3862ee41b34..3b7d850b690db 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -28,6 +28,8 @@ pub const EFD_SEMAPHORE: ::c_int = 0x1; pub const EFD_NONBLOCK: ::c_int = 0x800; pub const EFD_CLOEXEC: ::c_int = 0x80000; +pub const POLLRDHUP: ::c_short = 0x4000; + pub const TCP_KEEPIDLE: ::c_int = 34; pub const TCP_KEEPCNT: ::c_int = 35; pub const TCP_KEEPINTVL: ::c_int = 36; @@ -56,6 +58,13 @@ pub const SOL_FILTER: ::c_int = 0xfffc; pub const MADV_PURGE: ::c_int = 9; +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + pub const B1000000: ::speed_t = 24; pub const B1152000: ::speed_t = 25; pub const B1500000: ::speed_t = 26; @@ -96,6 +105,7 @@ extern "C" { stackaddr: *mut ::c_void, ) -> ::c_int; + pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advice: ::c_int) -> ::c_int; pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 27f3bf920c116..8439cfc11aabb 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1293,6 +1293,7 @@ pub const O_RDWR: ::c_int = 2; pub const O_NDELAY: ::c_int = 0x04; pub const O_APPEND: ::c_int = 8; pub const O_DSYNC: ::c_int = 0x40; +pub const O_RSYNC: ::c_int = 0x8000; pub const O_CREAT: ::c_int = 256; pub const O_EXCL: ::c_int = 1024; pub const O_NOCTTY: ::c_int = 2048; @@ -2832,6 +2833,7 @@ extern "C" { #[cfg_attr(target_os = "illumos", link_name = "_globfree_ext")] pub fn globfree(pglob: *mut ::glob_t); + pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void; From 7cab757d7b090db039cdc3782a1ec81333113ccf Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 24 Sep 2024 11:47:48 -0600 Subject: [PATCH 08/45] redox: Make ino_t be c_ulonglong (#3919) --- src/unix/redox/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index bc6e2a8a93d4e..87fb3cc7adb2f 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -22,7 +22,7 @@ pub type clockid_t = ::c_int; pub type dev_t = ::c_long; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; -pub type ino_t = ::c_ulong; +pub type ino_t = ::c_ulonglong; pub type mode_t = ::c_int; pub type nfds_t = ::c_ulong; pub type nlink_t = ::c_ulong; From d5b17d5e6974dd5ef2daa2ed08e9f8cb53cde276 Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:05:47 -0700 Subject: [PATCH 09/45] Add `getpwnam_r`, `getpwuid_r` to emscripten (#3906) --- libc-test/semver/emscripten.txt | 2 ++ src/unix/linux_like/emscripten/mod.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 6b1df1aab4c7f..d14abae402367 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,2 +1,4 @@ getentropy posix_fallocate64 +getpwnam_r +getpwuid_r diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 8014060890963..33d45bce91911 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1774,6 +1774,21 @@ extern "C" { ) -> ::c_int; pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::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; } // Alias to 64 to mimic glibc's LFS64 support From 707d32cddd461854c81af494f2f488b273520586 Mon Sep 17 00:00:00 2001 From: Callum Thomson Date: Tue, 24 Sep 2024 19:10:55 +0100 Subject: [PATCH 10/45] Fix alignment of uc_ucontext fields on arm64 android (#3894) --- src/unix/linux_like/android/b64/aarch64/align.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/linux_like/android/b64/aarch64/align.rs b/src/unix/linux_like/android/b64/aarch64/align.rs index 154c2c54ce6de..6891c14e90fa0 100644 --- a/src/unix/linux_like/android/b64/aarch64/align.rs +++ b/src/unix/linux_like/android/b64/aarch64/align.rs @@ -12,6 +12,7 @@ s! { pub uc_link: *mut ucontext_t, pub uc_stack: ::stack_t, pub uc_sigmask: ::sigset_t, + pub __pad: [u8; 1024 / 8 - core::mem::size_of::<::sigset_t>()], pub uc_mcontext: mcontext_t, } From 433d01944e237d89c786c419bc63fb3368bf9c9a Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 25 Sep 2024 00:53:37 +0100 Subject: [PATCH 11/45] Link windows-sys crate (#3915) WinAPI provides low level libc-like functions but for Windows. One may expect to find it here, so provide the links. `windows-sys` is provided by Microsoft. Official, looks good. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index da5a64f2e1083..9b02a3cdccdd9 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,14 @@ This crate exports all underlying platform types, functions, and constants under the crate root, so all items are accessible as `libc::foo`. The types and values of all the exported APIs match the platform that libc is compiled for. +Windows API bindings are not included in this crate. If you are looking for WinAPI +bindings, consider using crates like [windows-sys]. + More detailed information about the design of this library can be found in its [associated RFC][rfc]. [rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md +[windows-sys]: https://docs.rs/windows-sys ## v1.0 Roadmap From c31dfc1595a06fa28e2da66a262c7a64b5fc1923 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 25 Sep 2024 08:16:29 +0800 Subject: [PATCH 12/45] Initial support for NuttX (#3909) Define the essential types that for NuttX OS. Signed-off-by: Huang Qi --- build.rs | 4 +- src/unix/mod.rs | 10 +- src/unix/nuttx/mod.rs | 555 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 566 insertions(+), 3 deletions(-) create mode 100644 src/unix/nuttx/mod.rs diff --git a/build.rs b/build.rs index fb0341ef88c11..eb602cd37a491 100644 --- a/build.rs +++ b/build.rs @@ -24,7 +24,9 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ ( "target_os", - &["switch", "aix", "ohos", "hurd", "rtems", "visionos"], + &[ + "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", + ], ), ("target_env", &["illumos", "wasi", "aix", "ohos"]), ( diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 1e6daface673a..6c1656b9a41d5 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -326,8 +326,11 @@ extern "C" { } cfg_if! { - if #[cfg(any(target_os = "l4re", target_os = "espidf"))] { - // required libraries for L4Re and the ESP-IDF framework are linked externally, ATM + if #[cfg(any(target_os = "l4re", target_os = "espidf", target_os = "nuttx"))] { + // required libraries are linked externally for these platforms: + // * L4Re + // * ESP-IDF + // * NuttX } else if #[cfg(feature = "std")] { // cargo build, don't pull in anything extra as the std dep // already pulls in all libs. @@ -1610,6 +1613,9 @@ cfg_if! { } else if #[cfg(target_os = "hurd")] { mod hurd; pub use self::hurd::*; + } else if #[cfg(target_os = "nuttx")] { + mod nuttx; + pub use self::nuttx::*; } else { // Unknown target_os } diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs new file mode 100644 index 0000000000000..e3a3c15b338cc --- /dev/null +++ b/src/unix/nuttx/mod.rs @@ -0,0 +1,555 @@ +use c_void; +use in6_addr; +use in_addr_t; +use timespec; +use DIR; + +pub type nlink_t = u16; +pub type ino_t = u16; +pub type blkcnt_t = u64; +pub type blksize_t = i16; +pub type c_char = i8; +pub type c_long = isize; +pub type c_ulong = usize; +pub type cc_t = u8; +pub type clock_t = i64; +pub type dev_t = i32; +pub type fsblkcnt_t = u64; +pub type locale_t = *mut i8; +pub type mode_t = u32; +pub type nfds_t = u32; +pub type off_t = i64; +pub type pthread_key_t = i32; +pub type pthread_mutexattr_t = u8; +pub type pthread_rwlockattr_t = i32; +pub type pthread_t = i32; +pub type rlim_t = i64; +pub type sa_family_t = u16; +pub type socklen_t = u32; +pub type speed_t = usize; +pub type suseconds_t = i32; +pub type tcflag_t = u32; +pub type clockid_t = i32; +pub type time_t = i64; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: u64, + pub st_uid: u32, + pub st_gid: u32, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + pub st_blksize: blksize_t, + pub st_blocks: i64, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + pub struct passwd { + pub pw_name: *const c_char, + pub pw_uid: u32, + pub pw_gid: u32, + pub pw_gecos: *const c_char, + pub pw_dir: *const c_char, + pub pw_shell: *const c_char, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__] + } + + pub struct sem_t { __val: [usize; __SEM_SIZE__] } + + pub struct pthread_attr_t { __val: [usize; __PTHREAD_ATTR_SIZE__] } + + pub struct pthread_mutex_t { __val: [usize; __PTHREAD_MUTEX_SIZE__] } + + pub struct pthread_cond_t { __val: [usize; __PTHREAD_COND_SIZE__] } + + pub struct pthread_condattr_t { __val: [usize; __PTHREAD_CONDATTR_SIZE__] } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct lconv { + pub decimal_point: *const c_char, + pub thousands_sep: *const c_char, + pub grouping: *const c_char, + pub int_curr_symbol: *const c_char, + pub currency_symbol: *const c_char, + pub mon_decimal_point: *const c_char, + pub mon_thousands_sep: *const c_char, + pub mon_grouping: *const c_char, + pub positive_sign: *const c_char, + pub negative_sign: *const c_char, + pub int_frac_digits: i8, + pub frac_digits: i8, + pub p_cs_precedes: i8, + pub p_sep_by_space: i8, + pub n_cs_precedes: i8, + pub n_sep_by_space: i8, + pub p_sign_posn: i8, + pub n_sign_posn: i8, + pub int_n_cs_precedes: i8, + pub int_n_sep_by_space: i8, + pub int_n_sign_posn: i8, + pub int_p_cs_precedes: i8, + pub int_p_sep_by_space: i8, + pub int_p_sign_posn: i8, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct tm { + pub tm_sec: i32, + pub tm_min: i32, + pub tm_hour: i32, + pub tm_mday: i32, + pub tm_mon: i32, + pub tm_year: i32, + pub tm_wday: i32, + pub tm_yday: i32, + pub tm_isdst: i32, + pub tm_gmtoff: isize, + pub tm_zone: *const i8, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct addrinfo { + pub ai_flags: i32, + pub ai_family: i32, + pub ai_socktype: i32, + pub ai_protocol: i32, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct pthread_rwlock_t { + __val: [usize; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct statvfs { + pub f_bsize: usize, + pub f_frsize: usize, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsblkcnt_t, + pub f_ffree: fsblkcnt_t, + pub f_favail: fsblkcnt_t, + pub f_fsid: usize, + pub f_flag: usize, + pub f_namemax: usize, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct dirent { + pub d_type: u8, + pub d_name: [i8; __NAME_MAX__ + 1], + } + + pub struct fd_set { + __val: [u32; __FDSET_SIZE__], + } + + pub struct sigset_t { + __val: [u32; __SIGSET_SIZE__], + } + + pub struct sigaction { + pub sa_handler: usize, + pub sa_mask: sigset_t, + pub sa_flags: i32, + pub sa_user: usize, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct termios { + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_cc: [cc_t; 12], + pub c_speed: speed_t, + __reserved: [usize; __DEFAULT_RESERVED_SIZE__], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + 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 sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + ss_data: [u32; __SOCKADDR_STORAGE_SIZE__], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: u32, + } + + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } +} + +// Reserved two pointer size for reserved area for some structures. +// This ensures that the size of these structures is large enough +// if more fields are added in the NuttX side. +// +// These structures are that defined by POSIX but only necessary fields are included, +// for example, struct passwd, https://pubs.opengroup.org/onlinepubs/009695399/basedefs/pwd.h.html, +// POSIX only defines following fields in struct passwd: +// char *pw_name User's login name. +// uid_t pw_uid Numerical user ID. +// gid_t pw_gid Numerical group ID. +// char *pw_dir Initial working directory. +// char *pw_shell Program to use as shell. +// Other fields can be different depending on the implementation. + +const __DEFAULT_RESERVED_SIZE__: usize = 2; + +const __SOCKADDR_STORAGE_SIZE__: usize = 36; +const __PTHREAD_ATTR_SIZE__: usize = 5; +const __PTHREAD_MUTEX_SIZE__: usize = 9; +const __PTHREAD_COND_SIZE__: usize = 7; +const __PTHREAD_CONDATTR_SIZE__: usize = 5; +const __PTHREAD_RWLOCK_SIZE__: usize = 17; +const __SEM_SIZE__: usize = 6; +const __NAME_MAX__: usize = 64; +const __FDSET_SIZE__: usize = 10; +const __SIGSET_SIZE__: usize = 8; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __val: [0; __PTHREAD_COND_SIZE__], +}; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __val: [0; __PTHREAD_MUTEX_SIZE__], +}; + +// dlfcn.h +pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; + +// stdlib.h +pub const EXIT_SUCCESS: i32 = 0; +pub const EXIT_FAILURE: i32 = 1; + +// time.h +pub const CLOCK_REALTIME: i32 = 0; +pub const CLOCK_MONOTONIC: i32 = 1; + +// errno.h +pub const EPERM: i32 = 1; +pub const ENOENT: i32 = 2; +pub const ESRCH: i32 = 3; +pub const EINTR: i32 = 4; +pub const EIO: i32 = 5; +pub const ENXIO: i32 = 6; +pub const E2BIG: i32 = 7; +pub const ENOEXEC: i32 = 8; +pub const EBADF: i32 = 9; +pub const ECHILD: i32 = 10; +pub const EAGAIN: i32 = 11; +pub const ENOMEM: i32 = 12; +pub const EACCES: i32 = 13; +pub const EFAULT: i32 = 14; +pub const ENOTBLK: i32 = 15; +pub const EBUSY: i32 = 16; +pub const EEXIST: i32 = 17; +pub const EXDEV: i32 = 18; +pub const ENODEV: i32 = 19; +pub const ENOTDIR: i32 = 20; +pub const EISDIR: i32 = 21; +pub const EINVAL: i32 = 22; +pub const ENFILE: i32 = 23; +pub const EMFILE: i32 = 24; +pub const ENOTTY: i32 = 25; +pub const ETXTBSY: i32 = 26; +pub const EFBIG: i32 = 27; +pub const ENOSPC: i32 = 28; +pub const ESPIPE: i32 = 29; +pub const EROFS: i32 = 30; +pub const EMLINK: i32 = 31; +pub const EPIPE: i32 = 32; +pub const EDOM: i32 = 33; +pub const ERANGE: i32 = 34; +pub const EDEADLK: i32 = 35; +pub const ENAMETOOLONG: i32 = 36; +pub const ENOLCK: i32 = 37; +pub const ENOSYS: i32 = 38; +pub const ENOTEMPTY: i32 = 39; +pub const ELOOP: i32 = 40; +pub const EWOULDBLOCK: i32 = EAGAIN; +pub const ENOMSG: i32 = 42; +pub const EIDRM: i32 = 43; +pub const ECHRNG: i32 = 44; +pub const EL2NSYNC: i32 = 45; +pub const EL3HLT: i32 = 46; +pub const EL3RST: i32 = 47; +pub const ELNRNG: i32 = 48; +pub const EUNATCH: i32 = 49; +pub const ENOCSI: i32 = 50; +pub const EL2HLT: i32 = 51; +pub const EBADE: i32 = 52; +pub const EBADR: i32 = 53; +pub const EXFULL: i32 = 54; +pub const ENOANO: i32 = 55; +pub const EBADRQC: i32 = 56; +pub const EBADSLT: i32 = 57; +pub const EDEADLOCK: i32 = EDEADLK; +pub const EBFONT: i32 = 59; +pub const ENOSTR: i32 = 60; +pub const ENODATA: i32 = 61; +pub const ETIME: i32 = 62; +pub const ENOSR: i32 = 63; +pub const ENONET: i32 = 64; +pub const ENOPKG: i32 = 65; +pub const EREMOTE: i32 = 66; +pub const ENOLINK: i32 = 67; +pub const EADV: i32 = 68; +pub const ESRMNT: i32 = 69; +pub const ECOMM: i32 = 70; +pub const EPROTO: i32 = 71; +pub const EMULTIHOP: i32 = 72; +pub const EDOTDOT: i32 = 73; +pub const EBADMSG: i32 = 74; +pub const EOVERFLOW: i32 = 75; +pub const ENOTUNIQ: i32 = 76; +pub const EBADFD: i32 = 77; +pub const EREMCHG: i32 = 78; +pub const ELIBACC: i32 = 79; +pub const ELIBBAD: i32 = 80; +pub const ELIBSCN: i32 = 81; +pub const ELIBMAX: i32 = 82; +pub const ELIBEXEC: i32 = 83; +pub const EILSEQ: i32 = 84; +pub const ERESTART: i32 = 85; +pub const ESTRPIPE: i32 = 86; +pub const EUSERS: i32 = 87; +pub const ENOTSOCK: i32 = 88; +pub const EDESTADDRREQ: i32 = 89; +pub const EMSGSIZE: i32 = 90; +pub const EPROTOTYPE: i32 = 91; +pub const ENOPROTOOPT: i32 = 92; +pub const EPROTONOSUPPORT: i32 = 93; +pub const ESOCKTNOSUPPORT: i32 = 94; +pub const EOPNOTSUPP: i32 = 95; +pub const EPFNOSUPPORT: i32 = 96; +pub const EAFNOSUPPORT: i32 = 97; +pub const EADDRINUSE: i32 = 98; +pub const EADDRNOTAVAIL: i32 = 99; +pub const ENETDOWN: i32 = 100; +pub const ENETUNREACH: i32 = 101; +pub const ENETRESET: i32 = 102; +pub const ECONNABORTED: i32 = 103; +pub const ECONNRESET: i32 = 104; +pub const ENOBUFS: i32 = 105; +pub const EISCONN: i32 = 106; +pub const ENOTCONN: i32 = 107; +pub const ESHUTDOWN: i32 = 108; +pub const ETOOMANYREFS: i32 = 109; +pub const ETIMEDOUT: i32 = 110; +pub const ECONNREFUSED: i32 = 111; +pub const EHOSTDOWN: i32 = 112; +pub const EHOSTUNREACH: i32 = 113; +pub const EALREADY: i32 = 114; +pub const EINPROGRESS: i32 = 115; +pub const ESTALE: i32 = 116; +pub const EUCLEAN: i32 = 117; +pub const ENOTNAM: i32 = 118; +pub const ENAVAIL: i32 = 119; +pub const EISNAM: i32 = 120; +pub const EREMOTEIO: i32 = 121; +pub const EDQUOT: i32 = 122; +pub const ENOMEDIUM: i32 = 123; +pub const EMEDIUMTYPE: i32 = 124; +pub const ECANCELED: i32 = 125; +pub const ENOKEY: i32 = 126; +pub const EKEYEXPIRED: i32 = 127; +pub const EKEYREVOKED: i32 = 128; +pub const EKEYREJECTED: i32 = 129; +pub const EOWNERDEAD: i32 = 130; +pub const ENOTRECOVERABLE: i32 = 131; +pub const ERFKILL: i32 = 132; +pub const EHWPOISON: i32 = 133; +pub const ELBIN: i32 = 134; +pub const EFTYPE: i32 = 135; +pub const ENMFILE: i32 = 136; +pub const EPROCLIM: i32 = 137; +pub const ENOTSUP: i32 = 138; +pub const ENOSHARE: i32 = 139; +pub const ECASECLASH: i32 = 140; + +// fcntl.h +pub const FIOCLEX: i32 = 0x30b; +pub const F_SETFL: i32 = 0x9; +pub const F_DUPFD_CLOEXEC: i32 = 0x12; +pub const F_GETFD: i32 = 0x1; +pub const F_GETFL: i32 = 0x2; +pub const O_RDONLY: i32 = 0x1; +pub const O_WRONLY: i32 = 0x2; +pub const O_RDWR: i32 = 0x3; +pub const O_CREAT: i32 = 0x4; +pub const O_EXCL: i32 = 0x8; +pub const O_NOCTTY: i32 = 0x0; +pub const O_TRUNC: i32 = 0x20; +pub const O_APPEND: i32 = 0x10; +pub const O_NONBLOCK: i32 = 0x40; +pub const O_DSYNC: i32 = 0x80; +pub const O_DIRECT: i32 = 0x200; +pub const O_LARGEFILE: i32 = 0x2000; +pub const O_DIRECTORY: i32 = 0x800; +pub const O_NOFOLLOW: i32 = 0x1000; +pub const O_NOATIME: i32 = 0x40000; +pub const O_CLOEXEC: i32 = 0x400; +pub const O_ACCMODE: i32 = 0x0003; +pub const AT_FDCWD: i32 = -100; +pub const AT_REMOVEDIR: i32 = 0x200; + +// sys/types.h +pub const SEEK_SET: i32 = 0; +pub const SEEK_CUR: i32 = 1; +pub const SEEK_END: i32 = 2; + +// sys/stat.h +pub const S_IFDIR: u32 = 0x4000; +pub const S_IFLNK: u32 = 0xA000; +pub const S_IFREG: u32 = 0x8000; +pub const S_IFMT: u32 = 0xF000; +pub const S_IFIFO: u32 = 0x1000; +pub const S_IFSOCK: u32 = 0xc000; +pub const S_IFBLK: u32 = 0x6000; +pub const S_IFCHR: u32 = 0x2000; +pub const S_IRUSR: u32 = 0x100; +pub const S_IWUSR: u32 = 0x80; +pub const S_IXUSR: u32 = 0x40; +pub const S_IRGRP: u32 = 0x20; +pub const S_IWGRP: u32 = 0x10; +pub const S_IXGRP: u32 = 0x8; +pub const S_IROTH: u32 = 0x004; +pub const S_IWOTH: u32 = 0x002; +pub const S_IXOTH: u32 = 0x001; + +// sys/poll.h +pub const POLLIN: i16 = 0x01; +pub const POLLOUT: i16 = 0x04; +pub const POLLHUP: i16 = 0x10; +pub const POLLERR: i16 = 0x08; +pub const POLLNVAL: i16 = 0x20; + +// sys/socket.h +pub const AF_UNIX: i32 = 1; +pub const SOCK_DGRAM: i32 = 2; +pub const SOCK_STREAM: i32 = 1; +pub const AF_INET: i32 = 2; +pub const AF_INET6: i32 = 10; +pub const MSG_PEEK: i32 = 0x02; +pub const SOL_SOCKET: i32 = 1; +pub const SHUT_WR: i32 = 2; +pub const SHUT_RD: i32 = 1; +pub const SHUT_RDWR: i32 = 3; +pub const SO_ERROR: i32 = 4; +pub const SO_REUSEADDR: i32 = 11; +pub const SOMAXCONN: i32 = 8; +pub const SO_LINGER: i32 = 6; +pub const SO_RCVTIMEO: i32 = 0xa; +pub const SO_SNDTIMEO: i32 = 0xe; +pub const SO_BROADCAST: i32 = 1; + +// netinet/tcp.h +pub const TCP_NODELAY: i32 = 0x10; + +// nuttx/fs/ioctl.h +pub const FIONBIO: i32 = 0x30a; + +// unistd.h +pub const STDIN_FILENO: i32 = 0; +pub const STDOUT_FILENO: i32 = 1; +pub const STDERR_FILENO: i32 = 2; +pub const _SC_PAGESIZE: i32 = 0x36; +pub const _SC_THREAD_STACK_MIN: i32 = 0x58; +pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; + +// signal.h +pub const SIGPIPE: i32 = 13; + +// pthread.h +pub const PTHREAD_MUTEX_NORMAL: i32 = 0; + +// netinet/in.h +pub const IP_TTL: i32 = 0x1e; +pub const IPV6_V6ONLY: i32 = 0x17; +pub const IPV6_JOIN_GROUP: i32 = 0x11; +pub const IPV6_LEAVE_GROUP: i32 = 0x12; +pub const IP_MULTICAST_LOOP: i32 = 0x13; +pub const IPV6_MULTICAST_LOOP: i32 = 0x15; +pub const IP_MULTICAST_TTL: i32 = 0x12; +pub const IP_ADD_MEMBERSHIP: i32 = 0x14; +pub const IP_DROP_MEMBERSHIP: i32 = 0x15; + +extern "C" { + pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; + pub fn ioctl(fd: i32, request: i32, ...) -> i32; + pub fn dirfd(dirp: *mut DIR) -> i32; + pub fn recvfrom( + sockfd: i32, + buf: *mut c_void, + len: usize, + flags: i32, + src_addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> i32; + + pub fn pthread_create( + thread: *mut pthread_t, + attr: *const pthread_attr_t, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, + ) -> i32; + + pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; + pub fn futimens(fd: i32, times: *const timespec) -> i32; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> i32; + pub fn pthread_set_name_np(thread: pthread_t, name: *const c_char) -> i32; + pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; +} From 70de2da72a5ed176628e9d93408d5f7b95230db6 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 20 Sep 2024 11:59:55 +0300 Subject: [PATCH 13/45] Add fnmatch.h Add fnmatch() function and FNM_* constants. Documentation: Header file: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/fnmatch.h.html fnmatch() function: https://pubs.opengroup.org/onlinepubs/9799919799/functions/fnmatch.html Signed-off-by: Manos Pitsidianakis --- libc-test/build.rs | 12 ++++++++++++ libc-test/semver/unix.txt | 6 ++++++ src/unix/mod.rs | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 938294717eee3..0ea0abb7f915f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -191,6 +191,7 @@ fn test_apple(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "fnmatch.h", "getopt.h", "glob.h", "grp.h", @@ -454,6 +455,7 @@ fn test_openbsd(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "fnmatch.h", "getopt.h", "libgen.h", "limits.h", @@ -731,6 +733,7 @@ fn test_redox(target: &str) { "dlfcn.h", "errno.h", "fcntl.h", + "fnmatch.h", "grp.h", "limits.h", "locale.h", @@ -790,6 +793,7 @@ fn test_solarish(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "fnmatch.h", "getopt.h", "glob.h", "grp.h", @@ -1030,6 +1034,7 @@ fn test_netbsd(target: &str) { "elf.h", "errno.h", "fcntl.h", + "fnmatch.h", "getopt.h", "libgen.h", "limits.h", @@ -1244,6 +1249,7 @@ fn test_dragonflybsd(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "fnmatch.h", "getopt.h", "glob.h", "grp.h", @@ -1464,6 +1470,7 @@ fn test_wasi(target: &str) { "dirent.h", "errno.h", "fcntl.h", + "fnmatch.h", "langinfo.h", "limits.h", "locale.h", @@ -1579,6 +1586,7 @@ fn test_android(target: &str) { "elf.h", "errno.h", "fcntl.h", + "fnmatch.h", "getopt.h", "grp.h", "ifaddrs.h", @@ -2087,6 +2095,7 @@ fn test_freebsd(target: &str) { "errno.h", "execinfo.h", "fcntl.h", + "fnmatch.h", "getopt.h", "glob.h", "grp.h", @@ -2706,6 +2715,7 @@ fn test_emscripten(target: &str) { "dlfcn.h", "errno.h", "fcntl.h", + "fnmatch.h", "glob.h", "grp.h", "ifaddrs.h", @@ -2974,6 +2984,7 @@ fn test_neutrino(target: &str) { "dlfcn.h", "sys/elf.h", "fcntl.h", + "fnmatch.h", "glob.h", "grp.h", "iconv.h", @@ -3368,6 +3379,7 @@ fn test_linux(target: &str) { "dlfcn.h", "elf.h", "fcntl.h", + "fnmatch.h", "getopt.h", "glob.h", [gnu]: "gnu/libc-version.h", diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 062d867b8530c..00ef965960db7 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -132,6 +132,11 @@ FD_ZERO FILE FIOCLEX FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD F_DUPFD F_DUPFD_CLOEXEC F_GETFD @@ -526,6 +531,7 @@ fgetpos fgets fileno flock +fnmatch fopen fork fpathconf diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6c1656b9a41d5..2c2fc54dd2912 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -320,6 +320,24 @@ pub const ATF_PERM: ::c_int = 0x04; pub const ATF_PUBL: ::c_int = 0x08; pub const ATF_USETRAILERS: ::c_int = 0x10; +pub const FNM_PERIOD: c_int = 1 << 2; +pub const FNM_CASEFOLD: c_int = 1 << 4; +pub const FNM_NOMATCH: c_int = 1; + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "freebsd", + target_os = "android", + ))] { + pub const FNM_PATHNAME: c_int = 1 << 1; + pub const FNM_NOESCAPE: c_int = 1 << 0; + } else { + pub const FNM_PATHNAME: c_int = 1 << 0; + pub const FNM_NOESCAPE: c_int = 1 << 1; + } +} + extern "C" { pub static in6addr_loopback: in6_addr; pub static in6addr_any: in6_addr; @@ -1573,6 +1591,10 @@ cfg_if! { } } +extern "C" { + pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int; +} + cfg_if! { if #[cfg(target_env = "newlib")] { mod newlib; From b23f5176536c4ed3a1a28dcb377db32692166fae Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Wed, 25 Sep 2024 07:31:46 -0700 Subject: [PATCH 14/45] Add `AT_EACCESS` to emscripten (#3911) https://github.com/emscripten-core/emscripten/blob/3073806d3fde4320c81cb2dc7cf0e00378f52df1/system/lib/libc/musl/include/fcntl.h#L68 --- libc-test/semver/emscripten.txt | 1 + src/unix/linux_like/emscripten/mod.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index d14abae402367..d61541c4f2baf 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,3 +1,4 @@ +AT_EACCESS getentropy posix_fallocate64 getpwnam_r diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 33d45bce91911..4a8bf8dbb6b2d 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -775,6 +775,8 @@ pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const AT_EACCESS: ::c_int = 0x200; + pub const S_IEXEC: mode_t = 0o0100; pub const S_IWRITE: mode_t = 0o0200; pub const S_IREAD: mode_t = 0o0400; From 8ff67c11ae70530c2bcfe50ceaca9f5c1db27163 Mon Sep 17 00:00:00 2001 From: pin Date: Wed, 25 Sep 2024 21:07:36 +0200 Subject: [PATCH 15/45] Add missing definitions on NetBSD (#3927) This PR adds support for: CLOCK_PROCESS_CPUTIME_ID CLOCK_THREAD_CPUTIME_ID sysctlnametomib It replaces the following closed PRs: https://github.com/rust-lang/libc/pull/3926 https://github.com/rust-lang/libc/pull/3923 Sorry for the back and forward actions. --- libc-test/semver/netbsd.txt | 3 +++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 838f28f71b5d1..e07a7dbf08ae6 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -136,6 +136,8 @@ CLD_EXITED CLD_KILLED CLD_STOPPED CLD_TRAPPED +CLOCK_PROCESS_CPUTIME_ID +CLOCK_THREAD_CPUTIME_ID CMSG_DATA CMSG_FIRSTHDR CMSG_LEN @@ -1567,6 +1569,7 @@ sync syscall sysctl sysctlbyname +sysctlnametomib sysctldesc tcp_info telldir diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index f919b73e5c2f4..318557daf52b8 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1873,6 +1873,8 @@ pub const MNT_NOWAIT: ::c_int = 2; pub const MNT_LAZY: ::c_int = 3; // +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 4; pub const NTP_API: ::c_int = 4; pub const MAXPHASE: ::c_long = 500000000; pub const MAXFREQ: ::c_long = 500000; @@ -2646,6 +2648,11 @@ extern "C" { newp: *const ::c_void, newlen: ::size_t, ) -> ::c_int; + pub fn sysctlnametomib( + sname: *const ::c_char, + name: *mut ::c_int, + namelenp: *mut ::size_t, + ) -> ::c_int; #[link_name = "__kevent50"] pub fn kevent( kq: ::c_int, From 09d7aa0d84f9b87d1a8bcb96dc5727282084397d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Thu, 26 Sep 2024 18:22:17 +0200 Subject: [PATCH 16/45] Bump libc-test to Rust 2021 Edition (#3905) --- libc-test/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index df1bd04abd7d9..883dc3d43d8e9 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libc-test" version = "0.2.151" -edition = "2018" +edition = "2021" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" build = "build.rs" From c73a50d9fa69f20b65e3da35fd1f02cbad66db1f Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 29 Sep 2024 13:24:06 -0600 Subject: [PATCH 17/45] Fix CI for FreeBSD 15 (#3950) It was failing for two reasons: * 87fbd9fc7[^1] removed the TCP_MAXPEAKRATE symbol. * 3458bbd39[^2] changed the value of RLIM_NLIMITS Fixes #3947 [^1]: https://github.com/freebsd/freebsd-src/commit/87fbd9fc7fc5f8d79fe5e3dcd13ad02b11a67ef0 [^2]: https://github.com/freebsd/freebsd-src/commit/3458bbd397783f3bb62713c54ae87f19eeb98dc0 --- libc-test/build.rs | 5 ++++- libc-test/semver/freebsd.txt | 1 - src/unix/bsd/freebsdlike/freebsd/mod.rs | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 938294717eee3..743f9f28404db 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2306,6 +2306,10 @@ fn test_freebsd(target: &str) { | "PWAIT" | "PLOCK" | "PPAUSE" | "PRI_MIN_TIMESHARE" | "PUSER" | "PI_AV" | "PI_NET" | "PI_DISK" | "PI_TTY" | "PI_DULL" | "PI_SOFT" => true, + // This constant changed in FreeBSD 15 (git 3458bbd397783). It was never intended to + // be stable, and probably shouldn't be bound by libc at all. + "RLIM_NLIMITS" => true, + // This symbol changed in FreeBSD 14 (git 051e7d78b03), but the new // version should be safe to use on older releases. "IFCAP_CANTCHANGE" => true, @@ -2436,7 +2440,6 @@ fn test_freebsd(target: &str) { // Flags introduced in FreeBSD 14. "TCP_MAXUNACKTIME" - | "TCP_MAXPEAKRATE" | "TCP_IDLE_REDUCE" | "TCP_REMOTE_UDP_ENCAPS_PORT" | "TCP_DELACK" diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 933fea0e63e94..70484bbbb9579 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1494,7 +1494,6 @@ TCP_KEEPIDLE TCP_KEEPINIT TCP_KEEPINTVL TCP_LOG_LIMIT -TCP_MAXPEAKRATE TCP_MAXSEG TCP_MAXUNACKTIME TCP_MD5SIG diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3cf1fc1aeeef3..e7239fd965e07 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3779,7 +3779,6 @@ pub const TCP_INFO: ::c_int = 32; pub const TCP_CONGESTION: ::c_int = 64; pub const TCP_CCALGOOPT: ::c_int = 65; pub const TCP_MAXUNACKTIME: ::c_int = 68; -pub const TCP_MAXPEAKRATE: ::c_int = 69; pub const TCP_IDLE_REDUCE: ::c_int = 70; pub const TCP_REMOTE_UDP_ENCAPS_PORT: ::c_int = 71; pub const TCP_DELACK: ::c_int = 72; From b68a15960f28d36f3d248978a910a9e3faf99682 Mon Sep 17 00:00:00 2001 From: Rain Date: Sat, 28 Sep 2024 18:48:08 -0700 Subject: [PATCH 18/45] [musl] add posix_spawn chdir functions Add `posix_spawn_file_actions_add[f]chdir_np`, as present in musl 1.1.24 and above ([reference]). [reference]: https://git.musl-libc.org/cgit/musl/commit/?id=74244e5b3ed4a61d99c5fc0967b69e5c9a753456 --- libc-test/semver/linux-musl.txt | 2 ++ src/unix/linux_like/linux/musl/mod.rs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index c8b5ddbd75c28..1b6efeccfa5b1 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -80,6 +80,8 @@ getutxline lio_listio ntptimeval open_wmemstream +posix_spawn_file_actions_addchdir_np +posix_spawn_file_actions_addfchdir_np preadv2 preadv64 prlimit diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index a37da7d24c314..6bc9cc60d273d 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -968,6 +968,17 @@ extern "C" { pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; + // Added in `musl` 1.1.24 + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut ::posix_spawn_file_actions_t, + path: *const ::c_char, + ) -> ::c_int; + // Added in `musl` 1.1.24 + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut ::posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn getutxent() -> *mut utmpx; pub fn getutxid(ut: *const utmpx) -> *mut utmpx; pub fn getutxline(ut: *const utmpx) -> *mut utmpx; From 0a25ed85c91df598b1f730fadc75ddac0dcdee7e Mon Sep 17 00:00:00 2001 From: Paul Mabileau <35344098+PaulDance@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:17:53 +0200 Subject: [PATCH 19/45] Feat(Apple): Add the LOCAL_PEERTOKEN socket option (#3929) * Feat(apple): Add LOCAL_PEERTOKEN Taken from `sys/un.h`. Signed-off-by: Paul Mabileau * Docs(apple): Add description for LOCAL_PEER* socket options Signed-off-by: Paul Mabileau * Chore(test/apple): Add the LOCAL_PEERTOKEN symbol Signed-off-by: Paul Mabileau --------- Signed-off-by: Paul Mabileau --- libc-test/semver/apple.txt | 1 + src/unix/bsd/apple/mod.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 832182dd117b3..f022a006de401 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -849,6 +849,7 @@ LOCAL_PEEREPID LOCAL_PEEREUUID LOCAL_PEERPID LOCAL_PEERUUID +LOCAL_PEERTOKEN LOGIN_PROCESS LOG_AUTHPRIV LOG_CRON diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 9a5dc357fd038..d991e379ba79a 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4154,11 +4154,18 @@ pub const TCP_CONNECTION_INFO: ::c_int = 0x106; pub const SOL_LOCAL: ::c_int = 0; +/// Retrieve peer credentials. pub const LOCAL_PEERCRED: ::c_int = 0x001; +/// Retrieve peer PID. pub const LOCAL_PEERPID: ::c_int = 0x002; +/// Retrieve effective peer PID. pub const LOCAL_PEEREPID: ::c_int = 0x003; +/// Retrieve peer UUID. pub const LOCAL_PEERUUID: ::c_int = 0x004; +/// Retrieve effective peer UUID. pub const LOCAL_PEEREUUID: ::c_int = 0x005; +/// Retrieve peer audit token. +pub const LOCAL_PEERTOKEN: ::c_int = 0x006; pub const SOL_SOCKET: ::c_int = 0xffff; From 2191c87696b414a87a3e53428f176358179c7918 Mon Sep 17 00:00:00 2001 From: Yoh Deadfall Date: Mon, 30 Sep 2024 20:06:35 +0300 Subject: [PATCH 20/45] Android: Added PR_GET_NAME and PR_SET_NAME (#3941) --- libc-test/semver/android.txt | 2 ++ src/unix/linux_like/android/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index df205a82497c1..02a1f4b800db0 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1928,9 +1928,11 @@ POSIX_FADV_NORMAL POSIX_FADV_RANDOM POSIX_FADV_SEQUENTIAL POSIX_FADV_WILLNEED +PR_GET_NAME PR_GET_NO_NEW_PRIVS PR_GET_SECCOMP PR_GET_TIMING +PR_SET_NAME PR_SET_NO_NEW_PRIVS PR_SET_SECCOMP PR_TIMING_STATISTICAL diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 3e1b83e5adb73..61f91a183c4f7 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3157,6 +3157,8 @@ pub const PR_GET_TIMING: ::c_int = 13; pub const PR_SET_TIMING: ::c_int = 14; pub const PR_TIMING_STATISTICAL: ::c_int = 0; pub const PR_TIMING_TIMESTAMP: ::c_int = 1; +pub const PR_SET_NAME: ::c_int = 15; +pub const PR_GET_NAME: ::c_int = 16; // linux/if_addr.h pub const IFA_UNSPEC: ::c_ushort = 0; From 4ce03dad4387f27d15ab9f7da81a93ac7f82d9ce Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Tue, 1 Oct 2024 10:35:54 +0800 Subject: [PATCH 21/45] feat: move NT_XXX constants defined in elf.h to linux/mod.rs (#3938) --- libc-test/semver/linux-gnu.txt | 17 ----------------- libc-test/semver/linux.txt | 17 +++++++++++++++++ src/unix/linux_like/linux/gnu/mod.rs | 19 ------------------- src/unix/linux_like/linux/mod.rs | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 5b079941bb970..89253b6482090 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -337,23 +337,6 @@ NFT_USERDATA_MAXLEN NF_NETDEV_INGRESS NF_NETDEV_NUMHOOKS NILFS_SUPER_MAGIC -NT_PRSTATUS -NT_PRFPREG -NT_FPREGSET -NT_PRPSINFO -NT_PRXREG -NT_TASKSTRUCT -NT_PLATFORM -NT_AUXV -NT_GWINDOWS -NT_ASRS -NT_PSTATUS -NT_PSINFO -NT_PRCRED -NT_UTSNAME -NT_LWPSTATUS -NT_LWPSINFO -NT_PRFPXREG NTF_EXT_LEARNED NTF_MASTER NTF_OFFLOADED diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 402241df1d033..215f6bddf0ce0 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -4008,3 +4008,20 @@ eventfd_write __c_anonymous_ifru_map __c_anonymous_ifr_ifru __c_anonymous_ifc_ifcu +NT_PRSTATUS +NT_PRFPREG +NT_FPREGSET +NT_PRPSINFO +NT_PRXREG +NT_TASKSTRUCT +NT_PLATFORM +NT_AUXV +NT_GWINDOWS +NT_ASRS +NT_PSTATUS +NT_PSINFO +NT_PRCRED +NT_UTSNAME +NT_LWPSTATUS +NT_LWPSINFO +NT_PRFPXREG diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 5a350b7a57d84..a22e5484abcd2 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1094,25 +1094,6 @@ pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_O pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; -// elf.h -pub const NT_PRSTATUS: ::c_int = 1; -pub const NT_PRFPREG: ::c_int = 2; -pub const NT_FPREGSET: ::c_int = 2; -pub const NT_PRPSINFO: ::c_int = 3; -pub const NT_PRXREG: ::c_int = 4; -pub const NT_TASKSTRUCT: ::c_int = 4; -pub const NT_PLATFORM: ::c_int = 5; -pub const NT_AUXV: ::c_int = 6; -pub const NT_GWINDOWS: ::c_int = 7; -pub const NT_ASRS: ::c_int = 8; -pub const NT_PSTATUS: ::c_int = 10; -pub const NT_PSINFO: ::c_int = 13; -pub const NT_PRCRED: ::c_int = 14; -pub const NT_UTSNAME: ::c_int = 15; -pub const NT_LWPSTATUS: ::c_int = 16; -pub const NT_LWPSINFO: ::c_int = 17; -pub const NT_PRFPXREG: ::c_int = 20; - pub const ELFOSABI_ARM_AEABI: u8 = 64; // linux/sched.h diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 616e2e7c7d466..366c775d0ef8b 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5133,6 +5133,25 @@ pub const SCHED_FLAG_KEEP_PARAMS: ::c_int = 0x10; pub const SCHED_FLAG_UTIL_CLAMP_MIN: ::c_int = 0x20; pub const SCHED_FLAG_UTIL_CLAMP_MAX: ::c_int = 0x40; +// elf.h +pub const NT_PRSTATUS: ::c_int = 1; +pub const NT_PRFPREG: ::c_int = 2; +pub const NT_FPREGSET: ::c_int = 2; +pub const NT_PRPSINFO: ::c_int = 3; +pub const NT_PRXREG: ::c_int = 4; +pub const NT_TASKSTRUCT: ::c_int = 4; +pub const NT_PLATFORM: ::c_int = 5; +pub const NT_AUXV: ::c_int = 6; +pub const NT_GWINDOWS: ::c_int = 7; +pub const NT_ASRS: ::c_int = 8; +pub const NT_PSTATUS: ::c_int = 10; +pub const NT_PSINFO: ::c_int = 13; +pub const NT_PRCRED: ::c_int = 14; +pub const NT_UTSNAME: ::c_int = 15; +pub const NT_LWPSTATUS: ::c_int = 16; +pub const NT_LWPSINFO: ::c_int = 17; +pub const NT_PRFPXREG: ::c_int = 20; + pub const SCHED_FLAG_KEEP_ALL: ::c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS; pub const SCHED_FLAG_UTIL_CLAMP: ::c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX; From 2053d5b1d82d8cef862c5630d5968381c89e7fe4 Mon Sep 17 00:00:00 2001 From: Nathaniel Bennett Date: Mon, 30 Sep 2024 22:38:35 -0400 Subject: [PATCH 22/45] FreeBSD: Add ucontext_t, mcontext_t for all archs (#3848) --- libc-test/semver/freebsd-x86_64.txt | 2 - libc-test/semver/freebsd.txt | 4 +- src/unix/bsd/freebsdlike/freebsd/arm.rs | 43 +++++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 21 +++++++ src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 62 +++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 62 +++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/x86.rs | 9 --- .../bsd/freebsdlike/freebsd/x86_64/align.rs | 11 ---- 8 files changed, 191 insertions(+), 23 deletions(-) diff --git a/libc-test/semver/freebsd-x86_64.txt b/libc-test/semver/freebsd-x86_64.txt index be73d1f7290fe..14ddc25a1b254 100644 --- a/libc-test/semver/freebsd-x86_64.txt +++ b/libc-test/semver/freebsd-x86_64.txt @@ -13,8 +13,6 @@ _MC_HASSEGS fpreg fpreg32 max_align_t -mcontext_t reg reg32 -ucontext_t xmmreg diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 70484bbbb9579..cb36429fb36ab 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2003,6 +2003,7 @@ mallctl mallctlbymib mallctlnametomib mallocx +mcontext_t memmem memrchr memset_s @@ -2333,13 +2334,14 @@ timer_t timex truncate ttyname_r -uuidgen +ucontext_t unmount useconds_t uselocale utimensat utmpx utrace +uuidgen vm_size_t vmtotal wait4 diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index af3c8a7cf6f6c..eb90f3f9030e7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -5,6 +5,8 @@ pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; +pub type __greg_t = ::c_uint; +pub type __gregset_t = [::__greg_t; 17]; s! { pub struct stat { @@ -36,6 +38,47 @@ s! { } } +s_no_extra_traits! { + pub struct mcontext_t { + pub __gregs: ::__gregset_t, + pub mc_vfp_size: ::__size_t, + pub mc_vfp_ptr: *mut ::c_void, + pub mc_spare: [::c_uint; 33], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.__gregs == other.__gregs && + self.mc_vfp_size == other.mc_vfp_size && + self.mc_vfp_ptr == other.mc_vfp_ptr && + self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b) + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("__gregs", &self.__gregs) + .field("mc_vfp_size", &self.mc_vfp_size) + .field("mc_vfp_ptr", &self.mc_vfp_ptr) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.__gregs.hash(state); + self.mc_vfp_size.hash(state); + self.mc_vfp_ptr.hash(state); + self.mc_spare.hash(state); + } + } + } +} + pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index e7239fd965e07..fc01d8e5463b8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1638,6 +1638,15 @@ s_no_extra_traits! { _kf_cap_spare: u64, pub kf_path: [::c_char; ::PATH_MAX as usize], } + + pub struct ucontext_t { + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: ::mcontext_t, + pub uc_link: *mut ::ucontext_t, + pub uc_stack: ::stack_t, + pub uc_flags: ::c_int, + __spare__: [::c_int; 4], + } } cfg_if! { @@ -2592,6 +2601,18 @@ cfg_if! { self.kf_path.hash(state); } } + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_sigmask", &self.uc_sigmask) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_flags", &self.uc_flags) + .finish() + } + } } } diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 0900005166a2e..5de61946de3b9 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -32,6 +32,68 @@ s! { } } +s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_vers == other.mc_vers && + self.mc_flags == other.mc_flags && + self.mc_onstack == other.mc_onstack && + self.mc_len == other.mc_len && + self.mc_avec == other.mc_avec && + self.mc_av == other.mc_av && + self.mc_frame == other.mc_frame && + self.mc_fpreg == other.mc_fpreg && + self.mc_vsxfpreg == other.mc_vsxfpreg + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_vers", &self.mc_vers) + .field("mc_flags", &self.mc_flags) + .field("mc_onstack", &self.mc_onstack) + .field("mc_len", &self.mc_len) + .field("mc_avec", &self.mc_avec) + .field("mc_av", &self.mc_av) + .field("mc_frame", &self.mc_frame) + .field("mc_fpreg", &self.mc_fpreg) + .field("mc_vsxfpreg", &self.mc_vsxfpreg) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_vers.hash(state); + self.mc_flags.hash(state); + self.mc_onstack.hash(state); + self.mc_len.hash(state); + self.mc_avec.hash(state); + self.mc_av.hash(state); + self.mc_frame.hash(state); + self.mc_fpreg.hash(state); + self.mc_vsxfpreg.hash(state); + } + } + } +} + pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 07f2f11cdc9a4..ca9cf5c8524f2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -32,6 +32,68 @@ s! { } } +s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_vers == other.mc_vers && + self.mc_flags == other.mc_flags && + self.mc_onstack == other.mc_onstack && + self.mc_len == other.mc_len && + self.mc_avec == other.mc_avec && + self.mc_av == other.mc_av && + self.mc_frame == other.mc_frame && + self.mc_fpreg == other.mc_fpreg && + self.mc_vsxfpreg == other.mc_vsxfpreg + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_vers", &self.mc_vers) + .field("mc_flags", &self.mc_flags) + .field("mc_onstack", &self.mc_onstack) + .field("mc_len", &self.mc_len) + .field("mc_avec", &self.mc_avec) + .field("mc_av", &self.mc_av) + .field("mc_frame", &self.mc_frame) + .field("mc_fpreg", &self.mc_fpreg) + .field("mc_vsxfpreg", &self.mc_vsxfpreg) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_vers.hash(state); + self.mc_flags.hash(state); + self.mc_onstack.hash(state); + self.mc_len.hash(state); + self.mc_avec.hash(state); + self.mc_av.hash(state); + self.mc_frame.hash(state); + self.mc_fpreg.hash(state); + self.mc_vsxfpreg.hash(state); + } + } + } +} + pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 3e3e5cc9f34fb..75a900a043d09 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -66,15 +66,6 @@ s! { pub st_birthtime_nsec: ::c_long, __unused: [u8; 8], } - - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } } pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs index 3a016a0519852..208e7f2c90c0a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs @@ -184,14 +184,3 @@ cfg_if! { } } } - -s! { - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } -} From 3f2d4cbd6b6fd9017d0a98217dadecc584a1cfe8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 30 Sep 2024 23:02:26 -0400 Subject: [PATCH 23/45] Update PULL_REQUEST_TEMPLATE.md (#3953) --- .github/PULL_REQUEST_TEMPLATE.md | 52 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3bfd0807ce11b..5aafd9213ef20 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,25 +1,27 @@ -Thanks for considering submitting a PR! - -We have the -[contribution guide](https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md). -Please read it if you're new here! - -Here is a checklist for things that will be checked during review or continuous -integration: - -- \[ ] Edit corresponding file(s) under `libc-test/semver` when you add/remove - item(s), e.g. edit `linux.txt` if you add an item to - `src/unix/linux_like/linux/mod.rs` -- \[ ] Your PR doesn't contain any private or _unstable_ values like `*LAST` or - `*MAX` (see [#3131](https://github.com/rust-lang/libc/issues/3131)) -- \[ ] Provide a link to relevant source (headers or documentation) if your PR - adds or changes API. -- \[ ] If your PR has a breaking change, please clarify it -- \[ ] If your PR increments version number, it must NOT contain any other - changes (otherwise a release could be delayed) -- \[ ] Make sure `ci/style.sh` passes -- \[ ] `cd libc-test && cargo test` - - (this might fail on your env due to environment difference between your env - and CI. Ignore local failures if you are not sure) - -Delete this line and everything above before opening your PR. + + +# Description + + + +# Sources + + + +# Checklist + + + +- [ ] Relevant tests in `libc-test/semver` have been updated +- [ ] No placeholder or unstable values like `*LAST` or `*MAX` are + included (see [#3131](https://github.com/rust-lang/libc/issues/3131)) +- [ ] Tested locally (`cd libc-test && cargo test --target mytarget`); + especially relevant for platforms that may not be checked in CI From d3927d390097e45dbe7138fa88e8e5c98c491d2f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 1 Oct 2024 00:20:02 -0400 Subject: [PATCH 24/45] Sort linux-musl.txt (#3954) --- libc-test/semver/linux-musl.txt | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index c8b5ddbd75c28..3e1b2af9c0a9e 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -5,11 +5,6 @@ AF_XDP AIO_ALLDONE AIO_CANCELED AIO_NOTCANCELED -MPOL_BIND -MPOL_DEFAULT -MPOL_INTERLEAVE -MPOL_LOCAL -MPOL_PREFERRED Elf32_Chdr Elf64_Chdr LIO_NOP @@ -17,6 +12,11 @@ LIO_NOWAIT LIO_READ LIO_WAIT LIO_WRITE +MPOL_BIND +MPOL_DEFAULT +MPOL_INTERLEAVE +MPOL_LOCAL +MPOL_PREFERRED PF_IB PF_MPLS PF_XDP @@ -29,29 +29,29 @@ RWF_HIPRI RWF_NOWAIT RWF_SYNC SOL_XDP -XDP_SHARED_UMEM XDP_COPY -XDP_ZEROCOPY -XDP_USE_NEED_WAKEUP -XDP_USE_SG -XDP_UMEM_UNALIGNED_CHUNK_FLAG -XDP_RING_NEED_WAKEUP XDP_MMAP_OFFSETS -XDP_RX_RING -XDP_TX_RING -XDP_UMEM_REG -XDP_UMEM_FILL_RING -XDP_UMEM_COMPLETION_RING -XDP_STATISTICS XDP_OPTIONS XDP_OPTIONS_ZEROCOPY XDP_PGOFF_RX_RING XDP_PGOFF_TX_RING -XDP_UMEM_PGOFF_FILL_RING +XDP_PKT_CONTD +XDP_RING_NEED_WAKEUP +XDP_RX_RING +XDP_SHARED_UMEM +XDP_STATISTICS +XDP_TX_RING +XDP_UMEM_COMPLETION_RING +XDP_UMEM_FILL_RING XDP_UMEM_PGOFF_COMPLETION_RING -XSK_UNALIGNED_BUF_OFFSET_SHIFT +XDP_UMEM_PGOFF_FILL_RING +XDP_UMEM_REG +XDP_UMEM_UNALIGNED_CHUNK_FLAG +XDP_USE_NEED_WAKEUP +XDP_USE_SG +XDP_ZEROCOPY XSK_UNALIGNED_BUF_ADDR_MASK -XDP_PKT_CONTD +XSK_UNALIGNED_BUF_OFFSET_SHIFT adjtimex aio_cancel aio_error From 1566923c37118df370ed4620a157cb803b0d4415 Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Mon, 30 Sep 2024 21:25:40 -0700 Subject: [PATCH 25/45] Add `getgrgid`, `getgrnam`, `getgrnam_r` and `getgrgid_r` for emscripten (#3912) --- libc-test/semver/emscripten.txt | 4 ++++ src/unix/linux_like/emscripten/mod.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index d61541c4f2baf..150a7fb8a6c6f 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,5 +1,9 @@ AT_EACCESS getentropy +getgrgid +getgrnam +getgrnam_r +getgrgid_r posix_fallocate64 getpwnam_r getpwuid_r diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 4a8bf8dbb6b2d..c492f49f2995d 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1791,6 +1791,24 @@ extern "C" { buflen: ::size_t, result: *mut *mut passwd, ) -> ::c_int; + + // grp.h + pub fn getgrgid(gid: ::gid_t) -> *mut ::group; + pub fn getgrnam(name: *const ::c_char) -> *mut ::group; + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; } // Alias to 64 to mimic glibc's LFS64 support From d8ff07b336fd28c58088b718fee4f0f350b0f733 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 1 Oct 2024 05:48:22 +0100 Subject: [PATCH 26/45] Add mach_error_string (and mach_error_t) (#3913) `mach_error_string` is defined in `/usr/include/mach/mach_error.h` It is not referenced in the documentation Apple website. ``` char *mach_error_string( /* * Returns a string appropriate to the error argument given */ mach_error_t error_value ); ``` `mach_error_t` is defined in `/usr/include/mach/error.h` https://developer.apple.com/documentation/kernel/mach_error_t ``` typedef kern_return_t mach_error_t; ``` --- libc-test/semver/apple.txt | 2 ++ src/unix/bsd/apple/mod.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index f022a006de401..1b548b594a2cb 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1913,6 +1913,8 @@ lockf log2phys login_tty lutimes +mach_error_string +mach_error_t madvise malloc_default_zone malloc_good_size diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d991e379ba79a..48d6edd86aa6c 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -58,6 +58,7 @@ pub type thread_inspect_t = ::mach_port_t; pub type thread_act_t = ::mach_port_t; pub type thread_act_array_t = *mut ::thread_act_t; pub type policy_t = ::c_int; +pub type mach_error_t = ::kern_return_t; pub type mach_vm_address_t = u64; pub type mach_vm_offset_t = u64; pub type mach_vm_size_t = u64; @@ -6209,6 +6210,8 @@ extern "C" { 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; + pub fn mach_error_string(error_value: ::mach_error_t) -> *mut ::c_char; + // Added in macOS 10.13 // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 pub fn memset_s(s: *mut ::c_void, smax: ::size_t, c: ::c_int, n: ::size_t) -> ::c_int; From 6cd88a49e7ead33237eed71152ed72e196b95077 Mon Sep 17 00:00:00 2001 From: Andrew Liebenow Date: Tue, 1 Oct 2024 02:21:44 -0500 Subject: [PATCH 27/45] Add missing musl utmpx.h constants --- libc-test/semver/linux-musl.txt | 9 +++++++++ src/unix/linux_like/linux/musl/mod.rs | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 3e1b2af9c0a9e..2c02db10d94ee 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -5,30 +5,39 @@ AF_XDP AIO_ALLDONE AIO_CANCELED AIO_NOTCANCELED +BOOT_TIME +DEAD_PROCESS Elf32_Chdr Elf64_Chdr +EMPTY +INIT_PROCESS LIO_NOP LIO_NOWAIT LIO_READ LIO_WAIT LIO_WRITE +LOGIN_PROCESS MPOL_BIND MPOL_DEFAULT MPOL_INTERLEAVE MPOL_LOCAL MPOL_PREFERRED +NEW_TIME +OLD_TIME PF_IB PF_MPLS PF_XDP PIDFD_NONBLOCK PR_SET_VMA PR_SET_VMA_ANON_NAME +RUN_LVL RWF_APPEND RWF_DSYNC RWF_HIPRI RWF_NOWAIT RWF_SYNC SOL_XDP +USER_PROCESS XDP_COPY XDP_MMAP_OFFSETS XDP_OPTIONS diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index a37da7d24c314..26427898e5a59 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -628,6 +628,18 @@ pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT; pub const MS_RMT_MASK: ::c_ulong = 0x02800051; +// include/utmpx.h +pub const EMPTY: ::c_short = 0; +pub const RUN_LVL: ::c_short = 1; +pub const BOOT_TIME: ::c_short = 2; +pub const NEW_TIME: ::c_short = 3; +pub const OLD_TIME: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const USER_PROCESS: ::c_short = 7; +pub const DEAD_PROCESS: ::c_short = 8; +// musl does not define ACCOUNTING + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; From 7b0b1a821c494e310c3027394341a286a1fb4831 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Fri, 6 Sep 2024 16:11:20 -0400 Subject: [PATCH 28/45] Apple: Add additional `pthread` APIs --- libc-test/semver/apple.txt | 26 +++++++++++++++++++ src/unix/bsd/apple/b32/mod.rs | 35 ++++++++++++++++++++++++++ src/unix/bsd/apple/b64/mod.rs | 35 ++++++++++++++++++++++++++ src/unix/bsd/apple/mod.rs | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 1b548b594a2cb..ec3791acbfa99 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1117,16 +1117,29 @@ PROC_CSM_TECS PROC_PIDTASKALLINFO PROC_PIDTASKINFO PROC_PIDTHREADINFO +PTHREAD_CANCEL_ASYNCHRONOUS +PTHREAD_CANCEL_DEFERRED +PTHREAD_CANCEL_DISABLE +PTHREAD_CANCEL_ENABLE +PTHREAD_CANCELED PTHREAD_CREATE_DETACHED PTHREAD_CREATE_JOINABLE +PTHREAD_EXPLICIT_SCHED +PTHREAD_INHERIT_SCHED PTHREAD_INTROSPECTION_THREAD_CREATE PTHREAD_INTROSPECTION_THREAD_DESTROY PTHREAD_INTROSPECTION_THREAD_START PTHREAD_INTROSPECTION_THREAD_TERMINATE PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_ERRORCHECK +PTHREAD_ONCE_INIT +PTHREAD_PRIO_INHERIT +PTHREAD_PRIO_NONE +PTHREAD_PRIO_PROTECT PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_SHARED +PTHREAD_SCOPE_PROCESS +PTHREAD_SCOPE_SYSTEM PTHREAD_STACK_MIN PT_ATTACH PT_ATTACHEXC @@ -1744,6 +1757,7 @@ _WSTOPPED __PTHREAD_CONDATTR_SIZE__ __PTHREAD_COND_SIZE__ __PTHREAD_MUTEX_SIZE__ +__PTHREAD_ONCE_SIZE__ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ __darwin_mcontext64 @@ -2041,8 +2055,18 @@ pseudo_AF_KEY pseudo_AF_PIP pseudo_AF_RTIP pseudo_AF_XTP +pthread_atfork +pthread_attr_getdetachstate +pthread_attr_getinheritsched pthread_attr_getschedparam +pthread_attr_getschedpolicy +pthread_attr_getscope +pthread_attr_getstackaddr +pthread_attr_setinheritsched pthread_attr_setschedparam +pthread_attr_setschedpolicy +pthread_attr_setscope +pthread_attr_setstackaddr pthread_cancel pthread_condattr_getpshared pthread_condattr_setpshared @@ -2064,6 +2088,8 @@ pthread_kill pthread_main_np pthread_mutexattr_getpshared pthread_mutexattr_setpshared +pthread_once +pthread_once_t pthread_rwlockattr_getpshared pthread_rwlockattr_setpshared pthread_setname_np diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 4707fa4c99991..c28ad931b4c3c 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -54,6 +54,11 @@ s_no_extra_traits! { __sig: c_long, __opaque: [::c_char; 36] } + + pub struct pthread_once_t { + __sig: c_long, + __opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__], + } } cfg_if! { @@ -82,6 +87,29 @@ cfg_if! { self.__opaque.hash(state); } } + impl PartialEq for pthread_once_t { + fn eq(&self, other: &pthread_once_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_once_t {} + impl ::fmt::Debug for pthread_once_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_once_t") + .field("__sig", &self.__sig) + .finish() + } + } + impl ::hash::Hash for pthread_once_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } } } @@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 10; pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; +pub const __PTHREAD_ONCE_SIZE__: usize = 4; pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; @@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d; pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e; pub const BIOCSETFNR: ::c_ulong = 0x8008427e; +const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; +pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t { + __sig: _PTHREAD_ONCE_SIG_INIT, + __opaque: [0; 4], +}; + extern "C" { pub fn exchangedata( path1: *const ::c_char, diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 48d94bcd6bfdc..2206210da5575 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -54,6 +54,11 @@ s_no_extra_traits! { __sig: c_long, __opaque: [::c_char; 56] } + + pub struct pthread_once_t { + __sig: c_long, + __opaque: [::c_char; __PTHREAD_ONCE_SIZE__], + } } cfg_if! { @@ -82,6 +87,29 @@ cfg_if! { self.__opaque.hash(state); } } + impl PartialEq for pthread_once_t { + fn eq(&self, other: &pthread_once_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_once_t {} + impl ::fmt::Debug for pthread_once_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_once_t") + .field("__sig", &self.__sig) + .finish() + } + } + impl ::hash::Hash for pthread_once_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } } } @@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 11; pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; +pub const __PTHREAD_ONCE_SIZE__: usize = 8; pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; @@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const BIOCSETFNR: ::c_ulong = 0x8010427e; +const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; +pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t { + __sig: _PTHREAD_ONCE_SIG_INIT, + __opaque: [0; 8], +}; + extern "C" { pub fn exchangedata( path1: *const ::c_char, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 48d6edd86aa6c..54735b3f9801b 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3761,6 +3761,19 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2; pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; +pub const PTHREAD_INHERIT_SCHED: ::c_int = 1; +pub const PTHREAD_EXPLICIT_SCHED: ::c_int = 2; +pub const PTHREAD_CANCEL_ENABLE: ::c_int = 0x01; +pub const PTHREAD_CANCEL_DISABLE: ::c_int = 0x00; +pub const PTHREAD_CANCEL_DEFERRED: ::c_int = 0x02; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: ::c_int = 0x00; +pub const PTHREAD_CANCELED: *mut ::c_void = 1 as *mut ::c_void; +pub const PTHREAD_SCOPE_SYSTEM: ::c_int = 1; +pub const PTHREAD_SCOPE_PROCESS: ::c_int = 2; +pub const PTHREAD_PRIO_NONE: ::c_int = 0; +pub const PTHREAD_PRIO_INHERIT: ::c_int = 1; +pub const PTHREAD_PRIO_PROTECT: ::c_int = 2; + #[cfg(target_arch = "aarch64")] pub const PTHREAD_STACK_MIN: ::size_t = 16384; #[cfg(not(target_arch = "aarch64"))] @@ -5700,6 +5713,40 @@ extern "C" { newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; + pub fn pthread_once( + once_control: *mut ::pthread_once_t, + init_routine: ::Option, + ) -> ::c_int; + pub fn pthread_attr_getinheritsched( + attr: *const ::pthread_attr_t, + inheritsched: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getschedpolicy( + attr: *const ::pthread_attr_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getscope( + attr: *const ::pthread_attr_t, + contentionscope: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getstackaddr( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + ) -> ::c_int; + pub fn pthread_attr_getdetachstate( + attr: *const ::pthread_attr_t, + detachstate: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_setinheritsched( + attr: *mut ::pthread_attr_t, + inheritsched: ::c_int, + ) -> ::c_int; + pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int; + pub fn pthread_attr_setscope(attr: *mut ::pthread_attr_t, contentionscope: ::c_int) -> ::c_int; + pub fn pthread_attr_setstackaddr( + attr: *mut ::pthread_attr_t, + stackaddr: *mut ::c_void, + ) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn pthread_mach_thread_np(thread: ::pthread_t) -> ::mach_port_t; From 628bdeeb59a5a01625542ce80bb5692a52a73ea0 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 23 Sep 2024 10:22:32 -0600 Subject: [PATCH 29/45] Fix the definition of ino_t on 32-bit FreeBSD 12+ Commit 7437d0a6f1 erroneously defined it as "ulong" instead of u64. Nobody noticed the mistake, probably because it was only tested on 64-bit architectures, where those are equivalent. But it's a problem now, after #3723 , which switched the standard library to a FreeBSD 12 ABI. Issue https://github.com/rust-lang/rust/issues/130677 --- src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index de34069eabdf2..68a8364194607 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -4,7 +4,7 @@ pub type nlink_t = u16; // Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12: pub type dev_t = u32; -// Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12: +// Type of `ino_t` changed from `__uint32_t` to `__uint64_t` in FreeBSD 12: pub type ino_t = u32; s! { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 10fcaa03a4ef6..197400ffb4e28 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -2,7 +2,7 @@ pub type nlink_t = u64; pub type dev_t = u64; -pub type ino_t = ::c_ulong; +pub type ino_t = u64; pub type shmatt_t = ::c_uint; s! { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index ec6bce2a03091..d3a77d03c48d0 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -2,7 +2,7 @@ pub type nlink_t = u64; pub type dev_t = u64; -pub type ino_t = ::c_ulong; +pub type ino_t = u64; pub type shmatt_t = ::c_uint; pub type kpaddr_t = u64; pub type kssize_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 160a4baae481b..9d65317d29cb4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -2,7 +2,7 @@ pub type nlink_t = u64; pub type dev_t = u64; -pub type ino_t = ::c_ulong; +pub type ino_t = u64; pub type shmatt_t = ::c_uint; pub type kpaddr_t = u64; pub type kssize_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index d73215a68ec33..f76208400f324 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -2,7 +2,7 @@ pub type nlink_t = u64; pub type dev_t = u64; -pub type ino_t = ::c_ulong; +pub type ino_t = u64; pub type shmatt_t = ::c_uint; pub type kpaddr_t = u64; pub type kssize_t = i64; From f9a340427f7cce0b3cdf8ce4cf3ce38abb8b8c3d Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 23 Sep 2024 10:44:13 -0600 Subject: [PATCH 30/45] Fix the definition of "struct stat" on 32-bit FreeBSD 12+ The original definitions were never correct. But nobody noticed because we don't do CI on 32-bit FreeBSD. The problem is apparent now due to #3723 , which caused the nightly toolchain to switch to a FreeBSD 12 ABI. Fixes https://github.com/rust-lang/rust/issues/130677 --- src/unix/bsd/freebsdlike/freebsd/arm.rs | 30 ------------- .../{freebsd12/b64.rs => freebsd11/b32.rs} | 13 +++--- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 7 +-- .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 43 +++++++++++++++---- .../bsd/freebsdlike/freebsd/freebsd13/b64.rs | 34 --------------- .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 43 +++++++++++++++---- .../bsd/freebsdlike/freebsd/freebsd14/b64.rs | 34 --------------- .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 43 +++++++++++++++---- .../bsd/freebsdlike/freebsd/freebsd15/b64.rs | 34 --------------- .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 43 +++++++++++++++---- src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 26 ----------- src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 27 ------------ src/unix/bsd/freebsdlike/freebsd/x86.rs | 27 ------------ 13 files changed, 146 insertions(+), 258 deletions(-) rename src/unix/bsd/freebsdlike/freebsd/{freebsd12/b64.rs => freebsd11/b32.rs} (89%) delete mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs delete mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs delete mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index eb90f3f9030e7..58cf6263310a6 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -8,36 +8,6 @@ pub type register_t = i32; pub type __greg_t = ::c_uint; pub type __gregset_t = [::__greg_t; 17]; -s! { - 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_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_atime_pad: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_mtime_pad: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_ctime_pad: ::c_long, - pub st_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - pub st_birthtime_pad: ::c_long, - } -} - s_no_extra_traits! { pub struct mcontext_t { pub __gregs: ::__gregset_t, diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs similarity index 89% rename from src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs rename to src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs index 80c6fa1684530..5c1156581fd61 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs @@ -3,12 +3,10 @@ pub struct stat { pub st_dev: ::dev_t, pub st_ino: ::ino_t, - pub st_nlink: ::nlink_t, pub st_mode: ::mode_t, - st_padding0: i16, + pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, - st_padding1: i32, pub st_rdev: ::dev_t, pub st_atime: ::time_t, pub st_atime_nsec: ::c_long, @@ -16,14 +14,15 @@ pub struct stat { pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, - pub st_gen: u64, - pub st_spare: [u64; 10], + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + __unused: [u8; 8], } impl ::Copy for ::stat {} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 68a8364194607..e416ebf745841 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -479,10 +479,11 @@ extern "C" { } cfg_if! { - if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv64"))] { + if #[cfg(target_pointer_width = "64")] { mod b64; pub use self::b64::*; + } else { + mod b32; + pub use self::b32::*; } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 197400ffb4e28..c4431a6458e8f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -218,6 +218,40 @@ s! { /// kthread flag. pub ki_tdflags: ::c_long, } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], + } } s_no_extra_traits! { @@ -488,15 +522,6 @@ extern "C" { pub fn basename(path: *mut ::c_char) -> *mut ::c_char; } -cfg_if! { - if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv64"))] { - mod b64; - pub use self::b64::*; - } -} - cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs deleted file mode 100644 index 80c6fa1684530..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs +++ /dev/null @@ -1,34 +0,0 @@ -#[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - st_padding0: i16, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - st_padding1: i32, - pub st_rdev: ::dev_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_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - pub st_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u64, - pub st_spare: [u64; 10], -} - -impl ::Copy for ::stat {} -impl ::Clone for ::stat { - fn clone(&self) -> ::stat { - *self - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index d3a77d03c48d0..118404e8b089b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -228,6 +228,40 @@ s! { /// kthread flag. pub ki_tdflags: ::c_long, } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], + } } s_no_extra_traits! { @@ -529,15 +563,6 @@ extern "C" { pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; } -cfg_if! { - if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv64"))] { - mod b64; - pub use self::b64::*; - } -} - cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs deleted file mode 100644 index 80c6fa1684530..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs +++ /dev/null @@ -1,34 +0,0 @@ -#[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - st_padding0: i16, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - st_padding1: i32, - pub st_rdev: ::dev_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_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - pub st_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u64, - pub st_spare: [u64; 10], -} - -impl ::Copy for ::stat {} -impl ::Clone for ::stat { - fn clone(&self) -> ::stat { - *self - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 9d65317d29cb4..e624dd7201b0a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -228,6 +228,40 @@ s! { /// kthread flag. pub ki_tdflags: ::c_long, } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], + } } s_no_extra_traits! { @@ -529,15 +563,6 @@ extern "C" { pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; } -cfg_if! { - if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv64"))] { - mod b64; - pub use self::b64::*; - } -} - cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs deleted file mode 100644 index 80c6fa1684530..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs +++ /dev/null @@ -1,34 +0,0 @@ -#[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_nlink: ::nlink_t, - pub st_mode: ::mode_t, - st_padding0: i16, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - st_padding1: i32, - pub st_rdev: ::dev_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_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - pub st_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u64, - pub st_spare: [u64; 10], -} - -impl ::Copy for ::stat {} -impl ::Clone for ::stat { - fn clone(&self) -> ::stat { - *self - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index f76208400f324..a299af7d5d53e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -228,6 +228,40 @@ s! { /// kthread flag. pub ki_tdflags: ::c_long, } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], + } } s_no_extra_traits! { @@ -529,15 +563,6 @@ extern "C" { pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; } -cfg_if! { - if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv64"))] { - mod b64; - pub use self::b64::*; - } -} - cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 5de61946de3b9..17d48d5c42cfc 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -6,32 +6,6 @@ pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; -s! { - 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_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_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } -} - s_no_extra_traits! { #[repr(align(16))] pub struct mcontext_t { diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index ca9cf5c8524f2..c98fa3b027173 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -6,32 +6,6 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -s! { - 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_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_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } -} - s_no_extra_traits! { #[repr(align(16))] pub struct mcontext_t { @@ -95,6 +69,5 @@ cfg_if! { } pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; - pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 75a900a043d09..71bdb88b9f2a1 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -41,33 +41,6 @@ s_no_extra_traits! { } } -s! { - 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_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_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - __unused: [u8; 8], - } -} - pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; cfg_if! { From dd202816ec4ddc6cdf2ff9f2710768d7cdbf8309 Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Thu, 10 Oct 2024 13:10:33 +0530 Subject: [PATCH 31/45] Make vxworks functions public and add Risc-V targets --- Cargo.toml | 2 ++ ci/build.sh | 2 ++ src/vxworks/mod.rs | 10 ++++++++-- src/vxworks/riscv32.rs | 4 ++++ src/vxworks/riscv64.rs | 4 ++++ 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/vxworks/riscv32.rs create mode 100644 src/vxworks/riscv64.rs diff --git a/Cargo.toml b/Cargo.toml index ffce4f3241bda..40e8391110c13 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -86,12 +86,14 @@ targets = [ "riscv32i-unknown-none-elf", "riscv32imac-unknown-none-elf", "riscv32imc-unknown-none-elf", + "riscv32-wrs-vxworks", "riscv64gc-unknown-freebsd", "riscv64gc-unknown-hermit", "riscv64gc-unknown-linux-gnu", "riscv64gc-unknown-linux-musl", "riscv64gc-unknown-none-elf", "riscv64imac-unknown-none-elf", + "riscv64-wrs-vxworks", "s390x-unknown-linux-gnu", "s390x-unknown-linux-musl", "sparc-unknown-linux-gnu", diff --git a/ci/build.sh b/ci/build.sh index 722626b43d686..d7d7b9f1bb7d3 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -249,11 +249,13 @@ riscv32i-unknown-none-elf \ riscv32imac-unknown-none-elf \ riscv32imc-unknown-none-elf \ riscv32gc-unknown-linux-gnu \ +riscv32-wrs-vxworks \ riscv64gc-unknown-freebsd \ riscv64gc-unknown-hermit \ riscv64gc-unknown-linux-musl \ riscv64gc-unknown-none-elf \ riscv64imac-unknown-none-elf \ +riscv64-wrs-vxworks \ s390x-unknown-linux-musl \ sparc-unknown-linux-gnu \ sparc64-unknown-netbsd \ diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index fc2aa5e51ae4c..efec114d052f4 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1878,8 +1878,8 @@ extern "C" { pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; // vxCpuLib.h - fn vxCpuEnabledGet() -> ::cpuset_t; // Get set of running CPU's in the system - fn vxCpuConfiguredGet() -> ::cpuset_t; // Get set of Configured CPU's in the system + pub fn vxCpuEnabledGet() -> ::cpuset_t; // Get set of running CPU's in the system + pub fn vxCpuConfiguredGet() -> ::cpuset_t; // Get set of Configured CPU's in the system } //Dummy functions, these don't really exist in VxWorks. @@ -1972,6 +1972,12 @@ cfg_if! { } else if #[cfg(target_arch = "powerpc64")] { mod powerpc64; pub use self::powerpc64::*; + } else if #[cfg(target_arch = "riscv32")] { + mod riscv32; + pub use self::riscv32::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; } else { // Unknown target_arch } diff --git a/src/vxworks/riscv32.rs b/src/vxworks/riscv32.rs new file mode 100644 index 0000000000000..e617bb83c6ce3 --- /dev/null +++ b/src/vxworks/riscv32.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type c_long = i32; +pub type c_ulong = u32; diff --git a/src/vxworks/riscv64.rs b/src/vxworks/riscv64.rs new file mode 100644 index 0000000000000..5e95ea2567ddf --- /dev/null +++ b/src/vxworks/riscv64.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type wchar_t = i32; +pub type c_long = i64; +pub type c_ulong = u64; From 2fcf54bcb327202f0e50374ef904faeb1aa4bfc3 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 14 Sep 2024 20:20:02 +0100 Subject: [PATCH 32/45] fcntl add F_TRANSFEREXTENTS for macos. [ref](https://newosxbook.com/src.jl?tree=xnu&file=/bsd/man/man2/fcntl.2) --- libc-test/semver/apple.txt | 1 + src/unix/bsd/apple/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index ec3791acbfa99..1fd6e03758a2d 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -455,6 +455,7 @@ F_SPECULATIVE_READ F_TEST F_THAW_FS F_TLOCK +F_TRANSFEREXTENTS F_TRIM_ACTIVE_FILE F_ULOCK F_UNLCK diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 54735b3f9801b..1c14c1e70d801 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3591,6 +3591,7 @@ pub const F_PUNCHHOLE: ::c_int = 99; pub const F_TRIM_ACTIVE_FILE: ::c_int = 100; pub const F_SPECULATIVE_READ: ::c_int = 101; pub const F_GETPATH_NOFIRMLINK: ::c_int = 102; +pub const F_TRANSFEREXTENTS: ::c_int = 110; pub const F_ALLOCATECONTIG: ::c_uint = 0x02; pub const F_ALLOCATEALL: ::c_uint = 0x04; From 8924123c42e5fe9232f524129fd4e0d6f239b1d2 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 27 Sep 2024 22:01:43 +0000 Subject: [PATCH 33/45] arc4random api for haiku --- libc-test/build.rs | 1 + src/unix/haiku/mod.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 743f9f28404db..07621d5927d8b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4795,6 +4795,7 @@ fn test_haiku(target: &str) { "libutil.h", "link.h", "pty.h", + "stdlib.h", "stringlist.h", "sys/link_elf.h", } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 4afbeedfc1f9a..47e4c4eb69aeb 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -2133,6 +2133,10 @@ extern "C" { >, data: *mut ::c_void, ) -> ::c_int; + + pub fn arc4random() -> u32; + pub fn arc4random_uniform(upper_bound: u32) -> u32; + pub fn arc4random_buf(buf: *mut ::c_void, n: ::size_t); } #[link(name = "gnu")] From e1566fdb3d2c10b3807db147f080bcbfcd483ea2 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 5 Sep 2024 01:27:06 +0700 Subject: [PATCH 34/45] Add RTF_*, RTA_*, RTAX_*, RTM_* definitions on BSDs * Unify RTM_ADD and friends under bsd namespace * Keeps RTAX_MAX as it is used to loop over alternate internal encoding. --- libc-test/semver/dragonfly.txt | 25 ++++++++++++ libc-test/semver/freebsd.txt | 20 ++++++++++ libc-test/semver/netbsd.txt | 22 +++++++++++ libc-test/semver/openbsd.txt | 42 ++++++++++++++++++++ src/unix/bsd/apple/mod.rs | 37 ----------------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 13 ++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 8 ++++ src/unix/bsd/freebsdlike/mod.rs | 19 +++++++++ src/unix/bsd/mod.rs | 43 ++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 27 +++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 48 +++++++++++++++++++++++ 11 files changed, 267 insertions(+), 37 deletions(-) diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index b9ccffb681ad3..e01fe55d72ff3 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -873,6 +873,31 @@ RLIMIT_STACK RLIMIT_VMEM RLIM_INFINITY RLIM_NLIMITS +RTF_XRESOLVE +RTF_LLINFO +RTF_PROTO3 +RTF_PINNED +RTF_LOCAL +RTF_BROADCAST +RTF_MULTICAST +RTM_LOCK +RTM_RESOLVE +RTM_NEWADDR +RTM_DELADDR +RTM_IFINFO +RTM_NEWMADDR +RTM_DELMADDR +RTM_IFANNOUNCE +RTM_IEEE80211 +RTF_CLONING +RTF_PRCLONING +RTF_WASCLONED +RTF_MPLSOPS +RTM_VERSION +RTAX_MPLS1 +RTAX_MPLS2 +RTAX_MPLS3 +RTAX_MAX RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index cb36429fb36ab..5d4253029e5e6 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1222,6 +1222,26 @@ RLIMIT_UMTXP RLIMIT_VMEM RLIM_INFINITY RLIM_NLIMITS +RTF_XRESOLVE +RTF_LLINFO +RTF_PROTO3 +RTF_PINNED +RTF_LOCAL +RTF_BROADCAST +RTF_MULTICAST +RTM_LOCK +RTM_RESOLVE +RTM_NEWADDR +RTM_DELADDR +RTM_IFINFO +RTM_NEWMADDR +RTM_DELMADDR +RTM_IFANNOUNCE +RTM_IEEE80211 +RTF_LLDATA +RTF_FIXEDMTU +RTM_VERSION +RTAX_MAX RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index e07a7dbf08ae6..cfde7caca0c55 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -929,6 +929,28 @@ RLIM_INFINITY RLIM_NLIMITS RLIM_SAVED_CUR RLIM_SAVED_MAX +RTF_MASK +RTF_CONNECTED +RTF_ANNOUNCE +RTF_SRC +RTF_LOCAL +RTF_BROADCAST +RTF_UPDATING +RTF_DONTCHANGEIFA +RTM_VERSION +RTM_LOCK +RTM_IFANNOUNCE +RTM_IEEE80211 +RTM_SETGATE +RTM_LLINFO_UPD +RTM_IFINFO +RTM_OCHGADDR +RTM_NEWADDR +RTM_DELADDR +RTM_CHGADDR +RTA_TAG +RTAX_TAG +RTAX_MAX RTLD_NEXT RTLD_NOLOAD RTLD_SELF diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 019ab53d34ff0..9297c4ac4b81e 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -761,8 +761,50 @@ RLIM_INFINITY RLIM_NLIMITS RLIM_SAVED_CUR RLIM_SAVED_MAX +RTA_BFD +RTA_DNS +RTA_LABEL +RTA_SEARCH +RTA_SRC +RTA_SRCMASK +RTA_STATIC +RTAX_BFD +RTAX_DNS +RTAX_LABEL +RTAX_MAX +RTAX_SEARCH +RTAX_SRC +RTAX_SRCMASK +RTAX_STATIC +RTF_ANNOUNCE +RTF_BFD +RTF_BROADCAST +RTF_CACHED +RTF_CLONED +RTF_CLONING +RTF_CONNECTED +RTF_FMASK +RTF_LLINFO +RTF_LOCAL +RTF_MPATH +RTF_MPLS +RTF_MULTICAST +RTF_PROTO3 RTLD_NEXT RTLD_SELF +RTM_80211INFO +RTM_BFD +RTM_CHGADDRATTR +RTM_DELADDR +RTM_DESYNC +RTM_IFANNOUNCE +RTM_IFINFO +RTM_INVALIDATE +RTM_NEWADDR +RTM_PROPOSAL +RTM_RESOLVE +RTM_SOURCE +RTM_VERSION RUSAGE_CHILDREN RUSAGE_SELF RUSAGE_THREAD diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 54735b3f9801b..9c12439e54cbd 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4914,22 +4914,11 @@ pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020; pub const NET_RT_IFLIST2: ::c_int = 0x0006; // net/route.h -pub const RTF_UP: ::c_int = 0x1; -pub const RTF_GATEWAY: ::c_int = 0x2; -pub const RTF_HOST: ::c_int = 0x4; -pub const RTF_REJECT: ::c_int = 0x8; -pub const RTF_DYNAMIC: ::c_int = 0x10; -pub const RTF_MODIFIED: ::c_int = 0x20; -pub const RTF_DONE: ::c_int = 0x40; pub const RTF_DELCLONE: ::c_int = 0x80; pub const RTF_CLONING: ::c_int = 0x100; pub const RTF_XRESOLVE: ::c_int = 0x200; pub const RTF_LLINFO: ::c_int = 0x400; -pub const RTF_STATIC: ::c_int = 0x800; -pub const RTF_BLACKHOLE: ::c_int = 0x1000; pub const RTF_NOIFREF: ::c_int = 0x2000; -pub const RTF_PROTO2: ::c_int = 0x4000; -pub const RTF_PROTO1: ::c_int = 0x8000; pub const RTF_PRCLONING: ::c_int = 0x10000; pub const RTF_WASCLONED: ::c_int = 0x20000; pub const RTF_PROTO3: ::c_int = 0x40000; @@ -4948,13 +4937,6 @@ pub const RTF_GLOBAL: ::c_int = 0x40000000; pub const RTM_VERSION: ::c_int = 5; // Message types -pub const RTM_ADD: ::c_int = 0x1; -pub const RTM_DELETE: ::c_int = 0x2; -pub const RTM_CHANGE: ::c_int = 0x3; -pub const RTM_GET: ::c_int = 0x4; -pub const RTM_LOSING: ::c_int = 0x5; -pub const RTM_REDIRECT: ::c_int = 0x6; -pub const RTM_MISS: ::c_int = 0x7; pub const RTM_LOCK: ::c_int = 0x8; pub const RTM_OLDADD: ::c_int = 0x9; pub const RTM_OLDDEL: ::c_int = 0xa; @@ -4978,25 +4960,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20; pub const RTV_RTT: ::c_int = 0x40; pub const RTV_RTTVAR: ::c_int = 0x80; -// Bitmask values for rtm_addrs. -pub const RTA_DST: ::c_int = 0x1; -pub const RTA_GATEWAY: ::c_int = 0x2; -pub const RTA_NETMASK: ::c_int = 0x4; -pub const RTA_GENMASK: ::c_int = 0x8; -pub const RTA_IFP: ::c_int = 0x10; -pub const RTA_IFA: ::c_int = 0x20; -pub const RTA_AUTHOR: ::c_int = 0x40; -pub const RTA_BRD: ::c_int = 0x80; - -// Index offsets for sockaddr array for alternate internal encoding. -pub const RTAX_DST: ::c_int = 0; -pub const RTAX_GATEWAY: ::c_int = 1; -pub const RTAX_NETMASK: ::c_int = 2; -pub const RTAX_GENMASK: ::c_int = 3; -pub const RTAX_IFP: ::c_int = 4; -pub const RTAX_IFA: ::c_int = 5; -pub const RTAX_AUTHOR: ::c_int = 6; -pub const RTAX_BRD: ::c_int = 7; pub const RTAX_MAX: ::c_int = 8; pub const KERN_PROCARGS2: ::c_int = 49; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 489b82adb84b9..e00e60290369d 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1522,6 +1522,19 @@ pub const NGROUPS: usize = 16; pub const RB_PAUSE: ::c_int = 0x40000; pub const RB_VIDEO: ::c_int = 0x20000000; +// net/route.h +pub const RTF_CLONING: ::c_int = 0x100; +pub const RTF_PRCLONING: ::c_int = 0x10000; +pub const RTF_WASCLONED: ::c_int = 0x20000; +pub const RTF_MPLSOPS: ::c_int = 0x1000000; + +pub const RTM_VERSION: ::c_int = 7; + +pub const RTAX_MPLS1: ::c_int = 8; +pub const RTAX_MPLS2: ::c_int = 9; +pub const RTAX_MPLS3: ::c_int = 10; +pub const RTAX_MAX: ::c_int = 11; + const_fn! { {const} fn _CMSG_ALIGN(n: usize) -> usize { (n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index fc01d8e5463b8..0905d3c94f7f4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4697,6 +4697,14 @@ pub const CPU_WHICH_CPUSET: ::c_int = 3; pub const CPU_WHICH_IRQ: ::c_int = 4; pub const CPU_WHICH_JAIL: ::c_int = 5; +// net/route.h +pub const RTF_LLDATA: ::c_int = 0x400; +pub const RTF_FIXEDMTU: ::c_int = 0x80000; + +pub const RTM_VERSION: ::c_int = 5; + +pub const RTAX_MAX: ::c_int = 8; + // sys/signal.h pub const SIGTHR: ::c_int = 32; pub const SIGLWP: ::c_int = SIGTHR; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index af0632882cdbc..5ce3600d94ac9 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1009,6 +1009,25 @@ pub const SO_TYPE: ::c_int = 0x1008; pub const LOCAL_PEERCRED: ::c_int = 1; +// net/route.h +pub const RTF_XRESOLVE: ::c_int = 0x200; +pub const RTF_LLINFO: ::c_int = 0x400; +pub const RTF_PROTO3: ::c_int = 0x40000; +pub const RTF_PINNED: ::c_int = 0x100000; +pub const RTF_LOCAL: ::c_int = 0x200000; +pub const RTF_BROADCAST: ::c_int = 0x400000; +pub const RTF_MULTICAST: ::c_int = 0x800000; + +pub const RTM_LOCK: ::c_int = 0x8; +pub const RTM_RESOLVE: ::c_int = 0xb; +pub const RTM_NEWADDR: ::c_int = 0xc; +pub const RTM_DELADDR: ::c_int = 0xd; +pub const RTM_IFINFO: ::c_int = 0xe; +pub const RTM_NEWMADDR: ::c_int = 0xf; +pub const RTM_DELMADDR: ::c_int = 0x10; +pub const RTM_IFANNOUNCE: ::c_int = 0x11; +pub const RTM_IEEE80211: ::c_int = 0x12; + pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 61f764d1d2dee..918007159862e 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -543,6 +543,49 @@ pub const ITIMER_REAL: ::c_int = 0; pub const ITIMER_VIRTUAL: ::c_int = 1; pub const ITIMER_PROF: ::c_int = 2; +// net/route.h + +pub const RTF_UP: ::c_int = 0x1; +pub const RTF_GATEWAY: ::c_int = 0x2; +pub const RTF_HOST: ::c_int = 0x4; +pub const RTF_REJECT: ::c_int = 0x8; +pub const RTF_DYNAMIC: ::c_int = 0x10; +pub const RTF_MODIFIED: ::c_int = 0x20; +pub const RTF_DONE: ::c_int = 0x40; +pub const RTF_STATIC: ::c_int = 0x800; +pub const RTF_BLACKHOLE: ::c_int = 0x1000; +pub const RTF_PROTO2: ::c_int = 0x4000; +pub const RTF_PROTO1: ::c_int = 0x8000; + +// Message types +pub const RTM_ADD: ::c_int = 0x1; +pub const RTM_DELETE: ::c_int = 0x2; +pub const RTM_CHANGE: ::c_int = 0x3; +pub const RTM_GET: ::c_int = 0x4; +pub const RTM_LOSING: ::c_int = 0x5; +pub const RTM_REDIRECT: ::c_int = 0x6; +pub const RTM_MISS: ::c_int = 0x7; + +// Bitmask values for rtm_addrs. +pub const RTA_DST: ::c_int = 0x1; +pub const RTA_GATEWAY: ::c_int = 0x2; +pub const RTA_NETMASK: ::c_int = 0x4; +pub const RTA_GENMASK: ::c_int = 0x8; +pub const RTA_IFP: ::c_int = 0x10; +pub const RTA_IFA: ::c_int = 0x20; +pub const RTA_AUTHOR: ::c_int = 0x40; +pub const RTA_BRD: ::c_int = 0x80; + +// Index offsets for sockaddr array for alternate internal encoding. +pub const RTAX_DST: ::c_int = 0; +pub const RTAX_GATEWAY: ::c_int = 1; +pub const RTAX_NETMASK: ::c_int = 2; +pub const RTAX_GENMASK: ::c_int = 3; +pub const RTAX_IFP: ::c_int = 4; +pub const RTAX_IFA: ::c_int = 5; +pub const RTAX_AUTHOR: ::c_int = 6; +pub const RTAX_BRD: ::c_int = 7; + f! { pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr { if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 318557daf52b8..0921d56912cd2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2402,6 +2402,33 @@ pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int { alignment << MAP_ALIGNMENT_SHIFT } +// net/route.h +pub const RTF_MASK: ::c_int = 0x80; +pub const RTF_CONNECTED: ::c_int = 0x100; +pub const RTF_ANNOUNCE: ::c_int = 0x20000; +pub const RTF_SRC: ::c_int = 0x10000; +pub const RTF_LOCAL: ::c_int = 0x40000; +pub const RTF_BROADCAST: ::c_int = 0x80000; +pub const RTF_UPDATING: ::c_int = 0x100000; +pub const RTF_DONTCHANGEIFA: ::c_int = 0x200000; + +pub const RTM_VERSION: ::c_int = 4; +pub const RTM_LOCK: ::c_int = 0x8; +pub const RTM_IFANNOUNCE: ::c_int = 0x10; +pub const RTM_IEEE80211: ::c_int = 0x11; +pub const RTM_SETGATE: ::c_int = 0x12; +pub const RTM_LLINFO_UPD: ::c_int = 0x13; +pub const RTM_IFINFO: ::c_int = 0x14; +pub const RTM_OCHGADDR: ::c_int = 0x15; +pub const RTM_NEWADDR: ::c_int = 0x16; +pub const RTM_DELADDR: ::c_int = 0x17; +pub const RTM_CHGADDR: ::c_int = 0x18; + +pub const RTA_TAG: ::c_int = 0x100; + +pub const RTAX_TAG: ::c_int = 8; +pub const RTAX_MAX: ::c_int = 9; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 357662547b8e3..9e14e89515e47 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1881,6 +1881,54 @@ pub const RB_RESET: ::c_int = 0x08000; pub const RB_GOODRANDOM: ::c_int = 0x10000; pub const RB_UNHIBERNATE: ::c_int = 0x20000; +// net/route.h +pub const RTF_CLONING: ::c_int = 0x100; +pub const RTF_MULTICAST: ::c_int = 0x200; +pub const RTF_LLINFO: ::c_int = 0x400; +pub const RTF_PROTO3: ::c_int = 0x2000; +pub const RTF_ANNOUNCE: ::c_int = ::RTF_PROTO2; + +pub const RTF_CLONED: ::c_int = 0x10000; +pub const RTF_CACHED: ::c_int = 0x20000; +pub const RTF_MPATH: ::c_int = 0x40000; +pub const RTF_MPLS: ::c_int = 0x100000; +pub const RTF_LOCAL: ::c_int = 0x200000; +pub const RTF_BROADCAST: ::c_int = 0x400000; +pub const RTF_CONNECTED: ::c_int = 0x800000; +pub const RTF_BFD: ::c_int = 0x1000000; +pub const RTF_FMASK: ::c_int = b'\\' as _; + +pub const RTM_VERSION: ::c_int = 5; +pub const RTM_RESOLVE: ::c_int = 0xb; +pub const RTM_NEWADDR: ::c_int = 0xc; +pub const RTM_DELADDR: ::c_int = 0xd; +pub const RTM_IFINFO: ::c_int = 0xe; +pub const RTM_IFANNOUNCE: ::c_int = 0xf; +pub const RTM_DESYNC: ::c_int = 0x10; +pub const RTM_INVALIDATE: ::c_int = 0x11; +pub const RTM_BFD: ::c_int = 0x12; +pub const RTM_PROPOSAL: ::c_int = 0x13; +pub const RTM_CHGADDRATTR: ::c_int = 0x14; +pub const RTM_80211INFO: ::c_int = 0x15; +pub const RTM_SOURCE: ::c_int = 0x16; + +pub const RTA_SRC: ::c_int = 0x100; +pub const RTA_SRCMASK: ::c_int = 0x200; +pub const RTA_LABEL: ::c_int = 0x400; +pub const RTA_BFD: ::c_int = 0x800; +pub const RTA_DNS: ::c_int = 0x1000; +pub const RTA_STATIC: ::c_int = 0x2000; +pub const RTA_SEARCH: ::c_int = 0x4000; + +pub const RTAX_SRC: ::c_int = 8; +pub const RTAX_SRCMASK: ::c_int = 9; +pub const RTAX_LABEL: ::c_int = 10; +pub const RTAX_BFD: ::c_int = 11; +pub const RTAX_DNS: ::c_int = 12; +pub const RTAX_STATIC: ::c_int = 13; +pub const RTAX_SEARCH: ::c_int = 14; +pub const RTAX_MAX: ::c_int = 15; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES From dbe4b8b1a607163ff11ada0a13a7dc3549a4c62d Mon Sep 17 00:00:00 2001 From: Sebastien Marie Date: Tue, 15 Oct 2024 07:15:45 +0000 Subject: [PATCH 35/45] unbreak OpenBSD after #3714 by properly define RTF_FMASK --- src/unix/bsd/netbsdlike/openbsd/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 9e14e89515e47..19a43979b8318 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1896,7 +1896,15 @@ pub const RTF_LOCAL: ::c_int = 0x200000; pub const RTF_BROADCAST: ::c_int = 0x400000; pub const RTF_CONNECTED: ::c_int = 0x800000; pub const RTF_BFD: ::c_int = 0x1000000; -pub const RTF_FMASK: ::c_int = b'\\' as _; +pub const RTF_FMASK: ::c_int = ::RTF_LLINFO + | ::RTF_PROTO1 + | ::RTF_PROTO2 + | ::RTF_PROTO3 + | ::RTF_BLACKHOLE + | ::RTF_REJECT + | ::RTF_STATIC + | ::RTF_MPLS + | ::RTF_BFD; pub const RTM_VERSION: ::c_int = 5; pub const RTM_RESOLVE: ::c_int = 0xb; From e8d8053cbaba10bba9001c8f9caae3416969bc87 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 6 May 2024 15:00:03 -0600 Subject: [PATCH 36/45] redox: correct EPOLL constants --- src/unix/redox/mod.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 87fb3cc7adb2f..92aa1da91ac6b 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -683,22 +683,22 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x0100_0000; pub const EPOLL_CTL_ADD: ::c_int = 1; pub const EPOLL_CTL_DEL: ::c_int = 2; pub const EPOLL_CTL_MOD: ::c_int = 3; -pub const EPOLLIN: ::c_int = 1; -pub const EPOLLPRI: ::c_int = 0; -pub const EPOLLOUT: ::c_int = 2; -pub const EPOLLRDNORM: ::c_int = 0; -pub const EPOLLNVAL: ::c_int = 0; -pub const EPOLLRDBAND: ::c_int = 0; -pub const EPOLLWRNORM: ::c_int = 0; -pub const EPOLLWRBAND: ::c_int = 0; -pub const EPOLLMSG: ::c_int = 0; -pub const EPOLLERR: ::c_int = 0; -pub const EPOLLHUP: ::c_int = 0; -pub const EPOLLRDHUP: ::c_int = 0; -pub const EPOLLEXCLUSIVE: ::c_int = 0; -pub const EPOLLWAKEUP: ::c_int = 0; -pub const EPOLLONESHOT: ::c_int = 0; -pub const EPOLLET: ::c_int = 0; +pub const EPOLLIN: ::c_int = 0x001; +pub const EPOLLPRI: ::c_int = 0x002; +pub const EPOLLOUT: ::c_int = 0x004; +pub const EPOLLERR: ::c_int = 0x008; +pub const EPOLLHUP: ::c_int = 0x010; +pub const EPOLLNVAL: ::c_int = 0x020; +pub const EPOLLRDNORM: ::c_int = 0x040; +pub const EPOLLRDBAND: ::c_int = 0x080; +pub const EPOLLWRNORM: ::c_int = 0x100; +pub const EPOLLWRBAND: ::c_int = 0x200; +pub const EPOLLMSG: ::c_int = 0x400; +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 1 << 28; +pub const EPOLLWAKEUP: ::c_int = 1 << 29; +pub const EPOLLONESHOT: ::c_int = 1 << 30; +pub const EPOLLET: ::c_int = 1 << 31; // sys/stat.h pub const S_IFMT: ::c_int = 0o17_0000; From a4ef31b4334b658df8760faec51030559af6a109 Mon Sep 17 00:00:00 2001 From: Jan Sommer Date: Tue, 15 Oct 2024 18:28:51 +0200 Subject: [PATCH 37/45] Add getentropy to RTEMS --- src/unix/newlib/rtems/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index 36f4820c92f4f..031754950e6c1 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -137,5 +137,7 @@ extern "C" { clock_id: ::clockid_t, ) -> ::c_int; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int; } From 9b0ccb1014d847270be7721a059bc34d6e32161e Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 15 Oct 2024 12:35:21 -0600 Subject: [PATCH 38/45] Temporarily disable CI on FreeBSD 15 FreeBSD 15 is the unstable development release. Currently its GCE images available to Cirrus CI don't work because the solib version of libmd was just bumped, and the package builders haven't yet caught up. Issue #3967 --- .cirrus.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index bd9100b9b0eb4..d8fed558df6aa 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -7,9 +7,13 @@ task: - name: nightly freebsd-14 freebsd_instance: image: freebsd-14-1-release-amd64-ufs - - name: nightly freebsd-15 - freebsd_instance: - image_family: freebsd-15-0-snap + # Temporarily disable CI on FreeBSD 15.0-CURRENT until the libmd solib + # fallout is cleaned up. + # FIXME https://github.com/rust-lang/libc/issues/3967 + # https://github.com/rust-lang/libc/issues/3967 + #- name: nightly freebsd-15 + # freebsd_instance: + # image_family: freebsd-15-0-snap setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh From 1d5d92ca07688f654dd7a2c3b78794dae7ec8d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 16 Oct 2024 08:39:56 +0200 Subject: [PATCH 39/45] semver/linux-musl: Remove outdated "TODO: musl" comment The comment was there since the file was otherwise empty, but it has outlived its purpose. --- libc-test/semver/linux-musl.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 063bca262c338..9a34b36c2584c 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -1,4 +1,3 @@ -# TODO: musl. AF_IB AF_MPLS AF_XDP From fea199a3d306a01e967bcb0812946926bc46ab3f Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Wed, 16 Oct 2024 09:59:53 +0530 Subject: [PATCH 40/45] VxWorks Sched_param renamed, pthread functions and constants added --- src/vxworks/mod.rs | 66 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index efec114d052f4..3280eeb7e5a2f 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -253,7 +253,7 @@ s! { } // b_struct__Sched_param.h - pub struct _Sched_param { + pub struct sched_param { pub sched_priority: ::c_int, /* scheduling priority */ pub sched_ss_low_priority: ::c_int, /* low scheduling priority */ pub sched_ss_repl_period: ::_Timespec, /* replenishment period */ @@ -274,7 +274,7 @@ s! { pub threadAttrSchedpolicy : ::c_int, pub threadAttrName : *mut ::c_char, pub threadAttrOptions : ::c_int, - pub threadAttrSchedparam : ::_Sched_param, + pub threadAttrSchedparam : ::sched_param, } // signal.h @@ -613,6 +613,19 @@ pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; pub const PTHREAD_STACK_MIN: usize = 4096; pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30; +//sched.h +pub const SCHED_FIFO: ::c_int = 0x01; +pub const SCHED_RR: ::c_int = 0x02; +pub const SCHED_OTHER: ::c_int = 0x04; +pub const SCHED_SPORADIC: ::c_int = 0x08; +pub const PRIO_PROCESS: ::c_uint = 0; +pub const SCHED_FIFO_HIGH_PRI: ::c_int = 255; +pub const SCHED_FIFO_LOW_PRI: ::c_int = 0; +pub const SCHED_RR_HIGH_PRI: ::c_int = 255; +pub const SCHED_RR_LOW_PRI: ::c_int = 0; +pub const SCHED_SPORADIC_HIGH_PRI: ::c_int = 255; +pub const SCHED_SPORADIC_LOW_PRI: ::c_int = 0; + // ERRNO STUFF pub const ERROR: ::c_int = -1; pub const OK: ::c_int = 0; @@ -1388,6 +1401,29 @@ extern "C" { value: *mut ::c_void, ) -> ::c_int; + //pthread.h + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + + //pthread.h + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut ::sched_param, + ) -> ::c_int; + + //pthread.h + pub fn pthread_attr_setinheritsched( + attr: *mut ::pthread_attr_t, + inheritsched: ::c_int, + ) -> ::c_int; + + //pthread.h + pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int; + // pthread.h pub fn pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int; @@ -1400,6 +1436,7 @@ extern "C" { parent: ::Option, child: ::Option, ) -> ::c_int; + // stat.h pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; @@ -1754,6 +1791,31 @@ extern "C" { // dirent.h pub fn closedir(ptr: *mut ::DIR) -> ::c_int; + //sched.h + pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; + + //sched.h + pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; + + //sched.h + pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; + + //sched.h + pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; + + //sched.h + pub fn sched_setscheduler( + pid: ::pid_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + + //sched.h + pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; + + //sched.h + pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; + // sched.h pub fn sched_yield() -> ::c_int; From 1f687923ce2fddb87ee8d39552afef7649ed4bb5 Mon Sep 17 00:00:00 2001 From: Sebastien Marie Date: Thu, 17 Oct 2024 06:40:28 +0000 Subject: [PATCH 41/45] unbreak OpenBSD after #3937 fix FNM_PATHNAME and FNM_NOESCAPE values. --- src/unix/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 2c2fc54dd2912..d53a382a01ae4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -329,6 +329,7 @@ cfg_if! { target_os = "macos", target_os = "freebsd", target_os = "android", + target_os = "openbsd", ))] { pub const FNM_PATHNAME: c_int = 1 << 1; pub const FNM_NOESCAPE: c_int = 1 << 0; From 86d3d1e400bb796949572572f72612cb8190afde Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 17 Oct 2024 13:58:52 -0600 Subject: [PATCH 42/45] Reenable CI on FreeBSD 15 The freebsd-15-0-current-amd64-ufs-20241017 GCE image fixes the libmd.so problem, and once again works with Cirrus CI. Fixes #3967 --- .cirrus.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index d8fed558df6aa..8d3c647d58ece 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -7,13 +7,9 @@ task: - name: nightly freebsd-14 freebsd_instance: image: freebsd-14-1-release-amd64-ufs - # Temporarily disable CI on FreeBSD 15.0-CURRENT until the libmd solib - # fallout is cleaned up. - # FIXME https://github.com/rust-lang/libc/issues/3967 - # https://github.com/rust-lang/libc/issues/3967 - #- name: nightly freebsd-15 - # freebsd_instance: - # image_family: freebsd-15-0-snap + - name: nightly freebsd-15 + freebsd_instance: + image_family: freebsd-15-0-snap setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh From 043043f1b2dfcc240c968e75baff9cc135b80613 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 22 Jun 2024 11:22:44 +0200 Subject: [PATCH 43/45] hurd: Fix st_dev name Currently struct stat and struct stat64 are not coherent: struct stat is using st_dev, and struct stat64 is using st_fsid. st_dev is the more commonly-known name, already used by e.g. ~45 rust software in Debian, so better fix st_fsid into st_dev, rather than having to uselessly spend time hand-patching all these software. --- src/unix/hurd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index a89da8c5e5b2b..ee4597f8bb6b1 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -481,7 +481,7 @@ s! { pub struct stat64 { pub st_fstype: ::c_int, - pub st_fsid: __fsid_t, + pub st_dev: __fsid_t, /* Actually st_fsid */ pub st_ino: __ino64_t, pub st_gen: ::c_uint, pub st_rdev: __dev_t, From 158cd3063c11415194e0dc6e90cdf5fdad8b86e5 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 20 Oct 2024 09:17:50 +0200 Subject: [PATCH 44/45] hurd: fix definition of utsname struct - drop the "domainname" field, as it is not actually used - add a private "_UTSNAME_LENGTH" constant matching the helper libc one, to ease declaring the struct - bump the size of the other fields to "_UTSNAME_LENGTH" --- src/unix/hurd/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index a89da8c5e5b2b..b2c9bab720287 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -872,12 +872,11 @@ s! { } pub struct utsname { - pub sysname: [::c_char; 65], - pub nodename: [::c_char; 65], - pub release: [::c_char; 65], - pub version: [::c_char; 65], - pub machine: [::c_char; 65], - pub domainname: [::c_char; 65] + pub sysname: [::c_char; _UTSNAME_LENGTH], + pub nodename: [::c_char; _UTSNAME_LENGTH], + pub release: [::c_char; _UTSNAME_LENGTH], + pub version: [::c_char; _UTSNAME_LENGTH], + pub machine: [::c_char; _UTSNAME_LENGTH], } pub struct rlimit64 { @@ -3436,6 +3435,9 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { }; pub const PTHREAD_STACK_MIN: ::size_t = 0; +// Non-public helper constants +const _UTSNAME_LENGTH: usize = 1024; + const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) From 816b52478c6f057a58a10fb7e09f38864330f71c Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 21 Oct 2024 14:31:47 -0600 Subject: [PATCH 45/45] Fix the build on armv7-unknown-freebsd PR #3848 broke the build on armv7-unknown-freebsd by defining a field to be of an unknown type. Use the correct type name `usize` instead of `::__size_t`. --- src/unix/bsd/freebsdlike/freebsd/arm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 58cf6263310a6..8bc9378be2e6d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -11,7 +11,7 @@ pub type __gregset_t = [::__greg_t; 17]; s_no_extra_traits! { pub struct mcontext_t { pub __gregs: ::__gregset_t, - pub mc_vfp_size: ::__size_t, + pub mc_vfp_size: usize, pub mc_vfp_ptr: *mut ::c_void, pub mc_spare: [::c_uint; 33], }