From 3d65dc319857d371c4099d35ce7a833feda0fa8f Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 28 Jul 2026 15:31:07 +0200 Subject: [PATCH 01/88] libc-test/ctest fixes for QNX these are changes required to pass `cargo test -p libc-test --test ctest` on the QNX targets libc-test had probably not been run before for QNX8 so quite a few things needed fixing: - some constants that were present in QNX7.1 are no longer present in QNX8, e.g. `STATE_STACK`, `_NTO_CI_SANDBOX` - the values of some constants have changed on QNX8, e.g. `FILENAME_MAX` - some functions that were present in QNX7.1 are no longer present in QNX8, e.g `SyncMutexRevive` - some structs have changed ABI in QNX8, e.g. `_thread_attr`, `mallinfo`, `pthread_rwlock_t` - on QNX8, `inotify_*` functions now live in the `libfsnotify.so` library - on QNX8, the neutrino API is specified in `sys/neutrino.h` - some header files (e.g. `sys/malloc.h`, `nbutil.h`) are no longer present on QNX8 libc-test probably had not been run in a while for QNX7.1 so there a few small fixes there as well: - `ctest` v0.5.x requires that bindings have named arguments but `sysctl` was using underscores (`_`) as names; the arguments now have names - `BPF_{MOD,XOR}` are only defined in `pcap/bpf.h` but the header file cannot be included together with `net/bpf.h` due to `ifdef` include guards on the C side and `ctest` only generating a single test binary. These constants can't be tested by `ctest` on QNX7.1, so they have been added to the skip list - `ctest` does not support anonymous unions so the `ifr_ifru` field in the `ifreq` struct needs to be skipped - the `timezone` struct must be skipped as it's an `extern_ty!`pe (backport ) (cherry picked from commit 8568742e2d53ed681d7baf0829a1f1175270db21) --- libc-test/build/main.rs | 28 +++++++- src/new/nto/net/if_.rs | 45 ++++++++++-- src/unix/nto/mod.rs | 110 ++++++++++++++++++++++++------ src/unix/nto/neutrino.rs | 144 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 296 insertions(+), 31 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 597f75f1cfd73..de3ed278fec5b 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -3570,7 +3570,6 @@ fn test_neutrino(target: &str) { "limits.h", "sys/link.h", "locale.h", - "sys/malloc.h", "rcheck/malloc.h", "malloc.h", "mqueue.h", @@ -3634,7 +3633,6 @@ fn test_neutrino(target: &str) { "nl_types.h", "langinfo.h", "unix.h", - "nbutil.h", "aio.h", "net/bpf.h", "net/if_dl.h", @@ -3645,6 +3643,20 @@ fn test_neutrino(target: &str) { //"sys/asyncmsg.h", ); + // add QNX version specific header files + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + match target_os.as_str() { + "nto" => { + headers!(cfg, "sys/malloc.h", "nbutil.h",); + } + "qnx" => { + headers!(cfg, "sys/neutrino.h",); + } + _ => { + panic!("unexpected QNX target_os value: {target_os}") + } + } + // Create and include a header file containing // items which are not included in any official // header file. @@ -3717,7 +3729,7 @@ fn test_neutrino(target: &str) { "_channel_connect_attr" => true, // Extern types - "DIR" | "FILE" | "fpos_t" => true, + "DIR" | "FILE" | "fpos_t" | "timezone" => true, _ => false, } @@ -3731,6 +3743,15 @@ fn test_neutrino(target: &str) { "SIG_IGN" => true, "SIG_ERR" => true, + // On QNX7.x these constants are defined in `pcap/bpf.h` but we pass `net/bpf.h` to + // `ctest`. Both header files cannot be included at the same time because of + // `ifdef` include guards. As `ctest` only produces one test program we cannot + // test `pcap/bpf.h` separately + "BPF_MOD" | "BPF_XOR" => target_os == "nto", + // The value of this constant can changed from one QNX patchset to the next one so we + // skip it. The corresponding Rust binding is also marked as `#[deprecated]` + "RLIM_NLIMITS" => true, + _ => false, } }); @@ -3789,6 +3810,7 @@ fn test_neutrino(target: &str) { | ("sigevent", "__sigev_un2") // union | ("sigaction", "sa_sigaction") // sighandler_t type is super weird | ("syspage_entry", "__reserved") // does not exist + | ("ifreq", "ifr_ifru") // ifr_ifru is an anonymous union ) }); diff --git a/src/new/nto/net/if_.rs b/src/new/nto/net/if_.rs index d71c1bb24b32e..93789ec95aa06 100644 --- a/src/new/nto/net/if_.rs +++ b/src/new/nto/net/if_.rs @@ -1,5 +1,31 @@ use crate::prelude::*; +// `s_no_extra_traits` produces an `impl` block so the `#[cfg]` attribute needs +// to go *outside* the macro +#[cfg(target_os = "nto")] +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_space: crate::sockaddr_storage, + pub ifru_flags: c_short, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_dlt: c_int, + pub ifru_value: c_uint, + pub ifru_data: *mut c_char, + pub ifru_b: __c_anonymous_ifru_b, + pub ifru_fibmask: c_int, + } + + pub struct __c_anonymous_ifru_b { + pub b_buflen: u32, + pub b_buf: *mut c_void, + } +} + +#[cfg(target_os = "qnx")] s_no_extra_traits! { pub union __c_anonymous_ifr_ifru { pub ifru_addr: crate::sockaddr, @@ -17,16 +43,25 @@ s_no_extra_traits! { pub ifru_cap: [c_int; 2], pub ifru_fib: c_uint, pub ifru_vlan_pcp: c_uchar, + pub ifru_nv: ifreq_nv_req, + } + + pub struct ifreq_buffer { + pub length: size_t, + pub buffer: *mut c_void, + } + + pub struct ifreq_nv_req { + pub buf_length: c_uint, + pub length: c_uint, + pub buffer: *mut c_void, } +} +s_no_extra_traits! { pub struct ifreq { /// if name, e.g. "en0" pub ifr_name: [c_char; crate::IFNAMSIZ], pub ifr_ifru: __c_anonymous_ifr_ifru, } - - pub struct ifreq_buffer { - pub length: size_t, - pub buffer: *mut c_void, - } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index eac685243b917..9b49d285d25ed 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -81,6 +81,8 @@ pub type posix_spawnattr_t = crate::uintptr_t; pub type pthread_mutex_t = crate::sync_t; pub type pthread_mutexattr_t = crate::_sync_attr; +#[cfg(target_os = "qnx")] +pub type pthread_rwlock_t = crate::sync_t; pub type pthread_cond_t = crate::sync_t; pub type pthread_condattr_t = crate::_sync_attr; pub type pthread_rwlockattr_t = crate::_sync_attr; @@ -282,7 +284,7 @@ s! { pub gl_pathv: *mut *mut c_char, pub gl_offs: size_t, pub gl_flags: c_int, - pub gl_errfunc: extern "C" fn(*const c_char, c_int) -> c_int, + pub gl_errfunc: Option c_int>, __unused1: Padding<*mut c_void>, __unused2: Padding<*mut c_void>, @@ -458,6 +460,7 @@ s! { pub c_ospeed: crate::speed_t, } + #[cfg(target_os = "nto")] pub struct mallinfo { pub arena: c_int, pub ordblks: c_int, @@ -471,6 +474,20 @@ s! { pub keepcost: c_int, } + #[cfg(target_os = "qnx")] + pub struct mallinfo { + pub arena: size_t, + pub ordblks: size_t, + pub smblks: size_t, + pub hblks: size_t, + pub hblkhd: size_t, + pub usmblks: size_t, + pub fsmblks: size_t, + pub uordblks: size_t, + pub fordblks: size_t, + pub keepcost: size_t, + } + pub struct flock { pub l_type: i16, pub l_whence: i16, @@ -542,6 +559,7 @@ s! { } // FIXME(1.0): This should not implement `PartialEq` + #[cfg(target_os = "nto")] #[allow(unpredictable_function_pointer_comparisons)] pub struct _thread_attr { pub __flags: c_int, @@ -552,7 +570,22 @@ s! { pub __param: crate::__sched_param, pub __guardsize: c_uint, pub __prealloc: c_uint, - __spare: [c_int; 2], + __spare: Padding<[c_int; 2]>, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[cfg(target_os = "qnx")] + #[allow(unpredictable_function_pointer_comparisons)] + pub struct _thread_attr { + pub __flags: c_int, + pub __stacksize: size_t, + pub __stackaddr: *mut c_void, + __reserved0: Padding, + pub __policy: c_int, + pub __param: crate::__sched_param, + pub __guardsize: c_uint, + pub __prealloc: c_uint, + __reserved1: Padding, } pub struct _sync_attr { @@ -655,7 +688,10 @@ s! { } pub struct sigset_t { + #[cfg(target_os = "nto")] __val: [u32; 2], + #[cfg(target_os = "qnx")] // different alignment + __val: u64, } pub struct mq_attr { @@ -702,10 +738,14 @@ s_no_extra_traits! { #[repr(align(4))] pub struct pthread_barrier_t { - // union + #[cfg(target_os = "qnx")] + __pad: Padding<[u8; 8]>, // union + #[cfg(target_os = "nto")] __pad: Padding<[u8; 28]>, // union } + // `target_os = "qnx"` is handled by a `type` alias + #[cfg(target_os = "nto")] pub struct pthread_rwlock_t { pub __active: c_int, pub __blockedwriters: c_int, @@ -1048,7 +1088,7 @@ pub const POLLRDBAND: c_short = 0x0004; pub const IPTOS_LOWDELAY: u8 = 0x10; pub const IPTOS_THROUGHPUT: u8 = 0x08; pub const IPTOS_RELIABILITY: u8 = 0x04; -pub const IPTOS_MINCOST: u8 = 0x02; +pub const IPTOS_MINCOST: u8 = if cfg!(target_os = "nto") { 0x02 } else { 0x00 }; pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; @@ -1218,11 +1258,27 @@ pub const IN_MOVE_SELF: u32 = 0x00000800; pub const IN_UNMOUNT: u32 = 0x00002000; pub const IN_Q_OVERFLOW: u32 = 0x00004000; pub const IN_IGNORED: u32 = 0x00008000; -pub const IN_ONLYDIR: u32 = 0x01000000; -pub const IN_DONT_FOLLOW: u32 = 0x02000000; +pub const IN_ONLYDIR: u32 = if cfg!(target_os = "nto") { + 0x01000000 +} else { + 0x00400000 +}; +pub const IN_DONT_FOLLOW: u32 = if cfg!(target_os = "nto") { + 0x02000000 +} else { + 0x00100000 +}; -pub const IN_ISDIR: u32 = 0x40000000; -pub const IN_ONESHOT: u32 = 0x80000000; +pub const IN_ISDIR: u32 = if cfg!(target_os = "nto") { + 0x40000000 +} else { + 0x00010000 +}; +pub const IN_ONESHOT: u32 = if cfg!(target_os = "nto") { + 0x80000000 +} else { + 0x00800000 +}; pub const REG_EXTENDED: c_int = 0o0001; pub const REG_ICASE: c_int = 0o0002; @@ -1656,9 +1712,10 @@ pub const ENOTSUP: c_int = 48; pub const BUFSIZ: c_uint = 1024; pub const TMP_MAX: c_uint = 26 * 26 * 26; pub const FOPEN_MAX: c_uint = 16; -pub const FILENAME_MAX: c_uint = 255; +pub const FILENAME_MAX: c_uint = if cfg!(target_os = "nto") { 255 } else { 1024 }; pub const NI_MAXHOST: crate::socklen_t = 1025; +#[cfg(target_os = "nto")] // removed in QNX8 pub const M_KEEP: c_int = 4; pub const REG_STARTEND: c_int = 0o00004; pub const VEOF: usize = 4; @@ -1994,6 +2051,7 @@ pub const KERN_PROF: c_int = 16; pub const KERN_SAVED_IDS: c_int = 20; pub const KERN_SECURELVL: c_int = 9; pub const KERN_VERSION: c_int = 4; +#[cfg(target_os = "nto")] // removed in QNX8 pub const KERN_VNODE: c_int = 13; pub const LC_ALL: c_int = 63; @@ -2005,8 +2063,11 @@ pub const LC_NUMERIC: c_int = 8; pub const LC_TIME: c_int = 16; pub const MAP_STACK: c_int = 0x00001000; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const MNT_NOEXEC: c_int = 0x02; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const MNT_NOSUID: c_int = 0x04; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const MNT_RDONLY: c_int = 0x01; pub const NET_RT_DUMP: c_int = 1; @@ -2073,11 +2134,11 @@ pub const RLIMIT_RSS: c_int = 6; pub const RLIMIT_STACK: c_int = 3; pub const RLIMIT_VMEM: c_int = 6; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] -pub const RLIM_NLIMITS: c_int = 14; +pub const RLIM_NLIMITS: c_int = if cfg!(target_os = "nto") { 14 } else { 19 }; pub const SCHED_ADJTOHEAD: c_int = 5; pub const SCHED_ADJTOTAIL: c_int = 6; -pub const SCHED_MAXPOLICY: c_int = 7; +pub const SCHED_MAXPOLICY: c_int = if cfg!(target_os = "nto") { 7 } else { 9 }; pub const SCHED_SETPRIO: c_int = 7; pub const SCHED_SPORADIC: c_int = 4; @@ -2086,8 +2147,8 @@ pub const SIGCLD: c_int = SIGCHLD; pub const SIGDEADLK: c_int = 7; pub const SIGEMT: c_int = 7; pub const SIGEV_NONE: c_int = 0; -pub const SIGEV_SIGNAL: c_int = 129; -pub const SIGEV_THREAD: c_int = 135; +pub const SIGEV_SIGNAL: c_int = if cfg!(target_os = "nto") { 129 } else { 1 }; +pub const SIGEV_THREAD: c_int = if cfg!(target_os = "nto") { 135 } else { 7 }; pub const SO_USELOOPBACK: c_int = 0x0040; pub const _SS_ALIGNSIZE: usize = size_of::(); pub const _SS_MAXSIZE: usize = 128; @@ -2211,7 +2272,11 @@ pub const PTHREAD_CREATE_DETACHED: c_int = 0x01; pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; pub const PTHREAD_MUTEX_NORMAL: c_int = 3; -pub const PTHREAD_STACK_MIN: size_t = 256; +pub const PTHREAD_STACK_MIN: size_t = if cfg!(target_os = "nto") { + 256 +} else { + 4 * 1024 +}; pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; pub const PTHREAD_MUTEX_STALLED: c_int = 0x00; pub const PTHREAD_MUTEX_ROBUST: c_int = 0x10; @@ -2239,6 +2304,7 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __u: CLOCK_REALTIME as u32, __owner: 0xfffffffb, }; +#[cfg(target_os = "nto")] pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __active: 0, __blockedwriters: 0, @@ -2250,6 +2316,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __owner: -2i32 as c_uint, __spare: 0, }; +#[cfg(target_os = "qnx")] +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __u: 0, __owner: 0 }; const fn _CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) @@ -2398,6 +2466,8 @@ f! { // In QNX <=7.0, libregex functions were included in libc itself. #[link(name = "socket")] #[cfg_attr(not(target_env = "nto70"), link(name = "regex"))] +// `inotify_*` functions are provided by `fsnotify` on QNX 8.0 +#[cfg_attr(target_os = "qnx", link(name = "fsnotify"))] extern "C" { pub fn sem_destroy(sem: *mut sem_t) -> c_int; pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; @@ -2826,12 +2896,12 @@ extern "C" { pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; pub fn sysctl( - _: *const c_int, - _: c_uint, - _: *mut c_void, - _: *mut size_t, - _: *const c_void, - _: size_t, + name: *const c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *const c_void, + newlen: size_t, ) -> c_int; pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; diff --git a/src/unix/nto/neutrino.rs b/src/unix/nto/neutrino.rs index f360605d1902e..00793f0b8c9d7 100644 --- a/src/unix/nto/neutrino.rs +++ b/src/unix/nto/neutrino.rs @@ -172,6 +172,7 @@ s! { pub tick_nsec_inc: i32, } + #[cfg(target_os = "nto")] pub struct qtime_entry { pub cycles_per_sec: u64, pub nsec_tod_adjust: u64, // volatile @@ -193,6 +194,25 @@ s! { spare: [u32; 7], } + #[cfg(target_os = "qnx")] + pub struct qtime_entry { + pub cycles_per_sec: u64, + pub nsec_tod_adjust: u64, // volatile + pub nsec_inc: u32, + pub boot_time: u32, + pub adjust: _clockadjust, + pub timer_period: u32, + pub timer_scale: i32, + pub intr: i32, + pub epoch: u32, + pub flags: u32, + pub rr_interval_mul: u32, + pub timer_load_max: u64, + pub boot_cc: u64, + pub tick_period_cc: u64, + spare: Padding<[u64; 3]>, + } + pub struct _sched_info { pub priority_min: c_int, pub priority_max: c_int, @@ -219,6 +239,7 @@ s! { } s_no_extra_traits! { + #[cfg(target_os = "nto")] #[repr(align(8))] pub struct syspage_entry { pub size: u16, @@ -241,13 +262,37 @@ s_no_extra_traits! { pub pminfo: syspage_entry_info, pub old_mdriver: syspage_entry_info, spare0: [u32; 1], - __reserved: Padding<[u8; 160]>, // anonymous union with architecture dependent structs + __reserved: Padding<[u64; 20]>, // anonymous union with architecture dependent structs pub new_asinfo: syspage_array_info, pub new_cpuinfo: syspage_array_info, pub new_cacheattr: syspage_array_info, pub new_intrinfo: syspage_array_info, pub new_mdriver: syspage_array_info, } + + #[cfg(target_os = "qnx")] + #[repr(align(8))] + pub struct syspage_entry { + pub size: u16, + pub total_size: u16, + pub type_: u16, + pub num_cpu: u16, + pub system_private: syspage_entry_info, + version: [u16; 2], // inline struct + pub hwinfo: syspage_entry_info, + pub qtime: syspage_entry_info, + pub callout: syspage_entry_info, + pub typed_strings: syspage_entry_info, + pub strings: syspage_entry_info, + pub smp: syspage_entry_info, + __reserved: Padding<[u64; 20]>, // anonymous union with architecture dependent structs + pub asinfo: syspage_array_info, + pub cpuinfo: syspage_array_info, + pub cacheattr: syspage_array_info, + pub intrinfo: syspage_array_info, + pub hypinfo: syspage_entry_info, + pub cluster: syspage_array_info, + } } pub const SYSMGR_PID: u32 = 1; @@ -262,7 +307,9 @@ pub const STATE_STOPPED: c_int = 0x03; pub const STATE_SEND: c_int = 0x04; pub const STATE_RECEIVE: c_int = 0x05; pub const STATE_REPLY: c_int = 0x06; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_STACK: c_int = 0x07; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_WAITTHREAD: c_int = 0x08; pub const STATE_WAITPAGE: c_int = 0x09; pub const STATE_SIGSUSPEND: c_int = 0x0a; @@ -274,9 +321,14 @@ pub const STATE_JOIN: c_int = 0x0f; pub const STATE_INTR: c_int = 0x10; pub const STATE_SEM: c_int = 0x11; pub const STATE_WAITCTX: c_int = 0x12; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_NET_SEND: c_int = 0x13; +#[cfg(target_os = "nto")] // removed in QNX8 pub const STATE_NET_REPLY: c_int = 0x14; +#[cfg(target_os = "nto")] pub const STATE_MAX: c_int = 0x18; +#[cfg(target_os = "qnx")] +pub const STATE_MAX: c_int = 63; pub const _NTO_TIMEOUT_RECEIVE: i32 = 1 << STATE_RECEIVE; pub const _NTO_TIMEOUT_SEND: i32 = 1 << STATE_SEND; @@ -294,10 +346,12 @@ pub const _NTO_MI_ENDIAN_BIG: u32 = 1; pub const _NTO_MI_ENDIAN_DIFF: u32 = 2; pub const _NTO_MI_UNBLOCK_REQ: u32 = 256; pub const _NTO_MI_NET_CRED_DIRTY: u32 = 512; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const _NTO_MI_CONSTRAINED: u32 = 1024; pub const _NTO_MI_CHROOT: u32 = 2048; pub const _NTO_MI_BITS_64: u32 = 4096; pub const _NTO_MI_BITS_DIFF: u32 = 8192; +#[cfg(target_os = "nto")] // private (`/devs/sys/*.h`) in QNX8 pub const _NTO_MI_SANDBOX: u32 = 16384; pub const _NTO_CI_ENDIAN_BIG: u32 = 1; @@ -307,7 +361,9 @@ pub const _NTO_CI_STOPPED: u32 = 128; pub const _NTO_CI_UNABLE: u32 = 256; pub const _NTO_CI_TYPE_ID: u32 = 512; pub const _NTO_CI_CHROOT: u32 = 2048; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CI_BITS_64: u32 = 4096; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CI_SANDBOX: u32 = 16384; pub const _NTO_CI_LOADER: u32 = 32768; pub const _NTO_CI_FULL_GROUPS: u32 = 2147483648; @@ -351,6 +407,7 @@ pub const _NTO_PF_TERMING: u32 = 4; pub const _NTO_PF_ZOMBIE: u32 = 8; pub const _NTO_PF_NOZOMBIE: u32 = 16; pub const _NTO_PF_FORKED: u32 = 32; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_ORPHAN_PGRP: u32 = 64; pub const _NTO_PF_STOPPED: u32 = 128; pub const _NTO_PF_DEBUG_STOPPED: u32 = 256; @@ -359,33 +416,50 @@ pub const _NTO_PF_NOISYNC: u32 = 1024; pub const _NTO_PF_CONTINUED: u32 = 2048; pub const _NTO_PF_CHECK_INTR: u32 = 4096; pub const _NTO_PF_COREDUMP: u32 = 8192; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_RING0: u32 = 32768; pub const _NTO_PF_SLEADER: u32 = 65536; pub const _NTO_PF_WAITINFO: u32 = 131072; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_DESTROYALL: u32 = 524288; pub const _NTO_PF_NOCOREDUMP: u32 = 1048576; pub const _NTO_PF_WAITDONE: u32 = 4194304; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_TERM_WAITING: u32 = 8388608; pub const _NTO_PF_ASLR: u32 = 16777216; pub const _NTO_PF_EXECED: u32 = 33554432; pub const _NTO_PF_APP_STOPPED: u32 = 67108864; pub const _NTO_PF_64BIT: u32 = 134217728; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_NET: u32 = 268435456; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_PF_NOLAZYSTACK: u32 = 536870912; pub const _NTO_PF_NOEXEC_STACK: u32 = 1073741824; pub const _NTO_PF_LOADER_PERMS: u32 = 2147483648; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_INTR_PENDING: u32 = 65536; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_DETACHED: u32 = 131072; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_SHR_MUTEX: u32 = 262144; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_SHR_MUTEX_EUID: u32 = 524288; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_THREADS_HOLD: u32 = 1048576; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_UNBLOCK_REQ: u32 = 4194304; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_ALIGN_FAULT: u32 = 16777216; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_SSTEP: u32 = 33554432; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_ALLOCED_STACK: u32 = 67108864; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_NOMULTISIG: u32 = 134217728; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_LOW_LATENCY: u32 = 268435456; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TF_IOPRIV: u32 = 2147483648; pub const _NTO_TCTL_IO_PRIV: u32 = 1; @@ -394,15 +468,20 @@ pub const _NTO_TCTL_THREADS_CONT: u32 = 3; pub const _NTO_TCTL_RUNMASK: u32 = 4; pub const _NTO_TCTL_ALIGN_FAULT: u32 = 5; pub const _NTO_TCTL_RUNMASK_GET_AND_SET: u32 = 6; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_PERFCOUNT: u32 = 7; pub const _NTO_TCTL_ONE_THREAD_HOLD: u32 = 8; pub const _NTO_TCTL_ONE_THREAD_CONT: u32 = 9; pub const _NTO_TCTL_RUNMASK_GET_AND_SET_INHERIT: u32 = 10; pub const _NTO_TCTL_NAME: u32 = 11; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_RCM_GET_AND_SET: u32 = 12; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_SHR_MUTEX: u32 = 13; pub const _NTO_TCTL_IO: u32 = 14; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_NET_KIF_GET_AND_SET: u32 = 15; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TCTL_LOW_LATENCY: u32 = 16; pub const _NTO_TCTL_ADD_EXIT_EVENT: u32 = 17; pub const _NTO_TCTL_DEL_EXIT_EVENT: u32 = 18; @@ -424,7 +503,9 @@ pub const _NTO_CHF_SENDER_LEN: u32 = 32; pub const _NTO_CHF_COID_DISCONNECT: u32 = 64; pub const _NTO_CHF_REPLY_LEN: u32 = 128; pub const _NTO_CHF_PULSE_POOL: u32 = 256; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CHF_ASYNC_NONBLOCK: u32 = 512; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_CHF_ASYNC: u32 = 1024; pub const _NTO_CHF_GLOBAL: u32 = 2048; pub const _NTO_CHF_PRIVATE: u32 = 4096; @@ -437,13 +518,19 @@ pub const _NTO_CHO_CUSTOM_EVENT: u32 = 1; pub const _NTO_COF_CLOEXEC: u32 = 1; pub const _NTO_COF_DEAD: u32 = 2; pub const _NTO_COF_NOSHARE: u32 = 64; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_NETCON: u32 = 128; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_NONBLOCK: u32 = 256; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_ASYNC: u32 = 512; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_GLOBAL: u32 = 1024; pub const _NTO_COF_NOEVENT: u32 = 2048; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_INSECURE: u32 = 4096; pub const _NTO_COF_REG_EVENTS: u32 = 8192; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_COF_UNREG_EVENTS: u32 = 16384; pub const _NTO_COF_MASK: u32 = 65535; @@ -452,8 +539,18 @@ pub const _NTO_SIDE_CHANNEL: u32 = 1073741824; pub const _NTO_CONNECTION_SCOID: u32 = 65536; pub const _NTO_GLOBAL_CHANNEL: u32 = 1073741824; -pub const _NTO_TIMEOUT_MASK: u32 = (1 << STATE_MAX) - 1; -pub const _NTO_TIMEOUT_ACTIVE: u32 = 1 << STATE_MAX; +const STATE_TIMEOUT_MAX: u8 = 24; +pub const _NTO_TIMEOUT_MASK: u32 = if cfg!(target_os = "nto") { + (1 << STATE_MAX) - 1 +} else { + (1 << STATE_TIMEOUT_MAX) - 1 +}; +pub const _NTO_TIMEOUT_ACTIVE: u32 = if cfg!(target_os = "nto") { + 1 << STATE_MAX +} else { + 1 << STATE_TIMEOUT_MAX +}; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_TIMEOUT_IMMEDIATE: u32 = 1 << (STATE_MAX + 1); pub const _NTO_IC_LATENCY: u32 = 0; @@ -476,31 +573,54 @@ pub const _NTO_HOOK_OVERDRIVE: u32 = 2147418114; pub const _NTO_HOOK_LAST: u32 = 2147418114; pub const _NTO_HOOK_IDLE2_FLAG: u32 = 32768; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_SETUP: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_BLOCK: u32 = 2; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_WAKEUP: u32 = 4; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_CMD_SLEEP_ONLINE: u32 = 8; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_NEEDS_BLOCK: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_NEEDS_WAKEUP: u32 = 2; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_NEEDS_ONLINE: u32 = 4; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SYNC_TIME: u32 = 16; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SYNC_TLB: u32 = 32; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SUGGEST_OFFLINE: u32 = 256; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_SLEEP_MODE_REACHED: u32 = 512; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_IH_RESP_DELIVER_INTRS: u32 = 1024; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_READIOV_SEND: u32 = 0; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_READIOV_REPLY: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_VTID: u32 = 2147483648; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN: u32 = 32768; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_OP_MASK: u32 = 255; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_VERIFY: u32 = 0; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_CALCULATE: u32 = 1; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_CALCULATE_REUSE: u32 = 2; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN_VERIFY: u32 = 32768; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN_CALCULATE: u32 = 32769; +#[cfg(target_os = "nto")] // removed in QNX8 pub const _NTO_KEYDATA_PATHSIGN_CALCULATE_REUSE: u32 = 32770; pub const _NTO_SCTL_SETPRIOCEILING: u32 = 1; @@ -517,6 +637,7 @@ extern "C" { pub fn ChannelCreate(__flags: c_uint) -> c_int; pub fn ChannelCreate_r(__flags: c_uint) -> c_int; pub fn ChannelCreatePulsePool(__flags: c_uint, __config: *const nto_channel_config) -> c_int; + #[cfg(target_os = "nto")] pub fn ChannelCreateExt( __flags: c_uint, __mode: crate::mode_t, @@ -763,12 +884,14 @@ extern "C" { __bytes: usize, __info: *mut _msg_info64, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceivePulsev( __chid: c_int, __iov: *const crate::iovec, __parts: usize, __info: *mut _msg_info64, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceivePulsev_r( __chid: c_int, __iov: *const crate::iovec, @@ -799,6 +922,7 @@ extern "C" { __iov: *const crate::iovec, __parts: usize, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReadiov( __rcvid: c_int, __iov: *const crate::iovec, @@ -806,6 +930,7 @@ extern "C" { __offset: usize, __flags: c_int, ) -> isize; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReadiov_r( __rcvid: c_int, __iov: *const crate::iovec, @@ -872,6 +997,7 @@ extern "C" { pub fn MsgUnregisterEvent_r(__event: *const crate::sigevent) -> c_int; pub fn MsgInfo(__rcvid: c_int, __info: *mut _msg_info64) -> c_int; pub fn MsgInfo_r(__rcvid: c_int, __info: *mut _msg_info64) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgKeyData( __rcvid: c_int, __oper: c_int, @@ -880,6 +1006,7 @@ extern "C" { __iov: *const crate::iovec, __parts: c_int, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgKeyData_r( __rcvid: c_int, __oper: c_int, @@ -892,13 +1019,16 @@ extern "C" { pub fn MsgError_r(__rcvid: c_int, __err: c_int) -> c_int; pub fn MsgCurrent(__rcvid: c_int) -> c_int; pub fn MsgCurrent_r(__rcvid: c_int) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgSendAsyncGbl( __coid: c_int, __smsg: *const c_void, __sbytes: usize, __msg_prio: c_uint, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgSendAsync(__coid: c_int) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceiveAsyncGbl( __chid: c_int, __rmsg: *mut c_void, @@ -906,6 +1036,7 @@ extern "C" { __info: *mut _msg_info64, __coid: c_int, ) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn MsgReceiveAsync(__chid: c_int, __iov: *const crate::iovec, __parts: c_uint) -> c_int; pub fn MsgPause(__rcvid: c_int, __cookie: c_uint) -> c_int; pub fn MsgPause_r(__rcvid: c_int, __cookie: c_uint) -> c_int; @@ -943,6 +1074,7 @@ extern "C" { __value: *const crate::sigval, ) -> c_int; pub fn SignalReturn(__info: *mut _sighandler_info) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn SignalFault(__sigcode: c_uint, __regs: *mut c_void, __refaddr: usize) -> c_int; pub fn SignalAction( __pid: crate::pid_t, @@ -1087,12 +1219,14 @@ extern "C" { pub fn InterruptDetach_r(__id: c_int) -> c_int; pub fn InterruptWait(__flags: c_int, __timeout: *const u64) -> c_int; pub fn InterruptWait_r(__flags: c_int, __timeout: *const u64) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn InterruptCharacteristic( __type: c_int, __id: c_int, __new: *mut c_uint, __old: *mut c_uint, ) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn InterruptCharacteristic_r( __type: c_int, __id: c_int, @@ -1134,12 +1268,14 @@ extern "C" { pub fn SchedJobCreate_r(__job: *mut nto_job_t) -> c_int; pub fn SchedJobDestroy(__job: *mut nto_job_t) -> c_int; pub fn SchedJobDestroy_r(__job: *mut nto_job_t) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn SchedWaypoint( __job: *mut nto_job_t, __new: *const i64, __max: *const i64, __old: *mut i64, ) -> c_int; + #[cfg(target_os = "nto")] // declaration exists but symbol was removed in QNX8 pub fn SchedWaypoint_r( __job: *mut nto_job_t, __new: *const i64, @@ -1220,7 +1356,9 @@ extern "C" { pub fn SyncMutexLock_r(__sync: *mut crate::sync_t) -> c_int; pub fn SyncMutexUnlock(__sync: *mut crate::sync_t) -> c_int; pub fn SyncMutexUnlock_r(__sync: *mut crate::sync_t) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn SyncMutexRevive(__sync: *mut crate::sync_t) -> c_int; + #[cfg(target_os = "nto")] // removed in QNX8 pub fn SyncMutexRevive_r(__sync: *mut crate::sync_t) -> c_int; pub fn SyncCondvarWait(__sync: *mut crate::sync_t, __mutex: *mut crate::sync_t) -> c_int; pub fn SyncCondvarWait_r(__sync: *mut crate::sync_t, __mutex: *mut crate::sync_t) -> c_int; From b56c23e75924d6773c703a6e20eea19524678d7e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 28 Jul 2026 15:33:33 +0200 Subject: [PATCH 02/88] add semver files for QNX these are based on `unix.txt` without the API not present on QNX note that `qnx.txt` has extra API that is not present in `nto.txt`, like `SA_ONSTACK` and `cfsetspeed` with this change the entirity of `libc-test`'s tests pass on QNX targets (backport ) (cherry picked from commit e27c7f1e2b281d7c551e6b394b897b4ff0a230e6) --- libc-test/build/semver.rs | 7 +- libc-test/semver/nto.txt | 886 +++++++++++++++++++++++++++++++++++++ libc-test/semver/qnx.txt | 888 ++++++++++++++++++++++++++++++++++++++ src/unix/nto/mod.rs | 2 + 4 files changed, 1781 insertions(+), 2 deletions(-) create mode 100644 libc-test/semver/nto.txt create mode 100644 libc-test/semver/qnx.txt diff --git a/libc-test/build/semver.rs b/libc-test/build/semver.rs index e5339fe4faee5..a9b1b66ad5577 100644 --- a/libc-test/build/semver.rs +++ b/libc-test/build/semver.rs @@ -33,10 +33,13 @@ pub(crate) fn do_semver() { // NOTE: Android doesn't include the unix file (or the Linux file) because // there are some many definitions missing it's actually easier just to // maintain a file for Android. - // NOTE: AIX and L4Re do not include the unix file because there are + // NOTE: AIX, L4Re and QNX do not include the unix file because there are // definitions missing on these systems. It is easier to maintain separate // files for them. - if family != os && !matches!(os.as_str(), "android" | "aix" | "l4re") && os != "vxworks" { + if family != os + && !matches!(os.as_str(), "android" | "aix" | "l4re" | "nto" | "qnx") + && os != "vxworks" + { process_semver_file(&mut output, &mut semver_root, &family); } // We don't do semver for unknown targets. diff --git a/libc-test/semver/nto.txt b/libc-test/semver/nto.txt new file mode 100644 index 0000000000000..4fe337edf2b12 --- /dev/null +++ b/libc-test/semver/nto.txt @@ -0,0 +1,886 @@ +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +B0 +B110 +B115200 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B2400 +B300 +B38400 +B4800 +B50 +B57600 +B600 +B75 +B9600 +BRKINT +CLOCAL +CLOCK_MONOTONIC +CLOCK_REALTIME +CREAD +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTOPB +DIR +Dl_info +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOE +ECHOK +ECHONL +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +ELOOP +EMFILE +EMLINK +EMSGSIZE +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSYS +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTTY +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EROFS +ESHUTDOWN +ESPIPE +ESRCH +ESTALE +ETIMEDOUT +ETXTBSY +EWOULDBLOCK +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +FD_CLOEXEC +FD_CLR +FD_ISSET +FD_SET +FD_SETSIZE +FD_ZERO +FILE +FIOCLEX +FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_OK +F_SETFD +F_SETFL +F_SETLK +F_SETLKW +HUPCL +ICANON +ICRNL +IEXTEN +IFNAMSIZ +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INLCR +INPCK +INT_MAX +INT_MIN +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_TCP +IPPROTO_UDP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +ISIG +ISTRIP +IXANY +IXOFF +IXON +LOG_ALERT +LOG_AUTH +LOG_CONS +LOG_CRIT +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NI_MAXHOST +NOFLSH +OCRNL +ONLCR +ONLRET +ONOCR +OPOST +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_DIRECTORY +O_EXCL +O_NOFOLLOW +O_NONBLOCK +O_RDONLY +O_RDWR +O_TRUNC +O_WRONLY +PARENB +PARMRK +PARODD +PATH_MAX +PF_INET +PF_INET6 +PF_UNIX +PF_UNSPEC +POLLERR +POLLHUP +POLLIN +POLLNVAL +POLLOUT +POLLPRI +PRIO_PGRP +PRIO_PROCESS +PRIO_USER +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PTHREAD_COND_INITIALIZER +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_RWLOCK_INITIALIZER +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_NOW +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_RESETHAND +SA_SIGINFO +SEEK_CUR +SEEK_END +SEEK_SET +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGIOT +SIGKILL +SIGPIPE +SIGPROF +SIGQUIT +SIGSEGV +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SOCK_DGRAM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SO_ACCEPTCONN +SO_BROADCAST +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_LINGER +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TYPE +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TCIFLUSH +TCIOFF +TCIOFLUSH +TCION +TCOFLUSH +TCOOFF +TCOON +TCP_NODELAY +TCSADRAIN +TCSAFLUSH +TCSANOW +TIOCGWINSZ +TIOCSWINSZ +TOSTOP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VMIN +VQUIT +VSTART +VSTOP +VSUSP +VTIME +WCONTINUED +WCOREDUMP +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +X_OK +_PC_CHOWN_RESTRICTED +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_VDISABLE +_SC_ARG_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_HOST_NAME_MAX +_SC_NGROUPS_MAX +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_TTY_NAME_MAX +_SC_TZNAME_MAX +_SC_VERSION +_exit +abort +accept +access +addrinfo +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +bind +blkcnt_t +blksize_t +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +chdir +chmod +chown +clock_gettime +clock_t +clockid_t +close +closedir +closelog +confstr +connect +creat +dev_t +dirent +dladdr +dlclose +dlerror +dlopen +dlsym +dup +dup2 +execl +execle +execlp +execv +execve +execvp +exit +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fd_set +fdopen +feof +ferror +fflush +fgetc +fgetpos +fgets +fileno +flock +fnmatch +fopen +fork +fpathconf +fpos_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freopen +fsblkcnt_t +fscanf +fseek +fseeko +fsetpos +fsfilcnt_t +fstat +fstatat +fstatvfs +fsync +ftell +ftello +ftruncate +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcwd +getegid +getenv +geteuid +getgid +getgroups +gethostname +getlogin +getopt +getpeername +getpgid +getpgrp +getpid +getppid +getprotobyname +getprotobynumber +getpwnam +getpwuid +getservbyname +getsockname +getsockopt +gettimeofday +getuid +gid_t +gmtime +gmtime_r +grantpt +group +hostent +hstrerror +htonl +htons +if_indextoname +if_nametoindex +in6_addr +in6addr_any +in6addr_loopback +in_addr +in_addr_t +in_port_t +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +itimerval +kill +lchown +lconv +linger +link +linkat +listen +locale_t +localeconv +localtime +localtime_r +lseek +lstat +malloc +memccpy +memchr +memcmp +memcpy +memmove +memset +mkdir +mkdtemp +mkfifo +mknod +mkstemp +mktime +mlock +mlockall +mmap +mode_t +mprotect +msync +munlock +munlockall +munmap +nanosleep +nfds_t +nlink_t +ntohl +ntohs +off_t +open +opendir +openlog +passwd +pathconf +pclose +perror +pid_t +pipe +poll +pollfd +posix_memalign +posix_openpt +pread +printf +protoent +pselect +pthread_attr_destroy +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_attr_t +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_init +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_t +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_init +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_init +pthread_rwlockattr_t +pthread_self +pthread_setspecific +pthread_t +ptrdiff_t +ptsname +putchar +putchar_unlocked +putenv +puts +pwrite +raise +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +remove +rename +renameat +res_init +rewind +rewinddir +rlim_t +rlimit +rmdir +rusage +sa_family_t +scanf +sched_yield +select +sem_post +sem_t +sem_trywait +sem_wait +send +sendto +servent +setbuf +setegid +setenv +seteuid +setgid +setlocale +setlogmask +setpgid +setregid +setreuid +setsid +setsockopt +setuid +setvbuf +shm_open +shm_unlink +shutdown +sigaction +sigaddset +sigdelset +sigemptyset +sigfillset +sighandler_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigval +size_t +sleep +snprintf +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socketpair +socklen_t +speed_t +sprintf +sscanf +ssize_t +stat +statvfs +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strlen +strncat +strncmp +strncpy +strnlen +strpbrk +strrchr +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +symlink +symlinkat +sysconf +syslog +system +tcdrain +tcflag_t +tcflow +tcflush +tcgetattr +tcgetpgrp +tcgetsid +tcsendbreak +tcsetattr +tcsetpgrp +termios +time +time_t +timegm +times +timespec +timeval +timezone +tm +tmpfile +tmpnam +tms +tolower +toupper +ttyname +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +umask +uname +ungetc +unlink +unlinkat +unlockpt +unsetenv +usleep +utimbuf +utime +utimes +utsname +wait +waitpid +wchar_t +wcslen +wcstombs +winsize +wmemchr +write +writev diff --git a/libc-test/semver/qnx.txt b/libc-test/semver/qnx.txt new file mode 100644 index 0000000000000..955f6fba9bffe --- /dev/null +++ b/libc-test/semver/qnx.txt @@ -0,0 +1,888 @@ +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +B0 +B110 +B115200 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B2400 +B300 +B38400 +B4800 +B50 +B57600 +B600 +B75 +B9600 +BRKINT +CLOCAL +CLOCK_MONOTONIC +CLOCK_REALTIME +CREAD +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTOPB +DIR +Dl_info +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOE +ECHOK +ECHONL +ECONNABORTED +ECONNREFUSED +ECONNRESET +EDEADLK +EDESTADDRREQ +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +ELOOP +EMFILE +EMLINK +EMSGSIZE +ENAMETOOLONG +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOBUFS +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSYS +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTSOCK +ENOTTY +ENXIO +EOPNOTSUPP +EOVERFLOW +EPERM +EPFNOSUPPORT +EPIPE +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERANGE +EROFS +ESHUTDOWN +ESPIPE +ESRCH +ESTALE +ETIMEDOUT +ETXTBSY +EWOULDBLOCK +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +FD_CLOEXEC +FD_CLR +FD_ISSET +FD_SET +FD_SETSIZE +FD_ZERO +FILE +FIOCLEX +FIONBIO +FNM_CASEFOLD +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_OK +F_SETFD +F_SETFL +F_SETLK +F_SETLKW +HUPCL +ICANON +ICRNL +IEXTEN +IFNAMSIZ +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INLCR +INPCK +INT_MAX +INT_MIN +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_TCP +IPPROTO_UDP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +ISIG +ISTRIP +IXANY +IXOFF +IXON +LOG_ALERT +LOG_AUTH +LOG_CONS +LOG_CRIT +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NI_MAXHOST +NOFLSH +OCRNL +ONLCR +ONLRET +ONOCR +OPOST +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_DIRECTORY +O_EXCL +O_NOFOLLOW +O_NONBLOCK +O_RDONLY +O_RDWR +O_TRUNC +O_WRONLY +PARENB +PARMRK +PARODD +PATH_MAX +PF_INET +PF_INET6 +PF_UNIX +PF_UNSPEC +POLLERR +POLLHUP +POLLIN +POLLNVAL +POLLOUT +POLLPRI +PRIO_PGRP +PRIO_PROCESS +PRIO_USER +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PTHREAD_COND_INITIALIZER +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_RWLOCK_INITIALIZER +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_NOW +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_ONSTACK +SA_RESETHAND +SA_SIGINFO +SEEK_CUR +SEEK_END +SEEK_SET +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCONT +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGIOT +SIGKILL +SIGPIPE +SIGPROF +SIGQUIT +SIGSEGV +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SOCK_DGRAM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SO_ACCEPTCONN +SO_BROADCAST +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_LINGER +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TYPE +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TCIFLUSH +TCIOFF +TCIOFLUSH +TCION +TCOFLUSH +TCOOFF +TCOON +TCP_NODELAY +TCSADRAIN +TCSAFLUSH +TCSANOW +TIOCGWINSZ +TIOCSWINSZ +TOSTOP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VMIN +VQUIT +VSTART +VSTOP +VSUSP +VTIME +WCONTINUED +WCOREDUMP +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +X_OK +_PC_CHOWN_RESTRICTED +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_VDISABLE +_SC_ARG_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_HOST_NAME_MAX +_SC_NGROUPS_MAX +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_TTY_NAME_MAX +_SC_TZNAME_MAX +_SC_VERSION +_exit +abort +accept +access +addrinfo +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +bind +blkcnt_t +blksize_t +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +cfsetspeed +chdir +chmod +chown +clock_gettime +clock_t +clockid_t +close +closedir +closelog +confstr +connect +creat +dev_t +dirent +dladdr +dlclose +dlerror +dlopen +dlsym +dup +dup2 +execl +execle +execlp +execv +execve +execvp +exit +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fd_set +fdopen +feof +ferror +fflush +fgetc +fgetpos +fgets +fileno +flock +fnmatch +fopen +fork +fpathconf +fpos_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freopen +fsblkcnt_t +fscanf +fseek +fseeko +fsetpos +fsfilcnt_t +fstat +fstatat +fstatvfs +fsync +ftell +ftello +ftruncate +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcwd +getegid +getenv +geteuid +getgid +getgroups +gethostname +getlogin +getopt +getpeername +getpgid +getpgrp +getpid +getppid +getprotobyname +getprotobynumber +getpwnam +getpwuid +getservbyname +getsockname +getsockopt +gettimeofday +getuid +gid_t +gmtime +gmtime_r +grantpt +group +hostent +hstrerror +htonl +htons +if_indextoname +if_nametoindex +in6_addr +in6addr_any +in6addr_loopback +in_addr +in_addr_t +in_port_t +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +itimerval +kill +lchown +lconv +linger +link +linkat +listen +locale_t +localeconv +localtime +localtime_r +lseek +lstat +malloc +memccpy +memchr +memcmp +memcpy +memmove +memset +mkdir +mkdtemp +mkfifo +mknod +mkstemp +mktime +mlock +mlockall +mmap +mode_t +mprotect +msync +munlock +munlockall +munmap +nanosleep +nfds_t +nlink_t +ntohl +ntohs +off_t +open +opendir +openlog +passwd +pathconf +pclose +perror +pid_t +pipe +poll +pollfd +posix_memalign +posix_openpt +pread +printf +protoent +pselect +pthread_attr_destroy +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setstacksize +pthread_attr_t +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_init +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_mutex_destroy +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_t +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_init +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_init +pthread_rwlockattr_t +pthread_self +pthread_setspecific +pthread_t +ptrdiff_t +ptsname +putchar +putchar_unlocked +putenv +puts +pwrite +raise +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +remove +rename +renameat +res_init +rewind +rewinddir +rlim_t +rlimit +rmdir +rusage +sa_family_t +scanf +sched_yield +select +sem_post +sem_t +sem_trywait +sem_wait +send +sendto +servent +setbuf +setegid +setenv +seteuid +setgid +setlocale +setlogmask +setpgid +setregid +setreuid +setsid +setsockopt +setuid +setvbuf +shm_open +shm_unlink +shutdown +sigaction +sigaddset +sigdelset +sigemptyset +sigfillset +sighandler_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigval +size_t +sleep +snprintf +sockaddr +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socketpair +socklen_t +speed_t +sprintf +sscanf +ssize_t +stat +statvfs +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strlen +strncat +strncmp +strncpy +strnlen +strpbrk +strrchr +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +symlink +symlinkat +sysconf +syslog +system +tcdrain +tcflag_t +tcflow +tcflush +tcgetattr +tcgetpgrp +tcgetsid +tcsendbreak +tcsetattr +tcsetpgrp +termios +time +time_t +timegm +times +timespec +timeval +timezone +tm +tmpfile +tmpnam +tms +tolower +toupper +ttyname +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +umask +uname +ungetc +unlink +unlinkat +unlockpt +unsetenv +usleep +utimbuf +utime +utimes +utsname +wait +waitpid +wchar_t +wcslen +wcstombs +winsize +wmemchr +write +writev diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 9b49d285d25ed..61069196dad80 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -1757,6 +1757,8 @@ pub const SOCK_CLOEXEC: c_int = 0x10000000; pub const SA_SIGINFO: c_int = 0x0002; pub const SA_NOCLDWAIT: c_int = 0x0020; pub const SA_NODEFER: c_int = 0x0010; +#[cfg(target_os = "qnx")] // QNX8 only +pub const SA_ONSTACK: c_int = 0x0008; pub const SA_RESETHAND: c_int = 0x0004; pub const SA_NOCLDSTOP: c_int = 0x0001; From 4dc5eff5929de0b8ce883d9216c3f50a7518cba9 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Wed, 5 Aug 2026 10:28:55 -0400 Subject: [PATCH 03/88] Change the type of BPF_ALIGNMENT to size_t. Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com> (backport ) (cherry picked from commit 15d38f73f1629fadcb2553234a9894f213241c9d) --- src/unix/aix/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a7c2d6e275502..d8c64ee7b14d1 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -825,7 +825,7 @@ pub const BIOCGETIF: c_int = 0x4020426b; pub const BIOCSETIF: c_int = u32_cast_int(0x8020426c); pub const BPF_ABS: c_int = 32; pub const BPF_ADD: c_int = 0; -pub const BPF_ALIGNMENT: c_ulong = 4; +pub const BPF_ALIGNMENT: size_t = size_of::(); pub const BPF_ALU: c_int = 4; pub const BPF_AND: c_int = 80; pub const BPF_B: c_int = 16; From 766520cba34a9dd8eb0f87788c7ce9fc785a6d08 Mon Sep 17 00:00:00 2001 From: Andrew Kloet Date: Tue, 4 Aug 2026 13:24:19 -0400 Subject: [PATCH 04/88] openbsd: add missing HW_* sysctl constants Move OpenBSD HW_* sysctl constants into sys/sysctl.rs and add some missing definitions from sys/sysctl.h. Ref: https://github.com/openbsd/src/blob/544119925528153b873297bc630370abacfd5a7f/sys/sys/sysctl.h (backport ) (cherry picked from commit d0c9b0f14ef624576cfcb0a1285b2b29d54f4d47) --- libc-test/semver/openbsd.txt | 27 ++++++++++++++++++++ src/new/mod.rs | 1 + src/new/openbsd/sys/mod.rs | 1 + src/new/openbsd/sys/sysctl.rs | 35 ++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 -- 5 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/new/openbsd/sys/sysctl.rs diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index cc84b0bb7ff18..ef0b9b5c48a29 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -260,8 +260,35 @@ GLOB_NOMATCH GLOB_NOSORT GLOB_NOSPACE GLOB_NOSYS +HW_BATTERY +HW_BATTERY_CHARGEMODE +HW_BATTERY_CHARGESTART +HW_BATTERY_CHARGESTOP +HW_BYTEORDER +HW_CPUSPEED +HW_DISKCOUNT +HW_DISKNAMES +HW_DISKSTATS +HW_MACHINE +HW_MODEL HW_NCPU +HW_NCPUFOUND HW_NCPUONLINE +HW_PAGESIZE +HW_PERFPOLICY +HW_PHYSMEM +HW_PHYSMEM64 +HW_POWER +HW_PRODUCT +HW_SENSORS +HW_SERIALNO +HW_SETPERF +HW_UCOMNAMES +HW_USERMEM +HW_USERMEM64 +HW_UUID +HW_VENDOR +HW_VERSION IFF_ALLMULTI IFF_BROADCAST IFF_DEBUG diff --git a/src/new/mod.rs b/src/new/mod.rs index 13479209d23c9..3d1da7107b5e9 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -223,6 +223,7 @@ cfg_if! { pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; + pub use sys::sysctl::*; } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] { pub use net::bpf::*; pub use net::if_::*; diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs index d72038e438781..94d4e8db38a29 100644 --- a/src/new/openbsd/sys/mod.rs +++ b/src/new/openbsd/sys/mod.rs @@ -3,3 +3,4 @@ //! pub(crate) mod ipc; +pub(crate) mod sysctl; diff --git a/src/new/openbsd/sys/sysctl.rs b/src/new/openbsd/sys/sysctl.rs new file mode 100644 index 0000000000000..f52fc26a2016a --- /dev/null +++ b/src/new/openbsd/sys/sysctl.rs @@ -0,0 +1,35 @@ +//! Header: `sys/sysctl.h` +//! +//! + +use crate::prelude::*; + +pub const HW_MACHINE: c_int = 1; +pub const HW_MODEL: c_int = 2; +pub const HW_BYTEORDER: c_int = 4; +pub const HW_PHYSMEM: c_int = 5; +pub const HW_USERMEM: c_int = 6; +pub const HW_PAGESIZE: c_int = 7; +pub const HW_DISKNAMES: c_int = 8; +pub const HW_DISKSTATS: c_int = 9; +pub const HW_DISKCOUNT: c_int = 10; +pub const HW_SENSORS: c_int = 11; +pub const HW_CPUSPEED: c_int = 12; +pub const HW_SETPERF: c_int = 13; +pub const HW_VENDOR: c_int = 14; +pub const HW_PRODUCT: c_int = 15; +pub const HW_VERSION: c_int = 16; +pub const HW_SERIALNO: c_int = 17; +pub const HW_UUID: c_int = 18; +pub const HW_PHYSMEM64: c_int = 19; +pub const HW_USERMEM64: c_int = 20; +pub const HW_NCPUFOUND: c_int = 21; +pub const HW_PERFPOLICY: c_int = 23; +pub const HW_NCPUONLINE: c_int = 25; +pub const HW_POWER: c_int = 26; +pub const HW_BATTERY: c_int = 27; +pub const HW_UCOMNAMES: c_int = 28; + +pub const HW_BATTERY_CHARGEMODE: c_int = 1; +pub const HW_BATTERY_CHARGESTART: c_int = 2; +pub const HW_BATTERY_CHARGESTOP: c_int = 3; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 8b35121af917a..add6a2088abed 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1359,8 +1359,6 @@ pub const CTL_DDB: c_int = 9; pub const CTL_VFS: c_int = 10; pub const CTL_MAXID: c_int = 11; -pub const HW_NCPUONLINE: c_int = 25; - pub const KERN_OSTYPE: c_int = 1; pub const KERN_OSRELEASE: c_int = 2; pub const KERN_OSREV: c_int = 3; From e0fc9a2af61052038272182f83d9a571faf09dfb Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Mon, 11 Aug 2025 10:59:55 +0200 Subject: [PATCH 05/88] linux_like: unify SIGEV_THREAD_ID support This effectively adds the constant for musl too, as the last platform to support this symbol. It has been supported in musl since 7c71792e ("add support for SIGEV_THREAD_ID timers") and was released with v1.2.2 in January 2021. The libc-test build script needed some tweaking to skip the symbol when building against an older musl. Also double-checked that the `sigevent` struct is defined in the exact same way. Signed-off-by: Christoph Heiss Co-authored-by: Christoph Heiss (backport ) (cherry picked from commit 74e58cc7294fa594b205a33f8235a2b264455b13) --- libc-test/build/main.rs | 3 +++ libc-test/semver/emscripten.txt | 1 + libc-test/semver/l4re.txt | 1 + libc-test/semver/linux-gnu.txt | 1 - libc-test/semver/linux.txt | 1 + src/unix/linux_like/android/mod.rs | 2 -- src/unix/linux_like/l4re/uclibc/mod.rs | 2 -- src/unix/linux_like/linux/gnu/mod.rs | 2 -- src/unix/linux_like/linux/uclibc/mod.rs | 2 -- src/unix/linux_like/mod.rs | 1 + 10 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index de3ed278fec5b..b325af1e7c222 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4715,6 +4715,9 @@ fn test_linux(target: &str) { // FIXME(musl): Values changed in newer musl versions on these arches "O_LARGEFILE" if riscv64 || x86_64 => return true, + // musl 1.2.2 was the first version where this appeared at. + "SIGEV_THREAD_ID" if old_musl => return true, + _ => (), } } diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 35f7d85de5181..1fc5f3ed88d8e 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,4 +1,5 @@ AT_EACCESS +SIGEV_THREAD_ID getentropy getgrgid getgrgid_r diff --git a/libc-test/semver/l4re.txt b/libc-test/semver/l4re.txt index e4a8a79a28a11..d49b9dd89a195 100644 --- a/libc-test/semver/l4re.txt +++ b/libc-test/semver/l4re.txt @@ -1495,6 +1495,7 @@ SIGCONT SIGEV_NONE SIGEV_SIGNAL SIGEV_THREAD +SIGEV_THREAD_ID SIGFPE SIGHUP SIGILL diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 4fbcf053c022a..72cb83d94b254 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -402,7 +402,6 @@ RWF_NOWAIT RWF_SYNC SECURITYFS_MAGIC SELINUX_MAGIC -SIGEV_THREAD_ID SMACK_MAGIC SMB_SUPER_MAGIC SOL_CAIF diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 737874f32ce30..07ab97d980527 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3029,6 +3029,7 @@ SHORT_INODE SIGEV_NONE SIGEV_SIGNAL SIGEV_THREAD +SIGEV_THREAD_ID SIGIO SIGPOLL SIGPWR diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 29dc9d3ed2ea0..caf0e28385344 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1839,8 +1839,6 @@ pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); pub const NLA_ALIGNTO: c_int = 4; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const CIBAUD: crate::tcflag_t = 0o02003600000; pub const CBAUDEX: crate::tcflag_t = 0o010000; diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index 06add53ad9eae..06806d1051f0e 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -386,8 +386,6 @@ pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const AF_VSOCK: c_int = 40; pub const POSIX_FADV_DONTNEED: c_int = 4; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index b8c62331fa608..f36ec9ad51eda 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -679,8 +679,6 @@ pub const PF_NFC: c_int = AF_NFC; pub const PF_VSOCK: c_int = AF_VSOCK; pub const PF_XDP: c_int = AF_XDP; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const BUFSIZ: c_uint = 8192; pub const TMP_MAX: c_uint = 238328; pub const FOPEN_MAX: c_uint = 16; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 6c3d8013f9173..dd54a15e25fb0 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -216,8 +216,6 @@ pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; -pub const SIGEV_THREAD_ID: c_int = 4; - pub const AF_VSOCK: c_int = 40; // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 7951abf33f4d0..f7b5a0e69fe97 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1296,6 +1296,7 @@ pub const CLD_CONTINUED: c_int = 6; pub const SIGEV_SIGNAL: c_int = 0; pub const SIGEV_NONE: c_int = 1; pub const SIGEV_THREAD: c_int = 2; +pub const SIGEV_THREAD_ID: c_int = 4; pub const P_ALL: idtype_t = 0; pub const P_PID: idtype_t = 1; From 0886ec7554e5a509d924765246323ec553dba021 Mon Sep 17 00:00:00 2001 From: subotac <73706465+subotac@users.noreply.github.com> Date: Thu, 6 Aug 2026 14:37:00 +0300 Subject: [PATCH 06/88] wasi: add locale category constants Source: https://github.com/WebAssembly/wasi-libc/blob/6d8745c8cec1aaa82c24f2e3d7a544f7ea9c2089/libc-top-half/musl/include/locale.h#L23-L29 (backport ) (cherry picked from commit 364e4b60d8c300e97fb428d0389d00a5b03df2f4) --- libc-test/semver/wasi.txt | 7 +++++++ src/wasi/mod.rs | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/libc-test/semver/wasi.txt b/libc-test/semver/wasi.txt index 510c73fd16e70..7fa658bb78021 100644 --- a/libc-test/semver/wasi.txt +++ b/libc-test/semver/wasi.txt @@ -1,6 +1,13 @@ FD_ISSET FD_SET FD_ZERO +LC_ALL +LC_COLLATE +LC_CTYPE +LC_MESSAGES +LC_MONETARY +LC_NUMERIC +LC_TIME SOCK_CLOEXEC SOCK_NONBLOCK SOL_SOCKET diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index a21aa4f32635f..b386ecf696ea4 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -554,6 +554,14 @@ pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_ #[allow(unused_unsafe)] pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 2; +pub const LC_COLLATE: c_int = 3; +pub const LC_MONETARY: c_int = 4; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; + pub const ABDAY_1: crate::nl_item = 0x20000; pub const ABDAY_2: crate::nl_item = 0x20001; pub const ABDAY_3: crate::nl_item = 0x20002; From 5dc11c69bc2526a0ca028696588bf7c45d2995e1 Mon Sep 17 00:00:00 2001 From: Haseeb Nazir <36381672+iamhaseebn@users.noreply.github.com> Date: Mon, 3 Aug 2026 04:29:33 -0400 Subject: [PATCH 07/88] Add OpenBSD RTLD_NODELETE and RTLD_NOLOAD OpenBSD source: https://github.com/openbsd/src/blob/8bdaccf9d69425873152d3ed5dfe9a5e9f6b26d8/include/dlfcn.h#L42-L49 Fixes rust-lang/libc#5318 (backport ) (cherry picked from commit b37a8dec5c988a0ef09595240f873cd2bd2b9ac7) --- libc-test/semver/openbsd.txt | 2 ++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index ef0b9b5c48a29..859457ea63cd0 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -860,6 +860,8 @@ RTF_MPLS RTF_MULTICAST RTF_PROTO3 RTLD_NEXT +RTLD_NODELETE +RTLD_NOLOAD RTLD_SELF RTM_80211INFO RTM_BFD diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index add6a2088abed..7f47da25eaac0 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1338,6 +1338,8 @@ pub const NI_DGRAM: c_int = 16; pub const NI_MAXHOST: size_t = 256; pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_NODELETE: c_int = 0x400; +pub const RTLD_NOLOAD: c_int = 0x800; pub const CTL_MAXNAME: c_int = 12; From 6ab59ae5233803acec33001d5faf6e8045b0b29d Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:23 +0200 Subject: [PATCH 08/88] aix: annotate lfs types as slated for deprecation (backport ) (cherry picked from commit a3b815f92fc473f5513d3a3fec7eedc5be388a4c) --- src/unix/aix/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index d8c64ee7b14d1..eca9b6cf28e09 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -10,6 +10,7 @@ pub type blkcnt_t = c_long; pub type clock_t = c_int; pub type daddr_t = c_long; pub type dev_t = c_ulong; +// FIXME(1.0,deprecate): lfs binding to be removed pub type fpos64_t = c_longlong; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; @@ -21,6 +22,7 @@ pub type rlim_t = c_ulong; pub type speed_t = c_uint; pub type tcflag_t = c_uint; pub type time_t = c_long; +// FIXME(1.0,deprecate): lfs binding to be removed pub type time64_t = i64; pub type timer_t = c_long; pub type wchar_t = c_uint; @@ -33,6 +35,7 @@ pub type suseconds_t = c_int; pub type useconds_t = c_uint; pub type off_t = c_long; pub type offset_t = c_longlong; +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = c_longlong; pub type idtype_t = c_uint; @@ -48,6 +51,7 @@ pub type nl_item = c_int; pub type mqd_t = c_int; pub type shmatt_t = c_ulong; pub type regoff_t = c_long; +// FIXME(1.0,deprecate): lfs binding to be removed pub type rlim64_t = c_ulonglong; pub type sem_t = c_int; From c00f13b171455b8d7dcfa75d1c7c23e2bd3e0384 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:23 +0200 Subject: [PATCH 09/88] aix: annotate certain lfs bindings for deprecation Add comment annotations to certain LFS bindings that need deprecation and eventual removal only under certain targets. This is due to the fact they are only considered equivalent when the target is either 32-bits or 64-bits. This applies to `statfs`, `statvfs` and routines that depend on them. See `sys/statfs.h`, `sys/statvfs.h` under `/usr/include` in any AIX 7.3 machine. (backport ) (cherry picked from commit ee82420708a49a883250baf4dae44f85ce00926e) --- src/unix/aix/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index eca9b6cf28e09..ac455f75e8600 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -137,6 +137,7 @@ s! { pub msg_flags: c_int, } + // FIXME(1.0,deprecate,32): lfs binding to be removed. pub struct statvfs64 { pub f_bsize: crate::blksize64_t, pub f_frsize: crate::blksize64_t, @@ -270,6 +271,7 @@ s! { pub tv_nsec: c_int, } + // FIXME(1.0,deprecate,64): lfs binding to be removed pub struct statfs64 { pub f_version: c_int, pub f_type: c_int, @@ -2931,7 +2933,9 @@ extern "C" { pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int; pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate,32): lfs binding to be removed pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; pub fn ftello64(stream: *mut crate::FILE) -> off64_t; pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; @@ -3331,7 +3335,9 @@ extern "C" { pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn stat64at(dirfd: c_int, path: *const c_char, buf: *mut stat64, flags: c_int) -> c_int; pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate,32): lfs binding to be removed pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; pub fn statx(path: *const c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; pub fn strcasecmp_l( From 4dd51fe5469403c7cb95508e93467a700245bcbb Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:23 +0200 Subject: [PATCH 10/88] aix: annotate most lfs routines for deprecation Add comments for deprecation once stage 3 of the 64-bit plan is reached [^1]. [^1]: rust-lang/libc#4805 (backport ) (cherry picked from commit 8bfbef5c7e5dfee4f596ed054d985a058e9579cc) --- src/unix/aix/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index ac455f75e8600..a0e86fada7a64 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -117,6 +117,7 @@ s! { pub c_cc: [crate::cc_t; crate::NCCS], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct flock64 { pub l_type: c_short, pub l_whence: c_short, @@ -442,6 +443,7 @@ s! { __unused: Padding<[*mut c_void; 34]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -465,6 +467,7 @@ s! { shm_reserved1: Padding, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: dev_t, pub st_ino: ino_t, @@ -2920,25 +2923,33 @@ extern "C" { pub fn ffsl(value: c_long) -> c_int; pub fn ffsll(value: c_longlong) -> c_int; pub fn fgetgrent(file: *mut crate::FILE) -> *mut crate::group; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; pub fn fgetpwent(file: *mut crate::FILE) -> *mut crate::passwd; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn freelocale(loc: crate::locale_t); + // FIXME(1.0,deprecate): lfs binding to be removed pub fn freopen64( filename: *const c_char, mode: *const c_char, file: *mut crate::FILE, ) -> *mut crate::FILE; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fseeko64(stream: *mut crate::FILE, offset: off64_t, whence: c_int) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; // FIXME(1.0,deprecate,64): lfs binding to be removed pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; // FIXME(1.0,deprecate,32): lfs binding to be removed pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftello64(stream: *mut crate::FILE) -> off64_t; pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; pub fn getcontext(ucp: *mut ucontext_t) -> c_int; @@ -2996,6 +3007,7 @@ extern "C" { result: *mut *mut passwd, ) -> c_int; pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int; pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; @@ -3047,7 +3059,9 @@ extern "C" { width: size_t, compar: Option c_int>, ) -> *mut c_void; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn madvise(addr: caddr_t, len: size_t, advice: c_int) -> c_int; pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); @@ -3117,6 +3131,7 @@ extern "C" { pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; pub fn nl_langinfo_l(item: crate::nl_item, loc: crate::locale_t) -> *mut c_char; pub fn nrand48(xseed: *mut c_ushort) -> c_long; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; pub fn pollset_create(maxfd: c_int) -> pollset_t; pub fn pollset_ctl(ps: pollset_t, pollctl_array: *mut poll_ctl, array_length: c_int) -> c_int; @@ -3130,8 +3145,10 @@ extern "C" { pub fn pollset_query(ps: pollset_t, pollfd_query: *mut crate::pollfd) -> c_int; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fadvise64(fd: c_int, offset: off64_t, len: off64_t, advise: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; pub fn posix_spawn( @@ -3206,6 +3223,7 @@ extern "C" { argv: *const *mut c_char, envp: *const *mut c_char, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; pub fn ptrace64( @@ -3217,6 +3235,7 @@ extern "C" { ) -> c_int; pub fn pututline(u: *const utmp) -> *mut utmp; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: off64_t) -> ssize_t; pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; @@ -3305,6 +3324,7 @@ extern "C" { pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int; pub fn setpwent(); pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn setitimer( @@ -3332,7 +3352,9 @@ extern "C" { pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int; pub fn srand(seed: c_uint); pub fn srand48(seed: c_long); + // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64at(dirfd: c_int, path: *const c_char, buf: *mut stat64, flags: c_int) -> c_int; pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; // FIXME(1.0,deprecate,64): lfs binding to be removed @@ -3379,6 +3401,7 @@ extern "C" { new_value: *const crate::itimerspec, old_value: *mut crate::itimerspec, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; pub fn uname(buf: *mut crate::utsname) -> c_int; pub fn updwtmp(file: *const c_char, u: *const utmp); From c9aeff8581b07bfefee0c65e29e5f1c4b615dc51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:04:16 +0000 Subject: [PATCH 11/88] build(deps): bump vmactions/freebsd-vm from 1.5.2 to 1.5.3 Bumps [vmactions/freebsd-vm](https://github.com/vmactions/freebsd-vm) from 1.5.2 to 1.5.3. - [Release notes](https://github.com/vmactions/freebsd-vm/releases) - [Commits](https://github.com/vmactions/freebsd-vm/compare/77ed28d336d03fe19a3f4f7266c1d2c4714dd79d...83b151f58c6047089f4c80eb5ba2039d158ce093) --- updated-dependencies: - dependency-name: vmactions/freebsd-vm dependency-version: 1.5.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit 8a5f2d5c282a488ef0746aa15b68656a25e65127) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bf6aa9bc50f18..3aa5ddeed7d6d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -304,7 +304,7 @@ jobs: with: persist-credentials: false - name: Test on FreeBSD - uses: vmactions/freebsd-vm@77ed28d336d03fe19a3f4f7266c1d2c4714dd79d # v1.5.2 + uses: vmactions/freebsd-vm@83b151f58c6047089f4c80eb5ba2039d158ce093 # v1.5.3 if: contains(matrix.target, 'freebsd') with: release: ${{ matrix.release }} From df170ba14439374f82e5dbd29e17d518c8425e7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:03:25 +0000 Subject: [PATCH 12/88] build(deps): bump Swatinem/rust-cache from 2.9.1 to 2.9.2 Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.9.1 to 2.9.2. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/c19371144df3bb44fab255c43d04cbc2ab54d1c4...6323deb102c322ba6fcbdcafc7e3dddab59af2b6) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-version: 2.9.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit b52d93f842d10600d78fcc9ed4d693bb68f44876) --- .github/workflows/ci.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3aa5ddeed7d6d..5586e6aa6abe7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,7 +48,7 @@ jobs: with: persist-credentials: false - run: rustup update stable --no-self-update - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 # Here we use the latest stable Rust toolchain already installed by GitHub # Ideally we should run it for every target, but we cannot rely on unstable toolchains # due to Clippy not being consistent between them. @@ -94,7 +94,7 @@ jobs: # FIXME(ci): These `du` statements are temporary for debugging cache - name: Target size before restoring cache run: du -sh target | sort -k 2 || true - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: ${{ matrix.os }}-${{ matrix.toolchain }} - name: Target size after restoring cache @@ -151,7 +151,7 @@ jobs: persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: ${{ matrix.target }} @@ -253,7 +253,7 @@ jobs: persist-credentials: false - name: Setup Rust toolchain run: ./ci/install-rust.sh - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: key: ${{ matrix.target }} @@ -366,7 +366,7 @@ jobs: - name: Install Rust # FIXME(rust-lang/rust#160439): unpin once the issue is fixed run: rustup update nightly-2026-08-02 --no-self-update && rustup default nightly-2026-08-02 - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 - run: cargo doc --workspace --no-deps zizmor: From 97c3b5d25736f042358babfb52f93dc874419b90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:04:02 +0000 Subject: [PATCH 13/88] build(deps): bump taiki-e/install-action from 2.85.5 to 2.85.10 Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.85.5 to 2.85.10. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/6a1bd70eaac3c8bdf093356838d7ee09fda951cf...6c6fd71fe4fb72c3697d269963d0e15df8adedad) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-version: 2.85.10 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit f9189d510db5f6a10abb7309681d0582b234aafe) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5586e6aa6abe7..94d5fae3ff443 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -82,7 +82,7 @@ jobs: run: ./ci/install-rust.sh - name: Install semver-checks - uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5 + uses: taiki-e/install-action@6c6fd71fe4fb72c3697d269963d0e15df8adedad # v2.85.10 if: matrix.toolchain == 'stable' with: tool: cargo-semver-checks From 59238a593800fdb026882099aa513d920b5bb51f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:04:06 +0000 Subject: [PATCH 14/88] build(deps): bump vmactions/netbsd-vm from 1.4.5 to 1.4.6 Bumps [vmactions/netbsd-vm](https://github.com/vmactions/netbsd-vm) from 1.4.5 to 1.4.6. - [Release notes](https://github.com/vmactions/netbsd-vm/releases) - [Commits](https://github.com/vmactions/netbsd-vm/compare/e7ac71b97abbe8437cec8859a5acf72dfa6a8be0...00081e82b14bc40114eb97f32b4455306828516b) --- updated-dependencies: - dependency-name: vmactions/netbsd-vm dependency-version: 1.4.6 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit aa39754f8b7bb3c3505a0c54029c753fea5b0608) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 94d5fae3ff443..3692d34679572 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -331,7 +331,7 @@ jobs: run: ./ci/bsd-run.sh ${{ matrix.target }} - name: Test on NetBSD - uses: vmactions/netbsd-vm@e7ac71b97abbe8437cec8859a5acf72dfa6a8be0 # v1.4.5 + uses: vmactions/netbsd-vm@00081e82b14bc40114eb97f32b4455306828516b # v1.4.6 if: contains(matrix.target, 'netbsd') with: release: "10.1" From 328beb955c25276c515f71e461a36f8ab78eecc2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:04:10 +0000 Subject: [PATCH 15/88] build(deps): bump zizmorcore/zizmor-action from 0.6.1 to 0.6.2 Bumps [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action) from 0.6.1 to 0.6.2. - [Release notes](https://github.com/zizmorcore/zizmor-action/releases) - [Commits](https://github.com/zizmorcore/zizmor-action/compare/6fc4b006235f201fdab3722e17240ab420d580e5...3dc1ecc9bcb9e94e9b2c709687979e1298497054) --- updated-dependencies: - dependency-name: zizmorcore/zizmor-action dependency-version: 0.6.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit 5d91b82ebb47a56ea2e9ba80fcd48556e97fb565) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3692d34679572..e032f8617f919 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -382,7 +382,7 @@ jobs: persist-credentials: false - name: Run zizmor - uses: zizmorcore/zizmor-action@6fc4b006235f201fdab3722e17240ab420d580e5 # v0.6.1 + uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2 # One job that "summarizes" the success state of this pipeline. This can then be added to branch # protection, rather than having to add each job separately. From 66c2fd4db7e55734f2cad1601f1dd9ddaa466980 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 4 Jun 2026 10:35:02 +0200 Subject: [PATCH 16/88] emscripten: annotate file off tys for deprecation emscripten follows musl quite closely. The changes they make are not concerned with file offset types. The only exception to this is `blkcnt_t`. This type is defined as 32-bits wide no matter the target. All other file offset types are 64-bit wide no matter the target. (backport ) (cherry picked from commit 036d31d1a610708beefe31d080af3198db7c9f8f) --- libc-test/semver/emscripten.txt | 1 - src/unix/linux_like/emscripten/mod.rs | 39 ++++++++++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 1fc5f3ed88d8e..763addcdda6b4 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -8,4 +8,3 @@ getgrnam_r getpwnam_r getpwuid_r in6_pktinfo -posix_fallocate64 diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 184e3958e3d03..35f4bd87df698 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -28,20 +28,39 @@ pub type fsfilcnt_t = u32; pub type rlim_t = u64; pub type nlink_t = u32; -pub type ino64_t = crate::ino_t; +// FIXME(1.0,deprecate): lfs binding to be removed +pub type ino64_t = ino_t; + +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = off_t; -pub type blkcnt64_t = crate::blkcnt_t; -pub type rlim64_t = crate::rlim_t; +//FIXME(1.0,deprecate): lfs binding to be removed +pub type blkcnt64_t = blkcnt_t; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type rlim64_t = rlim_t; + +//FIXME(1.0,deprecate): lfs binding to be removed pub type rlimit64 = crate::rlimit; -pub type flock64 = crate::flock; -pub type stat64 = crate::stat; -pub type statfs64 = crate::statfs; -pub type statvfs64 = crate::statvfs; -pub type dirent64 = crate::dirent; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type flock64 = flock; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type stat64 = stat; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type statfs64 = statfs; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type statvfs64 = statvfs; + +//FIXME(1.0,deprecate): lfs binding to be removed +pub type dirent64 = dirent; extern_ty! { - pub type fpos64_t; // FIXME(emscripten): fill this out with a struct + //FIXME(1.0,deprecate): lfs binding to be removed + pub type fpos64_t; } s! { @@ -1462,4 +1481,6 @@ extern "C" { // Alias to 64 to mimic glibc's LFS64 support mod lfs64; + +// FIXME(1.0,deprecate): lfs bindings to be removed pub use self::lfs64::*; From c8e67db51d98cb3576786aaf85603abca8cce4fe Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 17 Jun 2026 15:29:04 +0200 Subject: [PATCH 17/88] android: annotate lfs types for deprecation Android had LFS bindings. This is not necessary. Targets with 32-bit ABIs have it upstream. Targets with 64-bit ABIs don't. This patch annotates them for future deprecation in the plan outlined in rust-lang/libc#4805. This only applies to targets with 64-bit ABIs. (backport ) (cherry picked from commit 5b25cab671fe373fab2b672e47fe6baaa4410951) --- .../linux_like/android/b64/aarch64/mod.rs | 1 + src/unix/linux_like/android/b64/mod.rs | 5 +++++ .../linux_like/android/b64/riscv64/mod.rs | 1 + src/unix/linux_like/android/b64/x86_64/mod.rs | 1 + src/unix/linux_like/android/mod.rs | 9 ++++++++ src/unix/linux_like/mod.rs | 22 +++++++++++++++++++ 6 files changed, 39 insertions(+) diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index c8c48e5d90894..2fe6211e00ec5 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -27,6 +27,7 @@ s! { __unused5: Padding, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index a1f7c393998da..c8df732d5a2b6 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -4,6 +4,7 @@ use crate::prelude::*; // but may be wrong for mips64 pub type mode_t = u32; +// FIXME(1.0,deprecate): lfs binding to be removed pub type off64_t = i64; pub type socklen_t = u32; @@ -21,6 +22,7 @@ s! { pub sa_restorer: Option, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct rlimit64 { pub rlim_cur: c_ulonglong, pub rlim_max: c_ulonglong, @@ -78,6 +80,7 @@ s! { pub _f: [c_char; 0], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statfs64 { pub f_type: u64, pub f_bsize: u64, @@ -93,6 +96,7 @@ s! { pub f_spare: [u64; 4], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct statvfs64 { pub f_bsize: c_ulong, pub f_frsize: c_ulong, @@ -135,6 +139,7 @@ s! { __reserved: Padding<[c_char; 36]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct sigset64_t { __bits: [c_ulong; 1], } diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 12f87304e7420..2d68a99b5a73d 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -28,6 +28,7 @@ s! { __unused5: Padding, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index de358edd5d41a..ef8a87970b9a9 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -25,6 +25,7 @@ s! { __unused: Padding<[c_long; 3]>, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index caf0e28385344..6c024534f5985 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -36,6 +36,7 @@ pub type nfds_t = c_uint; pub type rlim_t = c_ulong; pub type dev_t = c_ulong; pub type ino_t = c_ulong; +// FIXME(1.0,deprecate): lfs binding to be removed pub type ino64_t = u64; pub type __CPU_BITTYPE = c_ulong; pub type idtype_t = c_int; @@ -114,6 +115,7 @@ s! { pub l_pid: crate::pid_t, } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct flock64 { pub l_type: c_short, pub l_whence: c_short, @@ -534,6 +536,7 @@ s! { pub d_name: [c_char; 256], } + // FIXME(1.0,deprecate): lfs binding to be removed pub struct dirent64 { pub d_ino: u64, pub d_off: i64, @@ -3508,7 +3511,9 @@ extern "C" { pub fn setgrent(); pub fn endgrent(); pub fn getgrent() -> *mut crate::group; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; @@ -3518,6 +3523,7 @@ extern "C" { new_limit: *const crate::rlimit, old_limit: *mut crate::rlimit, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn prlimit64( pid: crate::pid_t, resource: c_int, @@ -3578,8 +3584,10 @@ extern "C" { pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); pub fn telldir(dirp: *mut crate::DIR) -> c_long; pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; pub fn getxattr( path: *const c_char, @@ -3736,6 +3744,7 @@ extern "C" { param: *const crate::sched_param, ) -> c_int; pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn sendfile64(out_fd: c_int, in_fd: c_int, offset: *mut off64_t, count: size_t) -> ssize_t; pub fn setfsgid(gid: crate::gid_t) -> c_int; pub fn setfsuid(uid: crate::uid_t) -> c_int; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index f7b5a0e69fe97..f4e2090669c9b 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -2100,26 +2100,37 @@ cfg_if! { target_os = "emscripten", )))] { extern "C" { + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] #[cfg(not(target_os = "l4re"))] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstatat64( dirfd: c_int, pathname: *const c_char, buf: *mut stat64, flags: c_int, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] #[cfg(not(target_os = "l4re"))] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn mmap64( addr: *mut c_void, len: size_t, @@ -2128,22 +2139,29 @@ cfg_if! { fd: c_int, offset: off64_t, ) -> *mut c_void; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn openat64(fd: c_int, path: *const c_char, oflag: c_int, ...) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn posix_fadvise64( fd: c_int, offset: off64_t, len: off64_t, advise: c_int, ) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pwrite64( fd: c_int, buf: *const c_void, count: size_t, offset: off64_t, ) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn readdir64_r( dirp: *mut crate::DIR, entry: *mut crate::dirent64, @@ -2151,7 +2169,9 @@ cfg_if! { ) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] #[cfg(not(target_os = "l4re"))] + // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; } } @@ -2165,12 +2185,14 @@ cfg_if! { target_os = "emscripten", )))] { extern "C" { + // FIXME(1.0,deprecate): lfs binding to be removed pub fn preadv64( fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t, ) -> ssize_t; + // FIXME(1.0,deprecate): lfs binding to be removed pub fn pwritev64( fd: c_int, iov: *const crate::iovec, From 3674a999b031672e356cd5f775510b41823ab24b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 6 Aug 2026 02:06:06 -0500 Subject: [PATCH 18/88] musl: Change `musl_v1_2_3` to `musl_v1_2` 1.2.0 was the release that introduced 64-bit `time_t` everywhere [1], which is the main thing we are interested in with this config. There is nothing special about 1.2.3, and most gated API will work down to 1.2.0. This has been a source of mild confusion. To make things more clear, drop the `_3`. We continue to support `libc_unstable_musl_v1_2_3` for now but emit a warning if set. Closes: https://github.com/rust-lang/libc/issues/5200 [1]: https://musl.libc.org/releases.html [ basically readid the same change for the backport rather than resolving conflicts - Trevor ] (backport ) (cherry picked from commit 01a116fe25e65e7233af1d19b48fd0cc2c723be7) --- .github/workflows/ci.yaml | 14 +++++------ build.rs | 23 ++++++++++++------- ci/run-docker.sh | 4 ++-- ci/verify-build.py | 2 +- etc/libc-util.py | 2 +- libc-test/build/main.rs | 12 +++++----- libc-test/tests/style_lib/mod.rs | 2 +- src/new/emscripten/sched.rs | 2 +- src/new/musl/sched.rs | 2 +- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 8 +++---- src/unix/linux_like/linux/musl/b32/hexagon.rs | 4 ++-- .../linux_like/linux/musl/b32/mips/mod.rs | 20 ++++++++-------- src/unix/linux_like/linux/musl/b32/powerpc.rs | 8 +++---- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 8 +++---- .../linux_like/linux/musl/b64/aarch64/mod.rs | 8 +++---- src/unix/linux_like/linux/musl/b64/mips64.rs | 4 ++-- .../linux_like/linux/musl/b64/powerpc64.rs | 4 ++-- src/unix/linux_like/linux/musl/b64/s390x.rs | 4 ++-- .../linux_like/linux/musl/b64/wasm32/mod.rs | 4 ++-- .../linux_like/linux/musl/b64/x86_64/mod.rs | 4 ++-- src/unix/linux_like/linux/musl/mod.rs | 10 ++++---- src/unix/linux_like/mod.rs | 6 ++--- 22 files changed, 81 insertions(+), 74 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e032f8617f919..2b239a4b1be1d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -191,34 +191,34 @@ jobs: - target: aarch64-linux-android - target: aarch64-unknown-linux-musl - target: aarch64-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: arm-linux-androideabi - target: arm-unknown-linux-gnueabihf - target: arm-unknown-linux-musleabihf - target: arm-unknown-linux-musleabihf - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl # FIXME(#4297): Disabled due to spurious failue # - target: i686-linux-android - target: i686-unknown-linux-musl - target: i686-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: loongarch64-unknown-linux-gnu - target: loongarch64-unknown-linux-musl - target: loongarch64-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: powerpc64-unknown-linux-gnu - target: powerpc64-unknown-linux-musl - target: powerpc64-unknown-linux-musl - env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + env: { RUST_LIBC_UNSTABLE_MUSL_V1_2: 1 } artifact-tag: new-musl - target: powerpc64le-unknown-linux-gnu - target: powerpc64le-unknown-linux-musl - target: powerpc64le-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - target: riscv64gc-unknown-linux-gnu - target: s390x-unknown-linux-gnu @@ -235,7 +235,7 @@ jobs: # - target: x86_64-unknown-linux-gnux32 - target: x86_64-unknown-linux-musl - target: x86_64-unknown-linux-musl - env: { TEST_MUSL_V1_2_3: 1 } + env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl # FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually. # - target: x86_64-unknown-redox diff --git a/build.rs b/build.rs index 4a5e154f85a27..17d9b832867ae 100644 --- a/build.rs +++ b/build.rs @@ -33,8 +33,8 @@ const ALLOWED_CFGS: &[&str] = &[ "libc_elfv2", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", - "musl_v1_2_3", - // musl v1.2.3+ && 32-bit: time_t is i64, struct layouts change + "musl_v1_2", + // musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change "musl32_time64", // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 "musl_redir_time64", @@ -150,13 +150,20 @@ fn main() { _ => (), } - let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3"); + let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); + if let Ok(old_musl_v1_2_3) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { + println!( + "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ + set `--cfg=libc_unstable_musl_v1_2`instead" + ); + musl_v1_2 |= old_musl_v1_2_3 != "0"; + } if let Ok(old_musl_v1_2_3) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { println!( "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ - set `--cfg=libc_unstable_musl_v1_2_3` via RUSTFLAGS instead" + set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" ); - musl_v1_2_3 |= old_musl_v1_2_3 != "0"; + musl_v1_2 |= old_musl_v1_2_3 != "0"; } // OpenHarmony uses a fork of the musl libc @@ -168,11 +175,11 @@ fn main() { || target_env == "ohos" || target_abi == "pauthtest" { - musl_v1_2_3 = true; + musl_v1_2 = true; } - if musl && musl_v1_2_3 { - set_cfg("musl_v1_2_3"); + if musl && musl_v1_2 { + set_cfg("musl_v1_2"); if target_ptr_width == "32" { set_cfg("musl32_time64"); set_cfg("linux_time_bits64"); diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 67ca55fadd0a2..288dc2f4c548c 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -40,8 +40,8 @@ run() { # and test them both in `ci/run.sh` more similar to what we do with glibc, # rather than needing two separate jobs. if [[ "$run_target" = *"musl"* ]]; then - if [ -n "${TEST_MUSL_V1_2_3:-}" ]; then - export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2_3" + if [ -n "${TEST_MUSL_V1_2:-}" ]; then + export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2" build_args+=("--build-arg=MUSL_VERSION=new") else build_args+=("--build-arg=MUSL_VERSION=old") diff --git a/ci/verify-build.py b/ci/verify-build.py index dc8ba576901b0..0219022ab30eb 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -411,7 +411,7 @@ def test_target(cfg: Cfg, target: Target) -> TargetResult: if "musl" in target_env: # Check with breaking changes from musl, including 64-bit time_t on 32-bit - run(cmd, rustflags=f"{rustflags} --cfg=libc_unstable_musl_v1_2_3") + run(cmd, rustflags=f"{rustflags} --cfg=libc_unstable_musl_v1_2") # Test again without default features, i.e. without `std` run([*cmd, "--no-default-features"], rustflags=rustflags) diff --git a/etc/libc-util.py b/etc/libc-util.py index fc5f81f832b5d..2181abf264d0b 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -429,7 +429,7 @@ def prepare() -> "CheckAllTargets": new.attributes = base.attributes | {"time_bits": "64"} new.target_dir = base.target_dir / "time64" new.extra_rustflags = base.extra_rustflags + [ - "--cfg=libc_unstable_musl_v1_2_3" + "--cfg=libc_unstable_musl_v1_2" ] new_checks.append(new) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index b325af1e7c222..189b005684e5a 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4083,22 +4083,22 @@ fn test_linux(target: &str) { None => panic!("failed to detect kernel version for Linux target {target}"), }; - let mut musl_v1_2_3 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3"); - if musl_v1_2_3 { + let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); + if musl_v1_2 { assert!(musl); } // Some platforms only exist with recent musl. Keep in sync with libc's build.rs. if musl && (loongarch64 || hexagon || pauthtest/* || ohos */) { - musl_v1_2_3 = true; + musl_v1_2 = true; } - let old_musl = musl && !musl_v1_2_3; + let old_musl = musl && !musl_v1_2; let mut cfg = ctest_cfg(); - if musl_v1_2_3 { - cfg.cfg("musl_v1_2_3", None); + if musl_v1_2 { + cfg.cfg("musl_v1_2", None); if b32 { cfg.cfg("musl32_time64", None); cfg.cfg("linux_time_bits64", None); diff --git a/libc-test/tests/style_lib/mod.rs b/libc-test/tests/style_lib/mod.rs index d436dcaaa2800..aabdbf7aefa13 100644 --- a/libc-test/tests/style_lib/mod.rs +++ b/libc-test/tests/style_lib/mod.rs @@ -55,7 +55,7 @@ const ALLOWED_POSITIVE_S_CFGS: &[&str] = &[ "gnu_file_offset_bits64", "gnu_time_bits64", "musl32_time64", - "musl_v1_2_3", + "musl_v1_2", ]; pub type Error = Box; diff --git a/src/new/emscripten/sched.rs b/src/new/emscripten/sched.rs index 3bf854ef33c29..fadadac2404b9 100644 --- a/src/new/emscripten/sched.rs +++ b/src/new/emscripten/sched.rs @@ -1,7 +1,7 @@ use crate::prelude::*; cfg_if! { - if #[cfg(musl_v1_2_3)] { + if #[cfg(musl_v1_2)] { s! { struct __c_anon_sched_param__reserved2 { __reserved1: crate::time_t, diff --git a/src/new/musl/sched.rs b/src/new/musl/sched.rs index 3bf854ef33c29..fadadac2404b9 100644 --- a/src/new/musl/sched.rs +++ b/src/new/musl/sched.rs @@ -1,7 +1,7 @@ use crate::prelude::*; cfg_if! { - if #[cfg(musl_v1_2_3)] { + if #[cfg(musl_v1_2)] { s! { struct __c_anon_sched_param__reserved2 { __reserved1: crate::time_t, diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 81ea674f6b041..c91b83d1fbc61 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -25,7 +25,7 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_ino: crate::ino_t, pub st_atime: crate::time_t, @@ -47,7 +47,7 @@ s! { #[cfg(all(musl32_time64, target_endian = "little"))] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_ino: crate::ino_t, } @@ -63,9 +63,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index c99411c15e7ed..32e1f67de99f0 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -46,9 +46,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 8beb5abcdab6a..6b814096d8907 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -23,11 +23,11 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_blksize: crate::blksize_t, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] __st_padding3: Padding, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, @@ -49,16 +49,16 @@ s! { #[cfg(all(musl32_time64, target_endian = "little"))] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_blksize: crate::blksize_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] __st_padding3: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_blocks: crate::blkcnt_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] __st_padding4: Padding<[c_long; 14]>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] __st_padding4: Padding<[c_long; 2]>, } @@ -74,9 +74,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 00b5015084ca2..648723676f378 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -35,7 +35,7 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] __unused: Padding<[c_long; 2]>, pub st_atime: crate::time_t, @@ -57,7 +57,7 @@ s! { #[cfg(all(musl32_time64, target_endian = "little"))] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] __unused: Padding<[c_long; 2]>, } @@ -73,9 +73,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 38fcf64c3ea53..26f0bd3d32ceb 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -25,7 +25,7 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub st_ino: crate::ino_t, pub st_atime: crate::time_t, @@ -41,7 +41,7 @@ s! { #[cfg(musl32_time64)] __pad2: Padding, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] pub st_ino: crate::ino_t, } @@ -61,9 +61,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 1821cf5572f9d..85fa1c07350d8 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -36,9 +36,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed @@ -51,9 +51,9 @@ s! { pub cgid: crate::gid_t, pub mode: crate::mode_t, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __seq: c_int, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "The type of this field has changed from c_ushort to c_int, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index fd1321ffd64d5..5b811078d1f7f 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -37,9 +37,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index ef500af952b62..b791d31e63da4 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -51,9 +51,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index b536c0290eb9c..d30307c6689a8 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -11,9 +11,9 @@ pub type statfs64 = statfs; s! { pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index 09e07acc21a59..15d80594816fa 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -30,9 +30,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index b66ae26733dd2..48890ff35ae23 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -98,9 +98,9 @@ s! { } pub struct ipc_perm { - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub __key: crate::key_t, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "This field is incorrectly named and will be changed diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 99acc27c81a1e..ecb2f830510c9 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -466,7 +466,7 @@ s! { pub ut_host: [c_char; 256], pub ut_exit: __exit_status, - #[cfg(not(musl_v1_2_3))] + #[cfg(not(musl_v1_2))] #[deprecated( since = "0.2.173", note = "The ABI of this field has changed from c_long to c_int with padding, \ @@ -474,14 +474,14 @@ s! { )] pub ut_session: c_long, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] #[cfg(not(target_endian = "little"))] __ut_pad2: Padding, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] pub ut_session: c_int, - #[cfg(musl_v1_2_3)] + #[cfg(musl_v1_2)] #[cfg(target_endian = "little")] __ut_pad2: Padding, @@ -599,7 +599,7 @@ pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; // Value was changed in 1.2.4 -pub const CPU_SETSIZE: c_int = if cfg!(musl_v1_2_3) { 1024 } else { 128 }; +pub const CPU_SETSIZE: c_int = if cfg!(musl_v1_2) { 1024 } else { 128 }; pub const PTRACE_TRACEME: c_int = 0; pub const PTRACE_PEEKTEXT: c_int = 1; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index f4e2090669c9b..fc4d6c3c1594f 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -270,7 +270,7 @@ cfg_if! { if #[cfg(any( target_env = "gnu", target_os = "android", - all(target_env = "musl", musl_v1_2_3) + all(target_env = "musl", musl_v1_2) ))] { s! { pub struct statx { @@ -1650,7 +1650,7 @@ cfg_if! { if #[cfg(any( target_env = "gnu", target_os = "android", - all(target_env = "musl", musl_v1_2_3), + all(target_env = "musl", musl_v1_2), target_os = "l4re" ))] { pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; @@ -2230,7 +2230,7 @@ cfg_if! { if #[cfg(any( target_env = "gnu", target_os = "android", - all(target_env = "musl", musl_v1_2_3) + all(target_env = "musl", musl_v1_2) ))] { extern "C" { pub fn statx( From cbd5bd0034e1e925f511a002a43138ea0db4b4ea Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 11 Aug 2026 05:49:30 -0400 Subject: [PATCH 19/88] test: Update skips on musl (backport ) (cherry picked from commit 111660a59adb7ef20933f2ade46598ba2ed7c44d) --- libc-test/build/main.rs | 19 ++++++++----------- src/unix/linux_like/linux_l4re_shared.rs | 4 ++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 189b005684e5a..d5dfff3acecb4 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4642,16 +4642,10 @@ fn test_linux(target: &str) { } } if musl { - // LFS64 types have been removed in musl 1.2.4+ - if name.starts_with("RLIM64") { - return true; - } - // CI fails because musl targets use Linux v4 kernel - if name.starts_with("NI_IDN") { - return true; - } - match name { + // LFS64 types have been removed in musl 1.2.4+ + x if x.starts_with("RLIM64") && musl_v1_2 => return true, + // FIXME: Does not exist on non-x86 architectures, slated for removal // in libc in 1.0 "MAP_32BIT" if ppc64 => return true, @@ -4703,11 +4697,14 @@ fn test_linux(target: &str) { | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => return true, + // Not present in musl, deprecated in libc. + "NI_IDN" => return true, + /* Added in versions more recent than what we test */ // Since 1.2.0 - "SO_DETACH_REUSEPORT_BPF" => return true, + "SO_DETACH_REUSEPORT_BPF" if old_musl => return true, // Since 1.2.3 - "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" => return true, + "SO_BUSY_POLL_BUDGET" | "SO_PREFER_BUSY_POLL" if old_musl => return true, // FIXME(musl): value was updated in new musl "RLIM_NLIMITS" => return true, diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 60a9138ef4781..ae6f57c9c45a2 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1005,6 +1005,10 @@ pub const NI_NOFQDN: c_int = 4; pub const NI_NAMEREQD: c_int = 8; pub const NI_DGRAM: c_int = 16; #[cfg(not(target_env = "uclibc"))] +#[cfg_attr( + target_env = "musl", + deprecated(since = "0.2.190", note = "not present in musl") +)] pub const NI_IDN: c_int = 32; cfg_if! { From 48b96f38e56255de5ee62ca2218506a5ebd26499 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 28 Jun 2023 19:52:06 +0100 Subject: [PATCH 20/88] android 32 bits fix stat struct proposal. close #3285 (backport ) (cherry picked from commit de7182906cf77b615f2897ba83ba65a6bdaa0065) --- src/unix/linux_like/android/b32/mod.rs | 45 +++++++++++++------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 056200313a33a..99a53b1d3edc8 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -25,47 +25,46 @@ s! { } pub struct stat { - pub st_dev: c_ulonglong, - __pad0: Padding<[c_uchar; 4]>, - __st_ino: crate::ino_t, - pub st_mode: c_uint, + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: c_ushort, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: c_ulonglong, - __pad3: Padding<[c_uchar; 4]>, - pub st_size: c_longlong, + pub st_rdev: crate::dev_t, + pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, - pub st_blocks: c_ulonglong, - pub st_atime: c_long, - pub st_atime_nsec: c_long, - pub st_mtime: c_long, - pub st_mtime_nsec: c_long, - pub st_ctime: c_long, - pub st_ctime_nsec: c_long, - pub st_ino: c_ulonglong, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_ulong, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_ulong, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_ulong, + __unused4: Padding, + __unused5: Padding, } pub struct stat64 { - pub st_dev: c_ulonglong, + pub st_dev: crate::dev_t, __pad0: Padding<[c_uchar; 4]>, __st_ino: crate::ino_t, pub st_mode: c_uint, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: c_ulonglong, + pub st_rdev: crate::dev_t, __pad3: Padding<[c_uchar; 4]>, - pub st_size: c_longlong, + pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, - pub st_blocks: c_ulonglong, - pub st_atime: c_long, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, pub st_atime_nsec: c_long, - pub st_mtime: c_long, + pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, - pub st_ctime: c_long, + pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - pub st_ino: c_ulonglong, + pub st_ino: crate::dev_t, } pub struct statfs64 { From a44b68268dfaa58f2786ea13d213396cfc31129e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 10 Aug 2026 15:42:24 +0100 Subject: [PATCH 21/88] android: match bionic for 32-bit `stat`, alias `stat64` On LP32 `dev_t`, `ino_t`, `off_t` and `blkcnt_t` are 32-bit while `__STAT64_BODY` uses wider fields, so keep bionic's layout and only use `time_t`, which does match. Bionic declares `stat` and `stat64` with the same macro, so make `stat64` an alias. (backport ) (cherry picked from commit 0f136e82b9de3a35a430439d598bf6b53b88b059) --- libc-test/build/main.rs | 3 +++ src/unix/linux_like/android/b32/mod.rs | 37 ++++++++------------------ 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index d5dfff3acecb4..5c59370a35f11 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -2225,6 +2225,9 @@ fn test_android(target: &str) { cfg.rename_type(move |ty| match ty { "Ioctl" => Some("int".to_string()), + // `stat64` is an alias of `struct stat`, so it needs the "struct" prefix: + // the bare name refers to the `stat64()` function in C. + "stat64" => Some("struct stat64".to_string()), _ => None, }); diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 99a53b1d3edc8..4f298d7041801 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -8,6 +8,9 @@ pub type off64_t = c_longlong; pub type sigset_t = c_ulong; pub type socklen_t = i32; pub type time64_t = i64; +// `struct stat64` is a synonym for `struct stat`, provided by Bionic for source +// compatibility with other systems. +pub type stat64 = stat; s! { // FIXME(1.0): This should not implement `PartialEq` @@ -24,47 +27,29 @@ s! { pub rlim_max: u64, } + // Note that the 32-bit `dev_t`, `ino_t`, `off_t` and `blkcnt_t` typedefs do + // not match the wider fields Bionic actually uses here, so they cannot be + // spelled with those aliases. pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: c_ushort, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_size: crate::off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_ulong, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_ulong, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_ulong, - __unused4: Padding, - __unused5: Padding, - } - - pub struct stat64 { - pub st_dev: crate::dev_t, + pub st_dev: c_ulonglong, __pad0: Padding<[c_uchar; 4]>, __st_ino: crate::ino_t, pub st_mode: c_uint, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, + pub st_rdev: c_ulonglong, __pad3: Padding<[c_uchar; 4]>, - pub st_size: crate::off_t, + pub st_size: c_longlong, pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, + pub st_blocks: c_ulonglong, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, pub st_mtime: crate::time_t, pub st_mtime_nsec: c_long, pub st_ctime: crate::time_t, pub st_ctime_nsec: c_long, - pub st_ino: crate::dev_t, + pub st_ino: c_ulonglong, } pub struct statfs64 { From 740c09425115da082300c23f5e1e87719f3579f0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 6 Aug 2026 03:55:42 -0500 Subject: [PATCH 22/88] test: Migrate from string comparisons to parsing `target_*` cfg (backport ) (cherry picked from commit 861c4fe35b946e638b67d78df33f11157e2fd936) --- libc-test/build/main.rs | 372 ++++++++++++++++++-------------------- libc-test/build/target.rs | 328 +++++++++++++++++++++++++++++++++ 2 files changed, 504 insertions(+), 196 deletions(-) create mode 100644 libc-test/build/target.rs diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 5c59370a35f11..6205d06a5ac13 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -1,6 +1,7 @@ #![allow(clippy::match_like_matches_macro)] mod semver; +mod target; use std::env; use std::env::VarError; @@ -13,76 +14,71 @@ use std::sync::LazyLock; use regex::Regex; -fn do_cc() { - // NOTE: family could be one of: unix, windows, wasm, or multiple values - // (e.g. "unix,wasm") - let family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); - let target = env::var("TARGET").unwrap(); - if family.contains("unix") || target.contains("cygwin") { - let exclude = ["redox", "wasi", "wali", "qurt"]; - if !exclude.iter().any(|x| target.contains(x)) { +use crate::target::PointerWidth::P32; +use crate::target::Target; + +fn do_cc(t: &Target) { + if t.families.iter().any(|x| x == "unix") || t.cygwin() { + let exclude = t.redox() || t.wasi() || t.wali() || t.qurt(); + if !exclude { let mut cmsg = cc::Build::new(); cmsg.file("src/cmsg.c"); - if target.contains("solaris") || target.contains("illumos") { + if t.solaris() || t.illumos() { cmsg.define("_XOPEN_SOURCE", "700"); } cmsg.compile("cmsg"); } - if (target.contains("linux") && !target.contains("wasm32")) - || target.contains("android") - || target.contains("emscripten") - || target.contains("fuchsia") - || target.contains("dragonfly") - || target.contains("bsd") - || target.contains("cygwin") + if t.linux() + || t.android() + || t.emscripten() + || t.fuchsia() + || t.dragonfly() + || t.triple.contains("bsd") + || t.cygwin() { cc::Build::new().file("src/makedev.c").compile("makedev"); } } - if target.contains("android") || (target.contains("linux") && !target.contains("wasm32")) { + if (t.android() || t.linux()) && !t.wali() { cc::Build::new().file("src/errqueue.c").compile("errqueue"); } - if target.contains("linux") && !target.contains("android") && !target.contains("wasm32") { + if t.linux() && !t.wali() { cc::Build::new().file("src/nlmsg.c").compile("nlmsg"); } - if (target.contains("linux") && !target.contains("wasm32")) - || target.contains("l4re") - || target.contains("android") - || target.contains("emscripten") - || target.contains("solaris") - || target.contains("illumos") + if (t.linux() || t.l4re() || t.android() || t.emscripten() || t.solaris() || t.illumos()) + && !t.wali() { cc::Build::new().file("src/sigrt.c").compile("sigrt"); } } -fn do_ctest() { - match &env::var("TARGET").unwrap() { - t if t.contains("android") => test_android(t), - t if t.contains("apple") => test_apple(t), - t if t.contains("dragonfly") => test_dragonflybsd(t), - t if t.contains("emscripten") => test_emscripten(t), - t if t.contains("freebsd") => test_freebsd(t), - t if t.contains("haiku") => test_haiku(t), - t if t.contains("l4re") => test_linux(t), - t if t.contains("linux") => test_linux(t), - t if t.contains("netbsd") => test_netbsd(t), - t if t.contains("openbsd") => test_openbsd(t), - t if t.contains("cygwin") => test_cygwin(t), - t if t.contains("redox") => test_redox(t), - t if t.contains("solaris") => test_solarish(t), - t if t.contains("illumos") => test_solarish(t), - t if t.contains("wasi") => test_wasi(t), - t if t.contains("windows") => test_windows(t), - t if t.contains("vxworks") => test_vxworks(t), - t if t.contains("nto-qnx") => test_neutrino(t), +fn do_ctest(t: &Target) { + match t { + t if t.android() => test_android(t), + t if t.apple() => test_apple(t), + t if t.dragonfly() => test_dragonflybsd(t), + t if t.emscripten() => test_emscripten(t), + t if t.freebsd() => test_freebsd(t), + t if t.haiku() => test_haiku(t), + t if t.l4re() => test_linux(t), + t if t.linux() => test_linux(t), + t if t.netbsd() => test_netbsd(t), + t if t.openbsd() => test_openbsd(t), + t if t.cygwin() => test_cygwin(t), + t if t.redox() => test_redox(t), + t if t.solaris() => test_solarish(t), + t if t.illumos() => test_solarish(t), + t if t.wasi() => test_wasi(t), + t if t.win() => test_windows(t), + t if t.vxworks() => test_vxworks(t), + t if t.nto() => test_neutrino(t), // QuRT ctest requires a sched_yield stub (static inline in SDK). - t if t.contains("qurt") => return, - t if t.contains("aix") => return test_aix(t), - t => panic!("unknown target {t}"), + t if t.qurt() => return, + t if t.aix() => return test_aix(t), + t => panic!("unknown target {t:?}"), } } @@ -105,11 +101,13 @@ fn ctest_cfg() -> ctest::TestGenerator { fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=."); + let t = Target::from_env(); + // Ensure version checking works, even if we don't use it. LazyLock::force(&VERSIONS); - do_cc(); - do_ctest(); + do_cc(&t); + do_ctest(&t); semver::do_semver(); } @@ -135,10 +133,10 @@ macro_rules! headers { }; } -fn test_apple(target: &str) { - assert!(target.contains("apple")); - let x86_64 = target.contains("x86_64"); - let i686 = target.contains("i686"); +fn test_apple(t: &Target) { + assert!(t.apple()); + let x86_64 = t.x86_64(); + let x86_32 = t.x86_32(); let macos = VERSIONS.macos; let mut cfg = ctest_cfg(); @@ -387,20 +385,20 @@ fn test_apple(target: &str) { cfg.skip_roundtrip(move |s| match s { // FIXME(macos): this type has the wrong ABI - "max_align_t" if i686 => true, + "max_align_t" if x86_32 => true, _ => false, }); ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_openbsd(target: &str) { - assert!(target.contains("openbsd")); +fn test_openbsd(t: &Target) { + assert!(t.openbsd()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - let x86_64 = target.contains("x86_64"); + let x86_64 = t.x86_64(); headers!( cfg, @@ -603,8 +601,8 @@ fn test_openbsd(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_cygwin(target: &str) { - assert!(target.contains("cygwin")); +fn test_cygwin(t: &Target) { + assert!(t.cygwin()); let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); @@ -777,14 +775,14 @@ fn test_cygwin(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_windows(target: &str) { - assert!(target.contains("windows")); - let gnu = target.contains("gnu"); - let i686 = target.contains("i686"); +fn test_windows(t: &Target) { + assert!(t.win()); + let gnu = t.gnu(); + let x86_32 = t.x86_32(); let mut cfg = ctest_cfg(); - if target.contains("msvc") { + if t.msvc() { cfg.flag("/wd4324"); } cfg.define("_WIN32_WINNT", Some("0x8000")); @@ -801,7 +799,7 @@ fn test_windows(target: &str) { // Needed for the Windows `time_t` test. println!("cargo::rustc-check-cfg=cfg(gnu_time_bits64)"); - if i686 && gnu && win_gnu_x86_time64 { + if x86_32 && gnu && win_gnu_x86_time64 { cfg.cfg("gnu_time_bits64", None); println!("cargo::rustc-cfg=gnu_time_bits64"); } @@ -863,14 +861,14 @@ fn test_windows(target: &str) { "SSIZE_T" if !gnu => true, "ssize_t" if !gnu => true, // FIXME(windows): The size and alignment of this type are incorrect - "time_t" if gnu && i686 && !win_gnu_x86_time64 => true, + "time_t" if gnu && x86_32 && !win_gnu_x86_time64 => true, _ => false, }); cfg.skip_struct(move |struct_| { match struct_.ident() { // FIXME(windows): The size and alignment of this struct are incorrect - "timespec" if gnu && i686 => true, + "timespec" if gnu && x86_32 => true, // Extern types "FILE" | "fpos_t" | "timezone" => true, _ => false, @@ -917,8 +915,8 @@ fn test_windows(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_redox(target: &str) { - assert!(target.contains("redox")); +fn test_redox(t: &Target) { + assert!(t.redox()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -967,10 +965,10 @@ fn test_redox(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_solarish(target: &str) { - let is_solaris = target.contains("solaris"); - let is_illumos = target.contains("illumos"); - assert!(is_solaris || is_illumos); +fn test_solarish(t: &Target) { + let solaris = t.solaris(); + let illumos = t.illumos(); + assert!(solaris || illumos); // ctest generates arguments supported only by clang, so make sure to run with CC=clang. // While debugging, "CFLAGS=-ferror-limit=" is useful to get more error output. @@ -983,7 +981,7 @@ fn test_solarish(target: &str) { // FIXME(solaris): This should be removed once new Nix crate is released. // See comment in src/unix/solarish/solaris.rs for these. - if is_solaris { + if solaris { cfg.define("O_DIRECT", Some("0x2000000")); cfg.define("SIGINFO", Some("41")); } @@ -1070,11 +1068,11 @@ fn test_solarish(target: &str) { "wchar.h", ); - if is_illumos { + if illumos { headers!(cfg, "sys/epoll.h", "sys/eventfd.h", "sys/timerfd.h",); } - if is_solaris { + if solaris { headers!(cfg, "sys/lgrp_user_impl.h",); } @@ -1132,7 +1130,7 @@ fn test_solarish(target: &str) { // EPOLLEXCLUSIVE is a relatively recent addition to the epoll interface and may not be // defined on older systems. It is, however, safe to use on systems which do not // explicitly support it. (A no-op is an acceptable implementation of EPOLLEXCLUSIVE.) - "EPOLLEXCLUSIVE" if is_illumos => true, + "EPOLLEXCLUSIVE" if illumos => true, // FIXME(illumos) // illumos has changed this constant, see https://www.illumos.org/issues/16200 for details. @@ -1141,7 +1139,7 @@ fn test_solarish(target: &str) { // https://github.com/illumos/sysroot/pull/5, however this will still predate the new value. // When this does eventually make it to the sysroot we should update it in this crate and // remove this test skip. - "PTHREAD_MUTEX_DEFAULT" if is_illumos => true, + "PTHREAD_MUTEX_DEFAULT" if illumos => true, _ => false, }); @@ -1160,7 +1158,7 @@ fn test_solarish(target: &str) { // the union handling is a mess x if x.contains("door_desc_t_") => true, // a bunch of solaris-only fields - "utmpx" if is_illumos => true, + "utmpx" if illumos => true, // Extern types "DIR" | "FILE" | "fpos_t" | "timezone" | "ucred_t" => true, @@ -1198,7 +1196,7 @@ fn test_solarish(target: &str) { // The LX brand (integrated into some illumos distros) commandeered several of the // `uc_filler` fields to use for brand-specific state. - ("ucontext_t", "uc_filler" | "uc_brand_data") if is_illumos => true, + ("ucontext_t", "uc_filler" | "uc_brand_data") if illumos => true, _ => false, } @@ -1231,9 +1229,9 @@ fn test_solarish(target: &str) { "fexecve" => true, // Solaris-different - "getpwent_r" | "getgrent_r" | "updwtmpx" if is_illumos => true, - "madvise" | "mprotect" if is_illumos => true, - "door_call" | "door_return" | "door_create" if is_illumos => true, + "getpwent_r" | "getgrent_r" | "updwtmpx" if illumos => true, + "madvise" | "mprotect" if illumos => true, + "door_call" | "door_return" | "door_create" if illumos => true, // The compat functions use these "native" functions linked to their // non-prefixed implementations in libc. @@ -1251,7 +1249,7 @@ fn test_solarish(target: &str) { // redefine_extname symbol in order to preserve compatibility. // Until better symbol binding story is figured out, it must be // excluded from the tests. - "getifaddrs" if is_illumos => true, + "getifaddrs" if illumos => true, // FIXME(ctest): Our API is unsound. The Rust API allows aliasing // pointers, but the C API requires pointers not to alias. @@ -1261,7 +1259,7 @@ fn test_solarish(target: &str) { // Exists on illumos too but, for now, is // [a recent addition](https://www.illumos.org/issues/17094). - "secure_getenv" if is_illumos => true, + "secure_getenv" if illumos => true, _ => false, } @@ -1270,8 +1268,8 @@ fn test_solarish(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_netbsd(target: &str) { - assert!(target.contains("netbsd")); +fn test_netbsd(t: &Target) { + assert!(t.netbsd()); let mut cfg = ctest_cfg(); // Assume netbsd10 but check for netbsd9 for test config. @@ -1581,8 +1579,8 @@ fn test_netbsd(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_dragonflybsd(target: &str) { - assert!(target.contains("dragonfly")); +fn test_dragonflybsd(t: &Target) { + assert!(t.dragonfly()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -1945,9 +1943,9 @@ fn which_dragonfly() -> Option { parse_dragonfly_version(stdout.trim()) } -fn test_wasi(target: &str) { - assert!(target.contains("wasi")); - let p2 = target.contains("wasip2"); +fn test_wasi(t: &Target) { + assert!(t.wasi()); + let p2 = t.wasip2(); let wasi_sdk = VERSIONS.wasi_sdk.unwrap(); let mut cfg = ctest_cfg(); @@ -2057,15 +2055,10 @@ fn test_wasi(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_android(target: &str) { - assert!(target.contains("android")); - let target_pointer_width = match target { - t if t.contains("aarch64") || t.contains("x86_64") => 64, - t if t.contains("i686") || t.contains("arm") => 32, - t => panic!("unsupported target: {t}"), - }; - let x86 = target.contains("i686") || target.contains("x86_64"); - let aarch64 = target.contains("aarch64"); +fn test_android(t: &Target) { + assert!(t.android()); + let x86 = t.x86(); + let aarch64 = t.aarch64(); // The API level the NDK toolchain targets, which caps the available libc // API surface (see `Versions`). Detection is required, so unwrap and let a // toolchain we can't read fail loudly rather than silently skip every test. @@ -2169,7 +2162,7 @@ fn test_android(target: &str) { "xlocale.h", // time64_t is not defined for 64-bit targets If included it will // generate the error 'Your time_t is already 64-bit' - (target_pointer_width == 32, "time64.h"), + (t.p32(), "time64.h"), (x86, "sys/reg.h"), ); @@ -2560,11 +2553,11 @@ fn test_android(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); - test_linux_like_apis(target); + test_linux_like_apis(t); } -fn test_freebsd(target: &str) { - assert!(target.contains("freebsd")); +fn test_freebsd(t: &Target) { + assert!(t.freebsd()); let mut cfg = ctest_cfg(); // FIXME: this can be removed in 1-2 releases @@ -3268,7 +3261,7 @@ fn test_freebsd(target: &str) { _ => false, } }); - if target.contains("arm") { + if t.arm32() { cfg.skip_roundtrip(move |s| match s { // Can't return an array from a C function. "__gregset_t" => true, @@ -3282,8 +3275,8 @@ fn test_freebsd(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_emscripten(target: &str) { - assert!(target.contains("emscripten")); +fn test_emscripten(t: &Target) { + assert!(t.emscripten()); let emscripten = VERSIONS.emscripten.unwrap(); let mut cfg = ctest_cfg(); @@ -3538,11 +3531,11 @@ fn test_emscripten(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_neutrino(target: &str) { - assert!(target.contains("nto-qnx")); +fn test_neutrino(t: &Target) { + assert!(t.nto()); let mut cfg = ctest_cfg(); - if target.ends_with("_iosock") { + if t.nto_iosock() { let qnx_target_val = env::var("QNX_TARGET") .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); @@ -3834,8 +3827,8 @@ fn which_vxworks() -> Option<(u32, u32)> { Some((major, minor)) } -fn test_vxworks(target: &str) { - assert!(target.contains("vxworks")); +fn test_vxworks(t: &Target) { + assert!(t.vxworks()); let mut cfg = ctest_cfg(); @@ -3973,14 +3966,8 @@ fn test_vxworks(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { - let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); - if target.contains("gnu") - && target.contains("linux") - && !target.ends_with("x32") - && !target.contains("riscv32") - && pointer_width == "32" - { +fn config_gnu_bits(t: &Target, cfg: &mut ctest::TestGenerator) { + if t.gnu() && t.linux() && !t.x32() && !t.riscv32() && t.pointer_width == P32 { let defaultbits = "32"; let mut tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS"); @@ -4022,24 +4009,17 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { } // This also covers the L4Re targets since they have a similar API surface -fn test_linux(target: &str) { - assert!(target.contains("linux") || target.contains("l4re")); - - // FIXME(linux32): Some 32 bit targets use old kernel headers because newer distros enforce 64 - // bit time. Use this to avoid skipping tests also on 64 bit targets. - let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH") - .unwrap_or_default() - .parse::() - .unwrap_or_default(); +fn test_linux(t: &Target) { + assert!(t.linux() || t.l4re()); // target_os - let linux = target.contains("linux"); - let l4re = target.contains("l4re"); + let linux = t.linux(); + let l4re = t.l4re(); // target_env - let gnu = target.contains("gnu"); - let musl = target.contains("musl") || target.contains("ohos") || target.contains("pauthtest"); - let uclibc = target.contains("uclibc"); + let gnu = t.gnu(); + let musl = t.musl(); + let uclibc = t.uclibc(); match (l4re, gnu, musl, uclibc) { (false, true, false, false) => (), @@ -4052,38 +4032,35 @@ fn test_linux(target: &str) { ), } - let arm = target.contains("arm"); - let eabihf = target.contains("eabihf"); - let aarch64 = target.contains("aarch64"); - let i686 = target.contains("i686"); - let ppc = target.contains("powerpc"); - let ppc64 = target.contains("powerpc64"); - let ppc64le = target.contains("powerpc64le"); - let _ppc64be = target.contains("powerpc64-"); - let ppc32 = ppc && !ppc64; - let s390x = target.contains("s390x"); - let sparc = target.contains("sparc"); - let sparc64 = target.contains("sparc64"); - let x32 = target.contains("x32"); - let x86_32 = target.contains("i686"); - let x86_64 = target.contains("x86_64"); - let gnueabihf = target.contains("gnueabihf"); - let x86_64_gnux32 = target.contains("gnux32") && x86_64; - let riscv64 = target.contains("riscv64"); - let hexagon = target.contains("hexagon"); - let loongarch64 = target.contains("loongarch64"); - let wasm32 = target.contains("wasm32"); - let uclibc = target.contains("uclibc"); - let mips = target.contains("mips"); - let mips64 = target.contains("mips64"); - let mips32 = mips && !mips64; - let pauthtest = target.contains("pauthtest"); - let b32 = arm || target.contains("hexagon") || mips32 || ppc32 || x86_32; + let arm32 = t.arm32(); + let eabihf = t.eabihf(); + let aarch64 = t.aarch64(); + let ppc = t.ppc(); + let ppc64 = t.ppc64(); + let ppc64le = t.ppc64le(); + let ppc32 = t.ppc32(); + let s390x = t.s390x(); + let sparc = t.sparc(); + let sparc64 = t.sparc64(); + let x32 = t.x32(); + let x86_32 = t.x86_32(); + let x86_64 = t.x86_64(); + let gnueabihf = t.eabihf() && t.gnu(); + let x86_64_gnux32 = x86_64 && t.gnu() && x32; + let riscv64 = t.riscv64(); + let hexagon = t.hexagon(); + let loongarch64 = t.loongarch64(); + let wasm32 = t.wasm32(); + let uclibc = t.uclibc(); + let mips = t.mips(); + let mips32 = t.mips32(); + let pauthtest = t.pauthtest(); + let p32 = t.p32(); let versions = &*VERSIONS; let kernel = match versions.linux { Some(v) => v, None if l4re => (0, 0), - None => panic!("failed to detect kernel version for Linux target {target}"), + None => panic!("failed to detect kernel version for Linux target {t:?}",), }; let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); @@ -4102,11 +4079,11 @@ fn test_linux(target: &str) { if musl_v1_2 { cfg.cfg("musl_v1_2", None); - if b32 { + if p32 { cfg.cfg("musl32_time64", None); cfg.cfg("linux_time_bits64", None); } - if arm || ppc32 || x86_32 || mips32 { + if arm32 || ppc32 || x86_32 || mips32 { cfg.cfg("musl_redir_time64", None); } } @@ -4121,7 +4098,7 @@ fn test_linux(target: &str) { // glibc versions older than 2.29. .define("__GLIBC_USE_DEPRECATED_SCANF", None); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); // The L4Re libc headers contain some L4Re helper functions which are not needed for the libc // interface and must not be added to the libc crate if l4re { @@ -4231,7 +4208,10 @@ fn test_linux(target: &str) { // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 // Also unavailable on gnueabihf with glibc 2.30. // https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1 - ((x86_64 || x86_32 || arm) && !gnueabihf && !l4re, "sys/io.h"), + ( + (x86_64 || x86_32 || arm32) && !gnueabihf && !l4re, + "sys/io.h" + ), // `sys/reg.h` is only available on x86 and x86_64 ((x86_64 || x86_32) && !l4re, "sys/reg.h"), // sysctl system call is deprecated and not available on musl @@ -4512,7 +4492,7 @@ fn test_linux(target: &str) { // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 // The previous version of the struct was removed in 6.11 due to a bug. // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f - "xdp_umem_reg" if musl || pointer_width == 32 => true, + "xdp_umem_reg" if musl || p32 => true, // FIXME(1.0,linux): A new field was added to `xsk_tx_metadata_request` in linux 6.15. // https://github.com/torvalds/linux/commit/ca4419f15abd19ba8be1e109661b60f9f5b6c9f0 @@ -4559,7 +4539,7 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.16 kernel headers. // On 64 bits the size did not change, skip only for 32 bits. - "ptrace_syscall_info" if pointer_width == 32 => true, + "ptrace_syscall_info" if p32 => true, // not in sys/fanotify.h in uclibc "fanotify_event_info_header" | "fanotify_event_info_fid" if uclibc => true, @@ -4925,11 +4905,11 @@ fn test_linux(target: &str) { "SOMAXCONN" if gnu => true, // Requires >= 6.9 kernel headers. - n if (arm || ppc32) && n.starts_with("FUTEX2_") => kernel < (6, 9), + n if (arm32 || ppc32) && n.starts_with("FUTEX2_") => kernel < (6, 9), // FIXME(linux): Not defined on ARM, gnueabihf, mips, musl, PowerPC, riscv64, s390x, and sparc64. "SYS_memfd_secret" - if arm | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => + if arm32 | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => { true } @@ -5006,7 +4986,7 @@ fn test_linux(target: &str) { } // FIXME(linux32): Requires >= 6.6 kernel headers. - "XDP_USE_SG" | "XDP_PKT_CONTD" if pointer_width == 32 => kernel < (6, 6), + "XDP_USE_SG" | "XDP_PKT_CONTD" if p32 => kernel < (6, 6), // FIXME(linux): Missing only on this platform for some reason "PR_MDWE_NO_INHERIT" if gnueabihf => true, @@ -5017,7 +4997,7 @@ fn test_linux(target: &str) { | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" | "XDP_TX_METADATA" - if musl || pointer_width == 32 => + if musl || p32 => { musl || kernel < (6, 8) } @@ -5299,7 +5279,7 @@ fn test_linux(target: &str) { ("timex", f) if f.starts_with("__unused") => true, // // FIXME(linux): It now takes mode_t since glibc 2.31 on some targets. ("ipc_perm", "mode") - if ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32) => + if ((x86_64 || x86_32 || arm32 || riscv64) && gnu || x86_64_gnux32) => { true } @@ -5319,7 +5299,7 @@ fn test_linux(target: &str) { // the `ifc_ifcu` field is an anonymous union ("ifconf", "ifc_ifcu") => true, // glibc uses a single array `uregs` instead of individual fields. - ("user_regs", _) if arm => true, + ("user_regs", _) if arm32 => true, // the `ifr_ifrn` field is an anonymous union ("iwreq", "ifr_ifrn") => true, // the `key` field is a zero-sized array @@ -5390,7 +5370,7 @@ fn test_linux(target: &str) { "bcm_msg_head" => true, // FIXME(linux): the call ABI of max_align_t is incorrect on these platforms: - "max_align_t" if i686 => true, + "max_align_t" if x86_32 => true, _ => false, }); @@ -5435,25 +5415,25 @@ fn test_linux(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); if !l4re { - test_linux_like_apis(target); + test_linux_like_apis(t); } } // This function tests APIs that are incompatible to test when other APIs // are included (e.g. because including both sets of headers clashes) -fn test_linux_like_apis(target: &str) { - let gnu = target.contains("gnu"); - let musl = target.contains("musl") || target.contains("ohos") || target.contains("pauthtest"); - let linux = target.contains("linux"); - let wali = target.contains("linux") && target.contains("wasm32"); - let emscripten = target.contains("emscripten"); - let android = target.contains("android"); +fn test_linux_like_apis(t: &Target) { + let gnu = t.gnu(); + let musl = t.musl(); + let linux = t.linux(); + let wali = t.wali(); + let emscripten = t.emscripten(); + let android = t.android(); assert!(linux || android || emscripten); let mut cfg = ctest_cfg(); if linux || android || emscripten { // test strerror_r from the `string.h` header - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); cfg.header("string.h") .skip_alias(|_| true) @@ -5486,7 +5466,7 @@ fn test_linux_like_apis(target: &str) { .skip_fn(|_| true) .skip_const(move |constant| !fnctl_constants.contains(&constant.ident())); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); if musl { cfg.header("fcntl.h"); } else { @@ -5499,7 +5479,7 @@ fn test_linux_like_apis(target: &str) { let mut cfg = ctest_cfg(); if (linux && !wali) || android { // test termios - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); let termios_constants = [ "BOTHER", "IBSHIFT", "TCGETS2", "TCSETS2", "TCSETSW2", "TCSETSF2", @@ -5538,7 +5518,7 @@ fn test_linux_like_apis(target: &str) { .skip_union(|_| true) .skip_const(move |constant| !ipv6_constants.contains(&constant.ident())); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); headers!(cfg, "linux/in6.h",); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_ipv6.rs").unwrap(); @@ -5560,7 +5540,7 @@ fn test_linux_like_apis(target: &str) { .skip_struct(move |struct_| !elf_structs.contains(&struct_.ident())) .skip_alias(move |alias| !elf_structs.contains(&alias.ident())); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_elf.rs").unwrap(); } @@ -5568,7 +5548,7 @@ fn test_linux_like_apis(target: &str) { if (linux && !wali) || android { // Test `ARPHRD_CAN`. let mut cfg = ctest_cfg(); - config_gnu_bits(target, &mut cfg); + config_gnu_bits(t, &mut cfg); cfg.header("linux/if_arp.h") .skip_fn(|_| true) .skip_static(|_| true) @@ -5582,8 +5562,8 @@ fn test_linux_like_apis(target: &str) { } } -fn test_haiku(target: &str) { - assert!(target.contains("haiku")); +fn test_haiku(t: &Target) { + assert!(t.haiku()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); @@ -5915,8 +5895,8 @@ fn test_haiku(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } -fn test_aix(target: &str) { - assert!(target.contains("aix")); +fn test_aix(t: &Target) { + assert!(t.aix()); // ctest generates arguments supported only by clang, so make sure to // run with CC=clang. While debugging, "CFLAGS=-ferror-limit=" @@ -6217,8 +6197,8 @@ fn test_aix(target: &str) { // QuRT ctest is disabled: sched_yield is static inline in the SDK (no // linkable symbol). A stub or --defsym is needed. The semver test works. #[allow(dead_code)] -fn test_qurt(target: &str) { - assert!(target.contains("qurt")); +fn test_qurt(t: &Target) { + assert!(t.qurt()); let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); diff --git a/libc-test/build/target.rs b/libc-test/build/target.rs new file mode 100644 index 0000000000000..2d80e30d79a9d --- /dev/null +++ b/libc-test/build/target.rs @@ -0,0 +1,328 @@ +use std::env; +use std::path::PathBuf; + +#[derive(Debug)] +#[allow(dead_code)] +pub struct Target { + // Info about the target + pub triple: String, + pub triple_split: Vec, + pub arch: String, + pub abi: String, + pub endian: Endian, + pub env: String, + pub families: Vec, + pub os: String, + pub pointer_width: PointerWidth, + pub target_features: Vec, + pub vendor: String, + + // General build info + pub manifest_dir: PathBuf, + pub out_dir: PathBuf, + pub cargo_features: Vec, +} + +impl Target { + pub fn from_env() -> Self { + let triple = env::var("TARGET").unwrap(); + let triple_split = triple.split('-').map(ToOwned::to_owned).collect(); + let families = env::var("CARGO_CFG_TARGET_FAMILY") + .map(|feats| feats.split(',').map(ToOwned::to_owned).collect()) + .unwrap_or_default(); + let target_features = env::var("CARGO_CFG_TARGET_FEATURE") + .map(|feats| feats.split(',').map(ToOwned::to_owned).collect()) + .unwrap_or_default(); + let cargo_features = env::vars() + .filter_map(|(name, _value)| name.strip_prefix("CARGO_FEATURE_").map(ToOwned::to_owned)) + .map(|s| s.to_lowercase().replace("_", "-")) + .collect(); + let pointer_width = match env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap().as_str() { + "32" => PointerWidth::P32, + "64" => PointerWidth::P64, + x => panic!("unsupported pointer width {x}"), + }; + let endian = match env::var("CARGO_CFG_TARGET_ENDIAN").unwrap().as_str() { + "little" => Endian::Little, + "big" => Endian::Big, + x => panic!("unsupported endian {x}"), + }; + + Self { + triple, + triple_split, + arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(), + abi: env::var("CARGO_CFG_TARGET_ABI").unwrap(), + endian, + env: env::var("CARGO_CFG_TARGET_ENV").unwrap(), + families, + os: env::var("CARGO_CFG_TARGET_OS").unwrap(), + pointer_width, + target_features, + vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(), + + manifest_dir: PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()), + out_dir: PathBuf::from(env::var("OUT_DIR").unwrap()), + cargo_features, + } + } +} + +#[allow(dead_code)] +impl Target { + /* arch */ + + pub fn aarch64(&self) -> bool { + self.arch == "aarch64" + } + + pub fn arm32(&self) -> bool { + self.arch == "arm" + } + + pub fn hexagon(&self) -> bool { + self.arch == "hexagon" + } + + pub fn loongarch32(&self) -> bool { + self.arch == "loongarch32" + } + + pub fn loongarch64(&self) -> bool { + self.arch == "loongarch64" + } + + pub fn loongarch(&self) -> bool { + self.loongarch32() || self.loongarch64() + } + + pub fn mips32(&self) -> bool { + self.arch == "mips32" || self.arch == "mips32r6" + } + + pub fn mips64(&self) -> bool { + self.arch == "mips64" || self.arch == "mips64r6" + } + + pub fn mips(&self) -> bool { + self.mips32() || self.mips64() + } + + pub fn ppc32(&self) -> bool { + self.arch == "powerpc" + } + + pub fn ppc64(&self) -> bool { + self.arch == "powerpc64" + } + + pub fn ppc64be(&self) -> bool { + self.ppc64() && self.endian == Endian::Big + } + + pub fn ppc64le(&self) -> bool { + self.ppc64() && self.endian == Endian::Little + } + + pub fn ppc(&self) -> bool { + self.ppc32() || self.ppc64() + } + + pub fn riscv32(&self) -> bool { + self.arch == "riscv32" + } + + pub fn riscv64(&self) -> bool { + self.arch == "riscv64" + } + + pub fn riscv(&self) -> bool { + self.riscv32() || self.riscv64() + } + + pub fn s390x(&self) -> bool { + self.arch == "s390x" + } + + pub fn sparc32(&self) -> bool { + self.arch == "sparc" + } + + pub fn sparc64(&self) -> bool { + self.arch == "sparc64" + } + + pub fn sparc(&self) -> bool { + self.sparc32() || self.sparc64() + } + + pub fn wasm32(&self) -> bool { + self.arch == "wasm32" + } + + pub fn x86_32(&self) -> bool { + self.arch == "x86" + } + + pub fn x86_64(&self) -> bool { + self.arch == "x86_64" + } + + pub fn x86(&self) -> bool { + self.x86_32() || self.x86_64() + } + + /* abi */ + + pub fn eabihf(&self) -> bool { + self.abi == "eabihf" + } + + pub fn pauthtest(&self) -> bool { + self.abi == "pauthtest" + } + + pub fn x32(&self) -> bool { + self.abi == "x32" + } + + /* env */ + + pub fn gnu(&self) -> bool { + self.env == "gnu" + } + + pub fn msvc(&self) -> bool { + self.env == "msvc" + } + + pub fn musl(&self) -> bool { + self.env == "musl" || self.env == "ohos" + } + + pub fn nto_iosock(&self) -> bool { + self.env.contains("nto") && self.env.contains("iosock") + } + + pub fn uclibc(&self) -> bool { + self.env == "uclibc" + } + + /* os */ + + pub fn aix(&self) -> bool { + self.os == "aix" + } + + pub fn android(&self) -> bool { + self.os == "android" + } + + pub fn cygwin(&self) -> bool { + self.os == "cygwin" + } + + pub fn dragonfly(&self) -> bool { + self.os == "dragonfly" + } + + pub fn emscripten(&self) -> bool { + self.os == "emscripten" + } + + pub fn freebsd(&self) -> bool { + self.os == "freebsd" + } + + pub fn fuchsia(&self) -> bool { + self.os == "fuchsia" + } + + pub fn haiku(&self) -> bool { + self.os == "haiku" + } + + pub fn illumos(&self) -> bool { + self.os == "illumos" + } + + pub fn l4re(&self) -> bool { + self.os == "l4re" + } + + pub fn linux(&self) -> bool { + self.os == "linux" + } + + pub fn netbsd(&self) -> bool { + self.os == "netbsd" + } + + pub fn nto(&self) -> bool { + self.os == "nto" + } + + pub fn openbsd(&self) -> bool { + self.os == "openbsd" + } + + pub fn qurt(&self) -> bool { + self.os == "qurt" + } + + pub fn redox(&self) -> bool { + self.os == "redox" + } + + pub fn solaris(&self) -> bool { + self.os == "solaris" + } + + pub fn vxworks(&self) -> bool { + self.os == "vxworks" + } + + pub fn wali(&self) -> bool { + self.os == "linux" && self.wasm32() + } + + pub fn wasi(&self) -> bool { + self.os == "wasi" + } + + pub fn wasip2(&self) -> bool { + self.wasi() && self.env == "p2" + } + + pub fn win(&self) -> bool { + self.os == "windows" + } + + /* vendor */ + + pub fn apple(&self) -> bool { + self.vendor == "apple" + } + + /* other */ + + pub fn p32(&self) -> bool { + self.pointer_width == PointerWidth::P32 + } + + pub fn p64(&self) -> bool { + self.pointer_width == PointerWidth::P64 + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum PointerWidth { + P32, + P64, +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Endian { + Little, + Big, +} From b881470d7d3a73ba0944a75e086d49c31914d20c Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 10 Aug 2026 22:37:03 -0700 Subject: [PATCH 23/88] feat: add missing lch* syscalls to *BSD platforms This change adds the following system calls to various 4.4BSD derivatives: * FreeBSD(-like) * lchmod ([DragonFlyBSD][1], [FreeBSD][2]) * macOS * [lchflags][3] * [lchmod][4] * NetBSD * [lchmod][5] These system calls are available on all ancient versions of *BSD (4.4BSD, FreeBSD 3.0, etc). More specific historical information about when the functions were added is available in the manpages and headers referenced. This change also adds *chflags and *chmod to macos' semver file (additional syscalls are missing from that file). 1: https://leaf.dragonflybsd.org/cgi/web-man?command=lchmod 2: https://man.freebsd.org/cgi/man.cgi?query=lchmod 3: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L597 4: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L598 5: https://man.netbsd.org/lchmod.2 Signed-off-by: Enji Cooper (backport ) (cherry picked from commit 8b4ebdc6514d20ddbdac718aade170bf400e2515) --- libc-test/semver/apple.txt | 2 ++ libc-test/semver/freebsd.txt | 1 + libc-test/semver/netbsd.txt | 3 ++- src/unix/bsd/apple/mod.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 2a7110250a0cc..bfe10bcf45b71 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2205,6 +2205,8 @@ key_t killpg kqueue labs +lchflags +lchmod lio_listio listxattr load_command diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 2cdacfe842cca..51a04be7c7d31 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2126,6 +2126,7 @@ kld_load kqueue labs lchflags +lchmod lcong48 lio_listio lockf diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 182d4e2b5a7b2..b5e8664cbb1ed 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1410,6 +1410,7 @@ labs lastlog lastlogx lchflags +lchmod lcong48 lgetxattr lio_listio @@ -1648,4 +1649,4 @@ utmpxname utrace uucred wait4 -waitid \ No newline at end of file +waitid diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 6aed401bbb009..f3c40cc02b225 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4424,6 +4424,8 @@ extern "C" { pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; pub fn chflags(path: *const c_char, flags: c_uint) -> c_int; pub fn fchflags(fd: c_int, flags: c_uint) -> c_int; + pub fn lchflags(path: *const c_char, flags: c_uint) -> c_int; + pub fn lchmod(path: *const c_char, mode: mode_t) -> c_int; pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn lio_listio( diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index eb4951ffc7e6b..3321a64e8844f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -5037,6 +5037,8 @@ extern "C" { symbol: *const c_char, version: *const c_char, ) -> *mut c_void; + + pub fn lchmod(path: *const c_char, mode: crate::mode_t) -> c_int; } #[link(name = "memstat")] diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 75e4008fc3328..2d5b6ee04a451 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1911,6 +1911,7 @@ extern "C" { pub fn chflags(path: *const c_char, flags: c_ulong) -> c_int; pub fn fchflags(fd: c_int, flags: c_ulong) -> c_int; pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; + pub fn lchmod(path: *const c_char, mode: crate::mode_t) -> c_int; pub fn extattr_list_fd( fd: c_int, From f1e0b14cce8bf7e5c54bda28dcf9a63e5d27b751 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 12 Aug 2026 02:57:26 -0400 Subject: [PATCH 24/88] docs: Add more links to public headers and manual pages (backport ) (cherry picked from commit 0d2a6f04d60292cb2bd969327abda7fc585bb420) --- CONTRIBUTING.md | 79 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35fcba6404ba7..a4f3b18e729fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,28 +112,79 @@ chance of being accepted: ### Source links -Please include permalinks to headers in commit messages for all API changes. +Please include permalinks to headers in commit messages for all API changes; +the maintainers need to compare changes against these sources, and we also want +to keep a record of exactly what the API looked like when bindings were written. Common sources include: -* Linux uapi: https://github.com/torvalds/linux/tree/master/include/uapi -* Glibc: https://github.com/sailfishos-mirror/glibc (original is https://sourceware.org/git/?p=glibc.git;a=tree) -* Musl: https://github.com/kraj/musl (original is https://git.musl-libc.org/cgit/musl/tree/) -* Apple XNU: https://github.com/apple-oss-distributions/xnu, libc https://github.com/apple-oss-distributions/Libc/tree/main/include -* Android: https://cs.android.com/android/platform/superproject/main -* FreeBSD: https://github.com/freebsd/freebsd-src/tree/main/lib/libc -* Illumos: https://github.com/illumos/illumos-gate/tree/master/usr/src/lib/libc -* Fuchsia: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/ +* Apple XNU: , + libc +* Android: +* Cygwin: (official mirror), + (original) +* DragonFlyBSD: (official mirror), + (original) +* Emscripten: +* FreeBSD: (official mirror), + (original) +* Fuchsia: +* Glibc: (unofficial mirror), + (original) +* Illumos: (official mirror), + (original) +* Linux uapi: (official mirror), + (original) +* Musl: (unofficial mirror), + (original) +* NetBSD: (official mirror), + (original) +* OpenBSD: (official mirror), + (original) +* RedoxOS: +* Windows GNU: (unofficial mirror), + (original) +* Windows MSVC: After navigating to the relevant file and selecting relevant lines, get a -permalink. On GitHub this is available by clicking the triple dots and -selecting "copy permalink", and on the Android and Fuchsia source viewers -this is available via l-r (links->commit). - -If sources are closed, link to documentation or paste relevant C declarations. +permalink: + +* On GitHub, click the triple dots and selecting "copy permalink". +* On the Android and Fuchsia source viewers, type l-r (links->commit). +* Cgit is trickier. Locate the latest commit by clicking "summary", clicking + the commit message tagged with "master" (or other name as applicable), and + copying the sha from that commit. Next, insert `?id=abcd1234...` in the URL, + (before line number indicators like `#123`) and copy the result. This should + look something like + . +* For CVSweb, navigate to the file of interest and click on the "annotate" link + for the desired revision. Example: + . + +If sources are not public, link to documentation or paste relevant C +declarations. (Including this information in the PR description is fine too, commit messages are preferred because they become part of history.) +### Manual pages + +Including links to manpages is not required but can also be very helpful to +include. Some platforms also publish manpages but not sources. + +Common web manuals: + +* AIX: +* Apple: + is the only known official site but it is severly outdated. + or are better options. +* DragonFlyBSD: +* FreeBSD: +* Illumos: +* NetBSD: +* OpenBSD: +* Solaris: +* Windows MSVC: + ## Breaking change policy See `src/lib.rs` for details. From 33104dd90014e4fb8a9cc7ca9f7161f59f24c58b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 12 Aug 2026 03:55:35 -0400 Subject: [PATCH 25/88] glibc: Move `signal.h` definitions to `src/new` This allows for quite a bit of cleanup. Links: * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/signal/signal.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/bits/sigaction.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/mips/bits/sigaction.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/s390/bits/sigaction.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/sparc/bits/sigaction.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/bits/signum-generic.h#L76 * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/bits/signum-arch.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/mips/bits/signum-arch.h * https://github.com/sailfishos-mirror/glibc/blob/ae646973c5957b7eed06cb80d49d13b42178072d/sysdeps/unix/sysv/linux/sparc/bits/signum-arch.h (backport ) (cherry picked from commit 72f013506e8e58e4e4f8d3c506c2028037db6543) --- src/new/glibc/bits/signum_generic.rs | 19 ++++++++ src/new/glibc/mod.rs | 11 +++++ src/new/glibc/signal.rs | 9 ++++ .../sysdeps/unix/linux/bits/sigaction.rs | 31 +++++++++++++ .../sysdeps/unix/linux/bits/signum_arch.rs | 28 ++++++++++++ .../sysdeps/unix/linux/mips/bits/sigaction.rs | 29 ++++++++++++ .../unix/linux/mips/bits/signum_arch.rs | 28 ++++++++++++ src/new/glibc/sysdeps/unix/linux/mod.rs | 33 ++++++++++++++ .../sysdeps/unix/linux/s390/bits/sigaction.rs | 27 ++++++++++++ .../unix/linux/sparc/bits/sigaction.rs | 28 ++++++++++++ .../unix/linux/sparc/bits/signum_arch.rs | 28 ++++++++++++ src/new/mod.rs | 2 + src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 35 --------------- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 35 --------------- src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 35 --------------- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 37 ---------------- src/unix/linux_like/linux/gnu/b32/mod.rs | 14 ------ src/unix/linux_like/linux/gnu/b32/powerpc.rs | 35 --------------- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 34 -------------- .../linux_like/linux/gnu/b32/sparc/mod.rs | 36 --------------- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 35 --------------- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 44 ------------------- .../linux/gnu/b64/loongarch64/mod.rs | 39 ---------------- .../linux_like/linux/gnu/b64/mips64/mod.rs | 42 ------------------ .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 44 ------------------- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 39 ---------------- src/unix/linux_like/linux/gnu/b64/s390x.rs | 42 ------------------ .../linux_like/linux/gnu/b64/sparc64/mod.rs | 44 ------------------- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 44 ------------------- src/unix/linux_like/mod.rs | 31 +++++++------ src/unix/mod.rs | 1 + 31 files changed, 292 insertions(+), 647 deletions(-) create mode 100644 src/new/glibc/bits/signum_generic.rs create mode 100644 src/new/glibc/signal.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs diff --git a/src/new/glibc/bits/signum_generic.rs b/src/new/glibc/bits/signum_generic.rs new file mode 100644 index 0000000000000..4dacf29dc6bc0 --- /dev/null +++ b/src/new/glibc/bits/signum_generic.rs @@ -0,0 +1,19 @@ +//! Header: `bits/signum-generic.h` + +use crate::prelude::*; + +pub const SIGINT: c_int = 2; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGSEGV: c_int = 11; +pub const SIGTERM: c_int = 15; + +pub const SIGHUP: c_int = 1; +pub const SIGQUIT: c_int = 3; +pub const SIGTRAP: c_int = 5; +pub const SIGKILL: c_int = 9; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; + +pub use super::super::sysdeps::unix::linux::bits::signum_arch::*; diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 86dec42d6a784..c96aec8df79d6 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -6,6 +6,14 @@ //! This module structure is modeled after glibc's source tree. Its build system selects headers //! from different locations based on the platform, which we mimic here with reexports. +/// Source directory: `bits/` +/// +/// +mod bits { + #[cfg(target_os = "linux")] + pub(crate) mod signum_generic; +} + /// Source directory: `posix/` /// /// @@ -13,6 +21,9 @@ mod posix { pub(crate) mod unistd; } +#[cfg(target_os = "linux")] +pub(crate) mod signal; + /// Source directory: `sysdeps/` /// /// diff --git a/src/new/glibc/signal.rs b/src/new/glibc/signal.rs new file mode 100644 index 0000000000000..023b49ed0c91a --- /dev/null +++ b/src/new/glibc/signal.rs @@ -0,0 +1,9 @@ +//! Header: `signal/signal.h` + +pub use super::bits::signum_generic::*; +pub use super::sysdeps::unix::linux::bits::sigaction::*; +use crate::prelude::*; + +extern "C" { + pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int; +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs new file mode 100644 index 0000000000000..86c54bcd2393d --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs @@ -0,0 +1,31 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/sigaction.h` + +use crate::prelude::*; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + // This function should be unsafe everywhere but is currently only done on + // newer arches. + #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] + pub sa_restorer: Option, + #[cfg(not(any(target_arch = "riscv32", target_arch = "riscv64")))] + pub sa_restorer: Option, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0x00000002; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); + +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs b/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs new file mode 100644 index 0000000000000..40357358fce2d --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/signum-arch.h` + +use crate::prelude::*; + +pub const SIGSTKFLT: c_int = 16; +pub const SIGPWR: c_int = 30; + +pub const SIGBUS: c_int = 7; +pub const SIGSYS: c_int = 31; + +pub const SIGURG: c_int = 23; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGCONT: c_int = 18; +pub const SIGCHLD: c_int = 17; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGPOLL: c_int = 29; +pub const SIGXFSZ: c_int = 25; +pub const SIGXCPU: c_int = 24; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; + +pub const SIGWINCH: c_int = 28; + +pub const SIGIO: c_int = SIGPOLL; diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs new file mode 100644 index 0000000000000..408da96204e41 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs @@ -0,0 +1,29 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/sigaction.h` + +use crate::prelude::*; + +s! { + // + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_flags: c_int, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_restorer: Option, + #[cfg(target_pointer_width = "32")] + _resv: [c_int; 1], + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0x00010000; +pub const SA_SIGINFO: c_int = 0x00000008; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); + +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; +pub const SIG_SETMASK: c_int = 3; diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs new file mode 100644 index 0000000000000..9e4f492eab386 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/signum_arch.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/signum-arch.h` + +use crate::prelude::*; + +pub const SIGEMT: c_int = 7; +pub const SIGPWR: c_int = 19; + +pub const SIGBUS: c_int = 10; +pub const SIGSYS: c_int = 12; + +pub const SIGURG: c_int = 21; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGCONT: c_int = 25; +pub const SIGCHLD: c_int = 18; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGPOLL: c_int = 22; +pub const SIGXCPU: c_int = 30; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGXFSZ: c_int = 31; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; + +pub const SIGWINCH: c_int = 20; + +pub const SIGIO: c_int = SIGPOLL; diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index 21dac17fc0b27..9a50741ff00a0 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -2,6 +2,39 @@ //! //! +/// Directory: `sysdeps/unix/sysv/linux/bits` +pub(crate) mod bits { + #[cfg_attr( + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips", + target_arch = "mips32r6", + ), + path = "../mips/bits/sigaction.rs" + )] + #[cfg_attr(target_arch = "s390x", path = "../s390/bits/sigaction.rs")] + #[cfg_attr( + any(target_arch = "sparc", target_arch = "sparc64"), + path = "../sparc/bits/sigaction.rs" + )] + pub(crate) mod sigaction; + #[cfg_attr( + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips", + target_arch = "mips32r6", + ), + path = "../mips/bits/signum_arch.rs" + )] + #[cfg_attr( + any(target_arch = "sparc", target_arch = "sparc64"), + path = "../sparc/bits/signum_arch.rs" + )] + pub(crate) mod signum_arch; +} + /// Directory: `net/` /// /// Source directory: `sysdeps/unix/sysv/linux/net` diff --git a/src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs new file mode 100644 index 0000000000000..9707ab3bfa562 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/s390/bits/sigaction.rs @@ -0,0 +1,27 @@ +//! Header: `sysdeps/unix/sysv/linux/s390/bits/sigaction.h` + +use crate::prelude::*; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + __glibc_reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + pub sa_mask: crate::sigset_t, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SA_SIGINFO: c_int = 4; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); + +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs new file mode 100644 index 0000000000000..9cdfd7efd024b --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/sigaction.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/sparc/bits/sigaction.h` + +use crate::prelude::*; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + #[cfg(target_pointer_width = "64")] + __reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + } +} + +pub const SA_NOCLDSTOP: c_int = 0x00000008; +pub const SA_NOCLDWAIT: c_int = 0x100; +pub const SA_SIGINFO: c_int = 0x200; +pub const SA_ONSTACK: c_int = 1; +pub const SA_RESTART: c_int = 0x2; +pub const SA_NODEFER: c_int = 0x20; +pub const SA_RESETHAND: c_int = 0x4; + +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 4; diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs new file mode 100644 index 0000000000000..0a946482fdac4 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/signum_arch.rs @@ -0,0 +1,28 @@ +//! Header: `sysdeps/unix/sysv/linux/sparc/bits/signum-arch.h` + +use crate::prelude::*; + +pub const SIGEMT: c_int = 7; +pub const SIGPWR: c_int = 29; + +pub const SIGBUS: c_int = 10; +pub const SIGSYS: c_int = 12; + +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 SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGPOLL: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGXFSZ: c_int = 25; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; + +pub const SIGWINCH: c_int = 28; + +pub const SIGIO: c_int = SIGPOLL; diff --git a/src/new/mod.rs b/src/new/mod.rs index 3d1da7107b5e9..06e27f2ad0fa2 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -196,6 +196,8 @@ cfg_if! { pub use linux::types::*; #[cfg(target_env = "gnu")] pub use net::route::*; + #[cfg(target_env = "gnu")] + pub use signal::*; } else if #[cfg(target_vendor = "apple")] { pub use net::bpf::*; pub use netinet::tcp::*; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 84503af35e23a..5b5cfeca22271 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = u32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -370,9 +361,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -396,29 +384,6 @@ pub const F_SETOWN: c_int = 8; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 5a9ca13b2bc54..b0afd57333998 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = u32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -296,9 +287,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -316,29 +304,6 @@ pub const F_SETOWN: c_int = 8; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index 323f7b56c3002..f3940f4be51c4 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = i32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -289,9 +280,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -314,29 +302,6 @@ pub const POLLWRBAND: c_short = 0x200; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 936551c2bcbbb..b05ae5c2ebbf3 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -166,16 +166,6 @@ s! { __f_spare: [c_int; 6], } - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_flags: c_int, - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_restorer: Option, - _resv: [c_int; 1], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, @@ -765,33 +755,6 @@ pub const MAP_STACK: c_int = 0x40000; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; -pub const SA_SIGINFO: c_int = 0x00000008; -pub const SA_NOCLDWAIT: c_int = 0x00010000; - -pub const SIGEMT: c_int = 7; -pub const SIGCHLD: c_int = 18; -pub const SIGBUS: c_int = 10; -pub const SIGTTIN: c_int = 26; -pub const SIGTTOU: c_int = 27; -pub const SIGXCPU: c_int = 30; -pub const SIGXFSZ: c_int = 31; -pub const SIGVTALRM: c_int = 28; -pub const SIGPROF: c_int = 29; -pub const SIGWINCH: c_int = 20; -pub const SIGUSR1: c_int = 16; -pub const SIGUSR2: c_int = 17; -pub const SIGCONT: c_int = 25; -pub const SIGSTOP: c_int = 23; -pub const SIGTSTP: c_int = 24; -pub const SIGURG: c_int = 21; -pub const SIGIO: c_int = 22; -pub const SIGSYS: c_int = 12; -pub const SIGPOLL: c_int = 22; -pub const SIGPWR: c_int = 19; -pub const SIG_SETMASK: c_int = 3; -pub const SIG_BLOCK: c_int = 0x1; -pub const SIG_UNBLOCK: c_int = 0x2; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 6363132fde03a..2b2efb1e18131 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -299,8 +299,6 @@ cfg_if! { pub const O_PATH: c_int = 0x1000000; pub const O_TMPFILE: c_int = 0x2000000 | O_DIRECTORY; - pub const SA_ONSTACK: c_int = 1; - pub const PTRACE_DETACH: c_uint = 11; pub const F_RDLCK: c_int = 1; @@ -329,11 +327,6 @@ cfg_if! { pub const EPROTO: c_int = 86; pub const EDOTDOT: c_int = 88; - pub const SA_NODEFER: c_int = 0x20; - pub const SA_RESETHAND: c_int = 0x4; - pub const SA_RESTART: c_int = 0x2; - pub const SA_NOCLDSTOP: c_int = 0x00000008; - pub const EPOLL_CLOEXEC: c_int = 0x400000; pub const EFD_CLOEXEC: c_int = 0x400000; @@ -342,8 +335,6 @@ cfg_if! { pub const O_PATH: c_int = 0o10000000; pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; - pub const SA_ONSTACK: c_int = 0x08000000; - pub const PTRACE_DETACH: c_uint = 17; pub const F_RDLCK: c_int = 0; @@ -371,11 +362,6 @@ cfg_if! { pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; - pub const SA_NODEFER: c_int = 0x40000000; - pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); - pub const SA_RESTART: c_int = 0x10000000; - pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index ac946d0ac3dd8..b63be98ecaeb2 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -7,15 +7,6 @@ use crate::{ pub type wchar_t = i32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -345,9 +336,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -371,29 +359,6 @@ pub const F_SETOWN: c_int = 8; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; pub const SIGSTKSZ: size_t = 0x4000; pub const MINSIGSTKSZ: size_t = 4096; pub const CBAUD: crate::tcflag_t = 0xff; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 5484a68bd1ec1..8a9c597ea0606 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -111,15 +111,6 @@ s! { pub ss_size: size_t, } - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -335,31 +326,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_SIGINFO: c_int = 4; -pub const SA_NOCLDWAIT: c_int = 2; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 4cee14cc5d340..f29605ba51e2b 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -9,15 +9,6 @@ use crate::{ pub type wchar_t = i32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -316,33 +307,6 @@ pub const ERFKILL: c_int = 134; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_SIGINFO: c_int = 0x200; -pub const SA_NOCLDWAIT: c_int = 0x100; - -pub const SIGEMT: c_int = 7; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 20; -pub const SIGBUS: c_int = 10; -pub const SIGUSR1: c_int = 30; -pub const SIGUSR2: c_int = 31; -pub const SIGCONT: c_int = 19; -pub const SIGSTOP: c_int = 17; -pub const SIGTSTP: c_int = 18; -pub const SIGURG: c_int = 16; -pub const SIGIO: c_int = 23; -pub const SIGSYS: c_int = 12; -pub const SIGPOLL: c_int = 23; -pub const SIGPWR: c_int = 29; -pub const SIG_SETMASK: c_int = 4; -pub const SIG_BLOCK: c_int = 1; -pub const SIG_UNBLOCK: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 52919b02c5b94..1bed38e18fcfd 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -8,15 +8,6 @@ pub type wchar_t = i32; pub type greg_t = i32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -416,9 +407,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -447,29 +435,6 @@ pub const POLLWRBAND: c_short = 0x200; pub const EFD_NONBLOCK: c_int = 0x800; pub const SFD_NONBLOCK: c_int = 0x0800; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; pub const CBAUD: crate::tcflag_t = 0o0010017; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index e294f1f132bed..f863aa4357685 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -12,17 +12,6 @@ pub type blksize_t = i32; pub type suseconds_t = i64; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -361,34 +350,6 @@ pub const POSIX_FADV_NOREUSE: c_int = 5; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; @@ -437,11 +398,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index b02be364a6a30..add1256ac6d2e 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -135,15 +135,6 @@ s! { __size: [c_ulong; 7], } - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, @@ -724,36 +715,6 @@ pub const SOCK_DGRAM: c_int = 2; pub const SFD_NONBLOCK: c_int = 0x800; pub const SFD_CLOEXEC: c_int = 0x080000; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; -pub const SIG_SETMASK: c_int = 2; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGSTKFLT: c_int = 16; -pub const SIGCHLD: c_int = 17; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -pub const SIGURG: c_int = 23; -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 SIGWINCH: c_int = 28; -pub const SIGIO: c_int = 29; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIGSYS: c_int = 31; pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index e5aea2547156c..df2b8f9745a74 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -137,15 +137,6 @@ s! { __size: [c_ulong; 7], } - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_flags: c_int, - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_restorer: Option, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, @@ -581,11 +572,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; @@ -708,34 +694,6 @@ pub const MAP_HUGETLB: c_int = 0x080000; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000008; -pub const SA_NOCLDWAIT: c_int = 0x00010000; - -pub const SIGEMT: c_int = 7; -pub const SIGCHLD: c_int = 18; -pub const SIGBUS: c_int = 10; -pub const SIGTTIN: c_int = 26; -pub const SIGTTOU: c_int = 27; -pub const SIGXCPU: c_int = 30; -pub const SIGXFSZ: c_int = 31; -pub const SIGVTALRM: c_int = 28; -pub const SIGPROF: c_int = 29; -pub const SIGWINCH: c_int = 20; -pub const SIGUSR1: c_int = 16; -pub const SIGUSR2: c_int = 17; -pub const SIGCONT: c_int = 25; -pub const SIGSTOP: c_int = 23; -pub const SIGTSTP: c_int = 24; -pub const SIGURG: c_int = 21; -pub const SIGIO: c_int = 22; -pub const SIGSYS: c_int = 12; -pub const SIGPOLL: c_int = 22; -pub const SIGPWR: c_int = 19; -pub const SIG_SETMASK: c_int = 3; -pub const SIG_BLOCK: c_int = 0x1; -pub const SIG_UNBLOCK: c_int = 0x2; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 51f71a8402a76..0f7e065c8532c 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -14,17 +14,6 @@ pub type gregset_t = [c_ulong; __NGREG]; pub type fpregset_t = [c_ulong; __NFPREG]; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -396,34 +385,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; @@ -476,11 +437,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 3371f0337e498..f473f8c7338c9 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -144,15 +144,6 @@ s! { pub ss_size: size_t, } - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, @@ -392,32 +383,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 134217728; -pub const SA_SIGINFO: c_int = 4; -pub const SA_NOCLDWAIT: c_int = 2; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0; -pub const SIG_UNBLOCK: c_int = 1; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; @@ -457,10 +422,6 @@ pub const ESRMNT: c_int = 69; pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 1073741824; -pub const SA_RESETHAND: c_int = -2147483648; -pub const SA_RESTART: c_int = 268435456; -pub const SA_NOCLDSTOP: c_int = 1; pub const EPOLL_CLOEXEC: c_int = 524288; pub const EFD_CLOEXEC: c_int = 524288; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 2c54c68d2b82a..d94fa32579b3c 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -13,16 +13,6 @@ pub type wchar_t = i32; pub type greg_t = u64; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - __glibc_reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - pub sa_mask: crate::sigset_t, - } - pub struct statfs { pub f_type: c_uint, pub f_bsize: c_uint, @@ -278,11 +268,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; @@ -312,13 +297,8 @@ pub const O_APPEND: c_int = 1024; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; pub const O_NONBLOCK: c_int = 2048; -pub const SA_NOCLDWAIT: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 4; -pub const SIGBUS: c_int = 7; pub const SIGSTKSZ: size_t = 0x2000; pub const MINSIGSTKSZ: size_t = 2048; -pub const SIG_SETMASK: c_int = 2; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; @@ -417,28 +397,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 17; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const O_ASYNC: c_int = 0x2000; pub const O_NDELAY: c_int = 0x800; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index e58bfd33f849d..dcfc7c442fa0e 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -12,17 +12,6 @@ pub type blksize_t = i64; pub type suseconds_t = i32; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -321,34 +310,6 @@ pub const ERFKILL: c_int = 134; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 1; -pub const SA_SIGINFO: c_int = 0x200; -pub const SA_NOCLDWAIT: c_int = 0x100; - -pub const SIGEMT: c_int = 7; -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 20; -pub const SIGBUS: c_int = 10; -pub const SIGUSR1: c_int = 30; -pub const SIGUSR2: c_int = 31; -pub const SIGCONT: c_int = 19; -pub const SIGSTOP: c_int = 17; -pub const SIGTSTP: c_int = 18; -pub const SIGURG: c_int = 16; -pub const SIGIO: c_int = 23; -pub const SIGSYS: c_int = 12; -pub const SIGPOLL: c_int = 23; -pub const SIGPWR: c_int = 29; -pub const SIG_SETMASK: c_int = 4; -pub const SIG_BLOCK: c_int = 1; -pub const SIG_UNBLOCK: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; @@ -400,11 +361,6 @@ pub const ECOMM: c_int = 85; pub const EPROTO: c_int = 86; pub const EDOTDOT: c_int = 88; -pub const SA_NODEFER: c_int = 0x20; -pub const SA_RESETHAND: c_int = 0x4; -pub const SA_RESTART: c_int = 0x2; -pub const SA_NOCLDSTOP: c_int = 0x00000008; - pub const EPOLL_CLOEXEC: c_int = 0x400000; pub const EFD_CLOEXEC: c_int = 0x400000; 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 8c5f3e5a1800d..98506315c3712 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 @@ -13,17 +13,6 @@ pub type greg_t = i64; pub type suseconds_t = i64; s! { - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - #[cfg(target_arch = "sparc64")] - __reserved0: Padding, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct statfs { pub f_type: crate::__fsword_t, pub f_bsize: crate::__fsword_t, @@ -426,34 +415,6 @@ pub const ERFKILL: c_int = 132; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; -pub const SA_ONSTACK: c_int = 0x08000000; -pub const SA_SIGINFO: c_int = 0x00000004; -pub const SA_NOCLDWAIT: c_int = 0x00000002; - -pub const SIGTTIN: c_int = 21; -pub const SIGTTOU: c_int = 22; -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 SIGWINCH: c_int = 28; -pub const SIGCHLD: c_int = 17; -pub const SIGBUS: c_int = 7; -pub const SIGUSR1: c_int = 10; -pub const SIGUSR2: c_int = 12; -pub const SIGCONT: c_int = 18; -pub const SIGSTOP: c_int = 19; -pub const SIGTSTP: c_int = 20; -pub const SIGURG: c_int = 23; -pub const SIGIO: c_int = 29; -pub const SIGSYS: c_int = 31; -pub const SIGSTKFLT: c_int = 16; -pub const SIGPOLL: c_int = 29; -pub const SIGPWR: c_int = 30; -pub const SIG_SETMASK: c_int = 2; -pub const SIG_BLOCK: c_int = 0x000000; -pub const SIG_UNBLOCK: c_int = 0x01; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; @@ -507,11 +468,6 @@ pub const ECOMM: c_int = 70; pub const EPROTO: c_int = 71; pub const EDOTDOT: c_int = 73; -pub const SA_NODEFER: c_int = 0x40000000; -pub const SA_RESETHAND: c_int = u32_cast_int(0x80000000); -pub const SA_RESTART: c_int = 0x10000000; -pub const SA_NOCLDSTOP: c_int = 0x00000001; - pub const EPOLL_CLOEXEC: c_int = 0x80000; pub const EFD_CLOEXEC: c_int = 0x80000; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index fc4d6c3c1594f..151d2cf87d967 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -435,8 +435,6 @@ pub const F_SEAL_WRITE: c_int = 0x0008; // FIXME(#235): Include file sealing fcntls once we have a way to verify them. -pub const SIGTRAP: c_int = 5; - pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; @@ -485,17 +483,24 @@ pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; pub const X_OK: c_int = 1; -pub const SIGHUP: c_int = 1; -pub const SIGINT: c_int = 2; -pub const SIGQUIT: c_int = 3; -pub const SIGILL: c_int = 4; -pub const SIGABRT: c_int = 6; -pub const SIGFPE: c_int = 8; -pub const SIGKILL: c_int = 9; -pub const SIGSEGV: c_int = 11; -pub const SIGPIPE: c_int = 13; -pub const SIGALRM: c_int = 14; -pub const SIGTERM: c_int = 15; + +cfg_if! { + // defined in src/new/glibc + if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { + 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 SIGFPE: c_int = 8; + pub const SIGKILL: c_int = 9; + pub const SIGSEGV: c_int = 11; + pub const SIGPIPE: c_int = 13; + pub const SIGALRM: c_int = 14; + pub const SIGTERM: c_int = 15; + } +} pub const PROT_NONE: c_int = 0; pub const PROT_READ: c_int = 1; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e331089b38317..89d2e7117174a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -2312,6 +2312,7 @@ cfg_if! { #[cfg(not(target_os = "l4re"))] pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE; pub fn atexit(cb: extern "C" fn()) -> c_int; + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")] pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int; From 9c3019d57482fa59713b55560c6c9e53c792fca7 Mon Sep 17 00:00:00 2001 From: StackOverflowExcept1on <109800286+StackOverflowExcept1on@users.noreply.github.com> Date: Wed, 12 Aug 2026 21:37:23 +0300 Subject: [PATCH 26/88] fix(android/aarch64): use `libc::ucontext_t` from Android NDK (backport ) (cherry picked from commit 1a8e71f33b1d6ea1e072210e7fc994417bbb2e34) --- libc-test/build/main.rs | 5 +++-- src/unix/linux_like/android/b32/arm.rs | 2 +- src/unix/linux_like/android/b64/aarch64/mod.rs | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 6205d06a5ac13..a4bee012dc47b 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -2276,8 +2276,6 @@ fn test_android(t: &Target) { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. "termios2" => true, - // uc_sigmask and uc_sigmask64 of ucontext_t are an anonymous union - "ucontext_t" => true, // 'private' type "prop_info" => true, @@ -2547,6 +2545,9 @@ fn test_android(t: &Target) { ("ifreq", "ifr_ifru") => true, ("ifconf", "ifc_ifcu") => true, + // uc_sigmask and uc_sigmask64 are an anonymous union + ("ucontext_t", "uc_sigmask" | "uc_sigmask64" | "uc_sigmask__c_anonymous_union") => true, + _ => false, } }); diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index 0fe599fe53141..789287b495031 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -31,7 +31,7 @@ s! { pub struct __c_anonymous_uc_sigmask_with_padding { pub uc_sigmask: crate::sigset_t, - /* Android has a wrong (smaller) sigset_t on x86. */ + /* Android has a wrong (smaller) sigset_t on ARM. */ __padding_rt_sigset: Padding, } diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 2fe6211e00ec5..39918d2de2e1d 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -63,6 +63,9 @@ s! { pub uc_link: *mut ucontext_t, pub uc_stack: crate::stack_t, pub uc_sigmask: crate::sigset_t, + /* The kernel adds extra padding after uc_sigmask to match + * glibc sigset_t on ARM64. */ + __padding: Padding<[c_char; 128 - size_of::()]>, pub uc_mcontext: mcontext_t, } From dfbac63c2bfc7211d631c9b73995e2159046294f Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sat, 15 Aug 2026 14:51:32 +0300 Subject: [PATCH 27/88] linux_like: add missing `STATX_*` constants libc already has `struct statx` fields through 6.16 but there are missing masks, so several fields are exposed with no way to request them. Add the five constants the header defines and libc does not. The NDK doesn't have `STATX_DIO_READ_ALIGN` yet, so left out for Android. Three others landed in r28 and CI still runs r27, so they're skipped in `test_android`. Link: https://github.com/torvalds/linux/blob/8cd9520d35a6c38db6567e97dd93b1f11f185dc6/include/uapi/linux/stat.h#L218-L221 Link: https://github.com/torvalds/linux/blob/8cd9520d35a6c38db6567e97dd93b1f11f185dc6/include/uapi/linux/stat.h#L257 Link: https://android.googlesource.com/platform/bionic/+/a63b21091ada240d92f8ceadb1cabbdedaaab81b/libc/kernel/uapi/linux/stat.h#95 Link: https://man7.org/linux/man-pages/man2/statx.2.html (backport ) (cherry picked from commit 0ddf5b7bc7a071b0c76b6c8f0f341235f72f3865) --- libc-test/build/main.rs | 11 +++++++++++ libc-test/semver/linux-gnu.txt | 5 +++++ src/unix/linux_like/mod.rs | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index a4bee012dc47b..d179566ceb3a9 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -2371,6 +2371,11 @@ fn test_android(t: &Target) { | "NTF_EXT_LOCKED" | "ALG_SET_DRBG_ENTROPY" => true, + // FIXME(android): NDK r28 minimum required + | "STATX_SUBVOL" + | "STATX_WRITE_ATOMIC" + | "STATX_ATTR_WRITE_ATOMIC" => true, + // FIXME(android): Something has been changed on r26b: | "NFNL_SUBSYS_COUNT" | "NF_NETDEV_NUMHOOKS" @@ -5052,6 +5057,12 @@ fn test_linux(t: &Target) { "PTRACE_SET_SYSCALL_INFO" => kernel < (6, 16), "TLS_INFO_TX_MAX_PAYLOAD_LEN" | "TLS_INFO_MAX" => kernel < (6, 19), + // statx mask and attribute bits + "STATX_MNT_ID_UNIQUE" => kernel < (6, 8), + "STATX_SUBVOL" => kernel < (6, 10), + "STATX_WRITE_ATOMIC" | "STATX_ATTR_WRITE_ATOMIC" => kernel < (6, 11), + "STATX_DIO_READ_ALIGN" => kernel < (6, 14), + // Changed value recently "SW_MAX" | "SW_CNT" => kernel < (6, 16), diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 72cb83d94b254..d846885a12c82 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -424,20 +424,25 @@ STATX_ATTR_IMMUTABLE STATX_ATTR_MOUNT_ROOT STATX_ATTR_NODUMP STATX_ATTR_VERITY +STATX_ATTR_WRITE_ATOMIC STATX_BASIC_STATS STATX_BLOCKS STATX_BTIME STATX_CTIME STATX_DIOALIGN +STATX_DIO_READ_ALIGN STATX_GID STATX_INO STATX_MNT_ID +STATX_MNT_ID_UNIQUE STATX_MODE STATX_MTIME STATX_NLINK STATX_SIZE +STATX_SUBVOL STATX_TYPE STATX_UID +STATX_WRITE_ATOMIC STATX__RESERVED STA_CLK STA_CLOCKERR diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 151d2cf87d967..3b041166323ec 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1678,6 +1678,12 @@ cfg_if! { pub const STATX_ALL: c_uint = 0x0fff; pub const STATX_MNT_ID: c_uint = 0x1000; pub const STATX_DIOALIGN: c_uint = 0x2000; + pub const STATX_MNT_ID_UNIQUE: c_uint = 0x00004000; + pub const STATX_SUBVOL: c_uint = 0x00008000; + pub const STATX_WRITE_ATOMIC: c_uint = 0x00010000; + // Not in the Android NDK as of r29. + #[cfg(not(target_os = "android"))] + pub const STATX_DIO_READ_ALIGN: c_uint = 0x00020000; pub const STATX__RESERVED: c_int = u32_cast_int(0x80000000); pub const STATX_ATTR_COMPRESSED: c_int = 0x0004; pub const STATX_ATTR_IMMUTABLE: c_int = 0x0010; @@ -1688,6 +1694,7 @@ cfg_if! { pub const STATX_ATTR_MOUNT_ROOT: c_int = 0x2000; pub const STATX_ATTR_VERITY: c_int = 0x100000; pub const STATX_ATTR_DAX: c_int = 0x200000; + pub const STATX_ATTR_WRITE_ATOMIC: c_int = 0x00400000; } } From 393c580b8b328c45362b616c4743a1fbd2a6497b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 17 Aug 2026 06:44:31 -0500 Subject: [PATCH 28/88] ci: Add configuration for renovatebot Based on the configuration for `compiler-builtins` [1]. [1]: https://github.com/rust-lang/compiler-builtins/blob/af778498377a1bb72aefee685edf7aebd79df5b0/.github/renovate.json5 (backport ) (cherry picked from commit 4d6f2682554432b55f1692cc2d057190d1b7aeeb) --- .github/renovate.json5 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/renovate.json5 diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 0000000000000..7d18fd573d6d8 --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,37 @@ +{ + $schema: "https://docs.renovatebot.com/renovate-schema.json", + extends: [ + "config:recommended", + ":maintainLockFilesMonthly", + "helpers:pinGitHubActionDigestsToSemver" + ], + packageRules: [ + { + matchCategories: [ + "rust" + ], + matchJsonata: [ + "isBreaking != true" + ], + // Disable non-breaking change updates because they + // are updated periodically with lockfile maintainance. + enabled: false, + }, + { + matchManagers: [ + "github-actions" + ], + // Every month + schedule: "* 0 1 * *", + groupName: "Github Actions", + } + ], + // Receive any update that fixes security vulnerabilities. + // We need this because we disabled "patch" updates for Rust. + // Note: You need to enable "Dependabot alerts" in "Code security" GitHub + // Settings to receive security updates. + // See https://docs.renovatebot.com/configuration-options/#vulnerabilityalerts + vulnerabilityAlerts: { + enabled: true, + }, +} From fb936b8be811a0504bd415875ef96c68e0205383 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 18 Aug 2026 09:15:23 +0000 Subject: [PATCH 29/88] chore(deps): update taiki-e/install-action action to v2.86.3 (backport ) (cherry picked from commit bd53ab4040b5791ae22417ac77fb0b61736a2313) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2b239a4b1be1d..cfbc588dd5b26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -82,7 +82,7 @@ jobs: run: ./ci/install-rust.sh - name: Install semver-checks - uses: taiki-e/install-action@6c6fd71fe4fb72c3697d269963d0e15df8adedad # v2.85.10 + uses: taiki-e/install-action@5b4d68e2e660441203ab128a23676f1e4faf1532 # v2.86.3 if: matrix.toolchain == 'stable' with: tool: cargo-semver-checks From f6d6840f146a9e1e99f1631023a07ef7ec526222 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 18 Aug 2026 04:14:57 -0500 Subject: [PATCH 30/88] ci: Remove dependabot We now have forking-renovate set up [1]. [1]: https://github.com/rust-lang/libc/issues/5419 (backport ) (cherry picked from commit c1dcff0355f15cfc0db85e2398eb44c82b361326) --- .github/dependabot.yaml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .github/dependabot.yaml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml deleted file mode 100644 index 5ace4600a1f26..0000000000000 --- a/.github/dependabot.yaml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" From 9b28c509f1b3f45ad359a0825c078dd8b80fa5ce Mon Sep 17 00:00:00 2001 From: telcharr Date: Sun, 9 Aug 2026 17:16:38 -0400 Subject: [PATCH 31/88] swap crate's INT_MIN/MAX with c_int::MIN/MAX (backport ) (cherry picked from commit be5f8daed00e1191ee448752f8754708ceb31f33) --- src/unix/linux_like/android/mod.rs | 14 +++++++------- src/unix/linux_like/linux/mod.rs | 14 +++++++------- src/vxworks/mod.rs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 6c024534f5985..7102140a26d3e 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1981,7 +1981,7 @@ pub const NF_BR_POST_ROUTING: c_int = 4; pub const NF_BR_BROUTING: c_int = 5; pub const NF_BR_NUMHOOKS: c_int = 6; -pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_BR_PRI_FIRST: c_int = c_int::MIN; pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300; pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200; pub const NF_BR_PRI_BRNF: c_int = 0; @@ -1991,7 +1991,7 @@ pub const NF_BR_PRI_NAT_SRC: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_BR_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv4.h pub const NF_IP_PRE_ROUTING: c_int = 0; @@ -2001,7 +2001,7 @@ pub const NF_IP_LOCAL_OUT: c_int = 3; pub const NF_IP_POST_ROUTING: c_int = 4; pub const NF_IP_NUMHOOKS: c_int = 5; -pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP_PRI_RAW: c_int = -300; @@ -2014,11 +2014,11 @@ pub const NF_IP_PRI_SECURITY: c_int = 50; pub const NF_IP_PRI_NAT_SRC: c_int = 100; pub const NF_IP_PRI_SELINUX_LAST: c_int = 225; pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300; -pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = c_int::MAX; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6.h pub const NF_IP6_PRE_ROUTING: c_int = 0; @@ -2028,7 +2028,7 @@ pub const NF_IP6_LOCAL_OUT: c_int = 3; pub const NF_IP6_POST_ROUTING: c_int = 4; pub const NF_IP6_NUMHOOKS: c_int = 5; -pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP6_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP6_PRI_RAW: c_int = -300; @@ -2044,7 +2044,7 @@ pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP6_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6/ip6_tables.h pub const IP6T_SO_ORIGINAL_DST: c_int = 80; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index ed3ac804ef6eb..75f49b8babb04 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1775,7 +1775,7 @@ pub const NF_BR_POST_ROUTING: c_int = 4; pub const NF_BR_BROUTING: c_int = 5; pub const NF_BR_NUMHOOKS: c_int = 6; -pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_BR_PRI_FIRST: c_int = c_int::MIN; pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300; pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200; pub const NF_BR_PRI_BRNF: c_int = 0; @@ -1785,7 +1785,7 @@ pub const NF_BR_PRI_NAT_SRC: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_BR_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv4.h pub const NF_IP_PRE_ROUTING: c_int = 0; @@ -1795,7 +1795,7 @@ pub const NF_IP_LOCAL_OUT: c_int = 3; pub const NF_IP_POST_ROUTING: c_int = 4; pub const NF_IP_NUMHOOKS: c_int = 5; -pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP_PRI_RAW: c_int = -300; @@ -1808,11 +1808,11 @@ pub const NF_IP_PRI_SECURITY: c_int = 50; pub const NF_IP_PRI_NAT_SRC: c_int = 100; pub const NF_IP_PRI_SELINUX_LAST: c_int = 225; pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300; -pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = c_int::MAX; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6.h pub const NF_IP6_PRE_ROUTING: c_int = 0; @@ -1822,7 +1822,7 @@ pub const NF_IP6_LOCAL_OUT: c_int = 3; pub const NF_IP6_POST_ROUTING: c_int = 4; pub const NF_IP6_NUMHOOKS: c_int = 5; -pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP6_PRI_FIRST: c_int = c_int::MIN; pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450; pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400; pub const NF_IP6_PRI_RAW: c_int = -300; @@ -1838,7 +1838,7 @@ pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300; /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) /// for details. -pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX; +pub const NF_IP6_PRI_LAST: c_int = c_int::MAX; // linux/netfilter_ipv6/ip6_tables.h pub const IP6T_SO_ORIGINAL_DST: c_int = 80; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 91e0a9dab4bee..3417a11c3b975 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -681,7 +681,7 @@ pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; pub const INT_MAX: c_int = 0x7fffffff; -pub const INT_MIN: c_int = -INT_MAX - 1; +pub const INT_MIN: c_int = -0x7fffffff - 1; // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std From 415d5d6dca589a973219af052a7ad128423d0527 Mon Sep 17 00:00:00 2001 From: telcharr Date: Tue, 11 Aug 2026 18:16:15 -0400 Subject: [PATCH 32/88] deprecate the integer type MIN/MAX constants (backport ) (cherry picked from commit 14ccfb074bcb0ba188adb14d4bc2a5e601caba79) --- src/fuchsia/mod.rs | 2 ++ src/new/qurt/limits.rs | 14 ++++++++++++++ src/sgx.rs | 2 ++ src/solid/mod.rs | 2 ++ src/switch.rs | 2 ++ src/unix/hurd/mod.rs | 37 +++++++++++++++++++++++++++++++++++++ src/unix/mod.rs | 2 ++ src/vxworks/mod.rs | 2 ++ src/windows/mod.rs | 2 ++ src/xous.rs | 2 ++ 10 files changed, 67 insertions(+) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index bb139ba1d43ba..46c5f192cc920 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -1127,7 +1127,9 @@ s_no_extra_traits! { pub const HOST_NAME_MAX: c_int = 255; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -1 - 0x7fffffff; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 0x7fffffff; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; diff --git a/src/new/qurt/limits.rs b/src/new/qurt/limits.rs index 8bf772cebd17d..b2b6e240351e8 100644 --- a/src/new/qurt/limits.rs +++ b/src/new/qurt/limits.rs @@ -5,23 +5,37 @@ use crate::prelude::*; // Character properties pub const CHAR_BIT: c_uint = 8; +#[deprecated(since = "0.2.190", note = "Use `c_char::MAX` instead.")] pub const CHAR_MAX: c_char = 255; // unsigned char on Hexagon +#[deprecated(since = "0.2.190", note = "Use `c_char::MIN` instead.")] pub const CHAR_MIN: c_char = 0; +#[deprecated(since = "0.2.190", note = "Use `c_schar::MAX` instead.")] pub const SCHAR_MAX: i8 = 127; +#[deprecated(since = "0.2.190", note = "Use `c_schar::MIN` instead.")] pub const SCHAR_MIN: i8 = -128; +#[deprecated(since = "0.2.190", note = "Use `c_uchar::MAX` instead.")] pub const UCHAR_MAX: c_uchar = 255; // Integer properties +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483647 - 1; +#[deprecated(since = "0.2.190", note = "Use `c_uint::MAX` instead.")] pub const UINT_MAX: c_uint = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `c_long::MAX` instead.")] pub const LONG_MAX: c_long = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `c_long::MIN` instead.")] pub const LONG_MIN: c_long = -2147483647 - 1; +#[deprecated(since = "0.2.190", note = "Use `c_ulong::MAX` instead.")] pub const ULONG_MAX: c_ulong = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `c_short::MAX` instead.")] pub const SHRT_MAX: c_short = 32767; +#[deprecated(since = "0.2.190", note = "Use `c_short::MIN` instead.")] pub const SHRT_MIN: c_short = -32768; +#[deprecated(since = "0.2.190", note = "Use `c_ushort::MAX` instead.")] pub const USHRT_MAX: c_ushort = 65535; // POSIX Limits diff --git a/src/sgx.rs b/src/sgx.rs index 9cf9c6d3b41b8..7855e67ad3d59 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -11,5 +11,7 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type ssize_t = isize; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index d14dcf88d270f..ee644731804ed 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -176,7 +176,9 @@ s! { } } +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; pub const EXIT_FAILURE: c_int = 1; diff --git a/src/switch.rs b/src/switch.rs index 2d202dd61fc5d..6ee4c5bae68c3 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -13,5 +13,7 @@ pub type ssize_t = isize; pub type off_t = i64; pub type wchar_t = u32; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index d3d1792135eae..7c18b498030ba 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -2634,42 +2634,79 @@ pub const TCP_REPAIR_OFF: c_int = 0; pub const TCP_REPAIR_OFF_NO_WP: c_int = -1; // stdint.h +#[deprecated(since = "0.2.190", note = "Use `i8::MIN` instead.")] pub const INT8_MIN: i8 = -128; +#[deprecated(since = "0.2.190", note = "Use `i16::MIN` instead.")] pub const INT16_MIN: i16 = -32768; +#[deprecated(since = "0.2.190", note = "Use `i32::MIN` instead.")] pub const INT32_MIN: i32 = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `i8::MAX` instead.")] pub const INT8_MAX: i8 = 127; +#[deprecated(since = "0.2.190", note = "Use `i16::MAX` instead.")] pub const INT16_MAX: i16 = 32767; +#[deprecated(since = "0.2.190", note = "Use `i32::MAX` instead.")] pub const INT32_MAX: i32 = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `u8::MAX` instead.")] pub const UINT8_MAX: u8 = 255; +#[deprecated(since = "0.2.190", note = "Use `u16::MAX` instead.")] pub const UINT16_MAX: u16 = 65535; +#[deprecated(since = "0.2.190", note = "Use `u32::MAX` instead.")] pub const UINT32_MAX: u32 = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `int_least8_t::MIN` instead.")] pub const INT_LEAST8_MIN: int_least8_t = -128; +#[deprecated(since = "0.2.190", note = "Use `int_least16_t::MIN` instead.")] pub const INT_LEAST16_MIN: int_least16_t = -32768; +#[deprecated(since = "0.2.190", note = "Use `int_least32_t::MIN` instead.")] pub const INT_LEAST32_MIN: int_least32_t = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `int_least8_t::MAX` instead.")] pub const INT_LEAST8_MAX: int_least8_t = 127; +#[deprecated(since = "0.2.190", note = "Use `int_least16_t::MAX` instead.")] pub const INT_LEAST16_MAX: int_least16_t = 32767; +#[deprecated(since = "0.2.190", note = "Use `int_least32_t::MAX` instead.")] pub const INT_LEAST32_MAX: int_least32_t = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `uint_least8_t::MAX` instead.")] pub const UINT_LEAST8_MAX: uint_least8_t = 255; +#[deprecated(since = "0.2.190", note = "Use `uint_least16_t::MAX` instead.")] pub const UINT_LEAST16_MAX: uint_least16_t = 65535; +#[deprecated(since = "0.2.190", note = "Use `uint_least32_t::MAX` instead.")] pub const UINT_LEAST32_MAX: uint_least32_t = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `int_fast8_t::MIN` instead.")] pub const INT_FAST8_MIN: int_fast8_t = -128; +#[deprecated(since = "0.2.190", note = "Use `int_fast16_t::MIN` instead.")] pub const INT_FAST16_MIN: int_fast16_t = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `int_fast32_t::MIN` instead.")] pub const INT_FAST32_MIN: int_fast32_t = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `int_fast8_t::MAX` instead.")] pub const INT_FAST8_MAX: int_fast8_t = 127; +#[deprecated(since = "0.2.190", note = "Use `int_fast16_t::MAX` instead.")] pub const INT_FAST16_MAX: int_fast16_t = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `int_fast32_t::MAX` instead.")] pub const INT_FAST32_MAX: int_fast32_t = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `uint_fast8_t::MAX` instead.")] pub const UINT_FAST8_MAX: uint_fast8_t = 255; +#[deprecated(since = "0.2.190", note = "Use `uint_fast16_t::MAX` instead.")] pub const UINT_FAST16_MAX: uint_fast16_t = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `uint_fast32_t::MAX` instead.")] pub const UINT_FAST32_MAX: uint_fast32_t = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `intptr_t::MIN` instead.")] pub const INTPTR_MIN: __intptr_t = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `intptr_t::MAX` instead.")] pub const INTPTR_MAX: __intptr_t = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `uintptr_t::MAX` instead.")] pub const UINTPTR_MAX: usize = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `ptrdiff_t::MIN` instead.")] pub const PTRDIFF_MIN: __ptrdiff_t = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `ptrdiff_t::MAX` instead.")] pub const PTRDIFF_MAX: __ptrdiff_t = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const SIG_ATOMIC_MIN: __sig_atomic_t = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const SIG_ATOMIC_MAX: __sig_atomic_t = 2147483647; +#[deprecated(since = "0.2.190", note = "Use `size_t::MAX` instead.")] pub const SIZE_MAX: usize = 4294967295; +#[deprecated(since = "0.2.190", note = "Use `wint_t::MIN` instead.")] pub const WINT_MIN: wint_t = 0; +#[deprecated(since = "0.2.190", note = "Use `wint_t::MAX` instead.")] pub const WINT_MAX: wint_t = 4294967295; pub const INT8_WIDTH: usize = 8; pub const UINT8_WIDTH: usize = 8; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 89d2e7117174a..b0863c49bb05e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -231,7 +231,9 @@ s! { } } +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 3417a11c3b975..25ae648cc24c9 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -680,7 +680,9 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 0x7fffffff; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -0x7fffffff - 1; // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 67e8df3b46dc2..50a7866e9a943 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -96,7 +96,9 @@ s! { } } +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; pub const EXIT_FAILURE: c_int = 1; diff --git a/src/xous.rs b/src/xous.rs index 2415fd42824e1..cf4a343e228f9 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -14,5 +14,7 @@ pub type ssize_t = isize; pub type off_t = i64; pub type wchar_t = u32; +#[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] pub const INT_MIN: c_int = -2147483648; +#[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = 2147483647; From b46395a22f3f7c5481a8d6a2848b42faaf5d5e52 Mon Sep 17 00:00:00 2001 From: telcharr Date: Fri, 14 Aug 2026 17:40:15 -0400 Subject: [PATCH 33/88] derive deprecated constants from their types (backport ) (cherry picked from commit 9d92a899e54ec3c374cb619e346f3dba8ceb397e) --- src/fuchsia/mod.rs | 4 +-- src/new/qurt/limits.rs | 32 ++++++++--------- src/sgx.rs | 4 +-- src/solid/mod.rs | 4 +-- src/switch.rs | 4 +-- src/unix/hurd/mod.rs | 79 ++++++++++++++++++++++-------------------- src/unix/mod.rs | 4 +-- src/vxworks/mod.rs | 4 +-- src/windows/mod.rs | 4 +-- src/xous.rs | 4 +-- 10 files changed, 73 insertions(+), 70 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 46c5f192cc920..b4765b7057f21 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -1128,9 +1128,9 @@ s_no_extra_traits! { pub const HOST_NAME_MAX: c_int = 255; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -1 - 0x7fffffff; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 0x7fffffff; +pub const INT_MAX: c_int = c_int::MAX; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; diff --git a/src/new/qurt/limits.rs b/src/new/qurt/limits.rs index b2b6e240351e8..f94da1a8a5cbd 100644 --- a/src/new/qurt/limits.rs +++ b/src/new/qurt/limits.rs @@ -6,37 +6,37 @@ use crate::prelude::*; // Character properties pub const CHAR_BIT: c_uint = 8; #[deprecated(since = "0.2.190", note = "Use `c_char::MAX` instead.")] -pub const CHAR_MAX: c_char = 255; // unsigned char on Hexagon +pub const CHAR_MAX: c_char = c_char::MAX; // unsigned char on Hexagon #[deprecated(since = "0.2.190", note = "Use `c_char::MIN` instead.")] -pub const CHAR_MIN: c_char = 0; -#[deprecated(since = "0.2.190", note = "Use `c_schar::MAX` instead.")] -pub const SCHAR_MAX: i8 = 127; -#[deprecated(since = "0.2.190", note = "Use `c_schar::MIN` instead.")] -pub const SCHAR_MIN: i8 = -128; +pub const CHAR_MIN: c_char = c_char::MIN; +#[deprecated(since = "0.2.190", note = "Use `i8::MAX` instead.")] +pub const SCHAR_MAX: i8 = i8::MAX; +#[deprecated(since = "0.2.190", note = "Use `i8::MIN` instead.")] +pub const SCHAR_MIN: i8 = i8::MIN; #[deprecated(since = "0.2.190", note = "Use `c_uchar::MAX` instead.")] -pub const UCHAR_MAX: c_uchar = 255; +pub const UCHAR_MAX: c_uchar = c_uchar::MAX; // Integer properties #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483647 - 1; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_uint::MAX` instead.")] -pub const UINT_MAX: c_uint = 4294967295; +pub const UINT_MAX: c_uint = c_uint::MAX; #[deprecated(since = "0.2.190", note = "Use `c_long::MAX` instead.")] -pub const LONG_MAX: c_long = 2147483647; +pub const LONG_MAX: c_long = c_long::MAX; #[deprecated(since = "0.2.190", note = "Use `c_long::MIN` instead.")] -pub const LONG_MIN: c_long = -2147483647 - 1; +pub const LONG_MIN: c_long = c_long::MIN; #[deprecated(since = "0.2.190", note = "Use `c_ulong::MAX` instead.")] -pub const ULONG_MAX: c_ulong = 4294967295; +pub const ULONG_MAX: c_ulong = c_ulong::MAX; #[deprecated(since = "0.2.190", note = "Use `c_short::MAX` instead.")] -pub const SHRT_MAX: c_short = 32767; +pub const SHRT_MAX: c_short = c_short::MAX; #[deprecated(since = "0.2.190", note = "Use `c_short::MIN` instead.")] -pub const SHRT_MIN: c_short = -32768; +pub const SHRT_MIN: c_short = c_short::MIN; #[deprecated(since = "0.2.190", note = "Use `c_ushort::MAX` instead.")] -pub const USHRT_MAX: c_ushort = 65535; +pub const USHRT_MAX: c_ushort = c_ushort::MAX; // POSIX Limits pub const ARG_MAX: c_int = 4096; diff --git a/src/sgx.rs b/src/sgx.rs index 7855e67ad3d59..6f891fce16748 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -12,6 +12,6 @@ pub type uintptr_t = usize; pub type ssize_t = isize; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483648; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index ee644731804ed..7184ccf05719c 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -177,9 +177,9 @@ s! { } #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483648; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; diff --git a/src/switch.rs b/src/switch.rs index 6ee4c5bae68c3..1d2d724bd91e4 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -14,6 +14,6 @@ pub type off_t = i64; pub type wchar_t = u32; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483648; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 7c18b498030ba..2b2eca29b6d12 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1,7 +1,10 @@ #![allow(dead_code)] -use crate::c_schar; use crate::prelude::*; +use crate::{ + c_schar, + ptrdiff_t, +}; // types pub type __s16_type = c_short; @@ -2635,79 +2638,79 @@ pub const TCP_REPAIR_OFF_NO_WP: c_int = -1; // stdint.h #[deprecated(since = "0.2.190", note = "Use `i8::MIN` instead.")] -pub const INT8_MIN: i8 = -128; +pub const INT8_MIN: i8 = i8::MIN; #[deprecated(since = "0.2.190", note = "Use `i16::MIN` instead.")] -pub const INT16_MIN: i16 = -32768; +pub const INT16_MIN: i16 = i16::MIN; #[deprecated(since = "0.2.190", note = "Use `i32::MIN` instead.")] -pub const INT32_MIN: i32 = -2147483648; +pub const INT32_MIN: i32 = i32::MIN; #[deprecated(since = "0.2.190", note = "Use `i8::MAX` instead.")] -pub const INT8_MAX: i8 = 127; +pub const INT8_MAX: i8 = i8::MAX; #[deprecated(since = "0.2.190", note = "Use `i16::MAX` instead.")] -pub const INT16_MAX: i16 = 32767; +pub const INT16_MAX: i16 = i16::MAX; #[deprecated(since = "0.2.190", note = "Use `i32::MAX` instead.")] -pub const INT32_MAX: i32 = 2147483647; +pub const INT32_MAX: i32 = i32::MAX; #[deprecated(since = "0.2.190", note = "Use `u8::MAX` instead.")] -pub const UINT8_MAX: u8 = 255; +pub const UINT8_MAX: u8 = u8::MAX; #[deprecated(since = "0.2.190", note = "Use `u16::MAX` instead.")] -pub const UINT16_MAX: u16 = 65535; +pub const UINT16_MAX: u16 = u16::MAX; #[deprecated(since = "0.2.190", note = "Use `u32::MAX` instead.")] -pub const UINT32_MAX: u32 = 4294967295; +pub const UINT32_MAX: u32 = u32::MAX; #[deprecated(since = "0.2.190", note = "Use `int_least8_t::MIN` instead.")] -pub const INT_LEAST8_MIN: int_least8_t = -128; +pub const INT_LEAST8_MIN: int_least8_t = int_least8_t::MIN; #[deprecated(since = "0.2.190", note = "Use `int_least16_t::MIN` instead.")] -pub const INT_LEAST16_MIN: int_least16_t = -32768; +pub const INT_LEAST16_MIN: int_least16_t = int_least16_t::MIN; #[deprecated(since = "0.2.190", note = "Use `int_least32_t::MIN` instead.")] -pub const INT_LEAST32_MIN: int_least32_t = -2147483648; +pub const INT_LEAST32_MIN: int_least32_t = int_least32_t::MIN; #[deprecated(since = "0.2.190", note = "Use `int_least8_t::MAX` instead.")] -pub const INT_LEAST8_MAX: int_least8_t = 127; +pub const INT_LEAST8_MAX: int_least8_t = int_least8_t::MAX; #[deprecated(since = "0.2.190", note = "Use `int_least16_t::MAX` instead.")] -pub const INT_LEAST16_MAX: int_least16_t = 32767; +pub const INT_LEAST16_MAX: int_least16_t = int_least16_t::MAX; #[deprecated(since = "0.2.190", note = "Use `int_least32_t::MAX` instead.")] -pub const INT_LEAST32_MAX: int_least32_t = 2147483647; +pub const INT_LEAST32_MAX: int_least32_t = int_least32_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uint_least8_t::MAX` instead.")] -pub const UINT_LEAST8_MAX: uint_least8_t = 255; +pub const UINT_LEAST8_MAX: uint_least8_t = uint_least8_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uint_least16_t::MAX` instead.")] -pub const UINT_LEAST16_MAX: uint_least16_t = 65535; +pub const UINT_LEAST16_MAX: uint_least16_t = uint_least16_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uint_least32_t::MAX` instead.")] -pub const UINT_LEAST32_MAX: uint_least32_t = 4294967295; +pub const UINT_LEAST32_MAX: uint_least32_t = uint_least32_t::MAX; #[deprecated(since = "0.2.190", note = "Use `int_fast8_t::MIN` instead.")] -pub const INT_FAST8_MIN: int_fast8_t = -128; +pub const INT_FAST8_MIN: int_fast8_t = int_fast8_t::MIN; #[deprecated(since = "0.2.190", note = "Use `int_fast16_t::MIN` instead.")] -pub const INT_FAST16_MIN: int_fast16_t = -2147483648; +pub const INT_FAST16_MIN: int_fast16_t = int_fast16_t::MIN; #[deprecated(since = "0.2.190", note = "Use `int_fast32_t::MIN` instead.")] -pub const INT_FAST32_MIN: int_fast32_t = -2147483648; +pub const INT_FAST32_MIN: int_fast32_t = int_fast32_t::MIN; #[deprecated(since = "0.2.190", note = "Use `int_fast8_t::MAX` instead.")] -pub const INT_FAST8_MAX: int_fast8_t = 127; +pub const INT_FAST8_MAX: int_fast8_t = int_fast8_t::MAX; #[deprecated(since = "0.2.190", note = "Use `int_fast16_t::MAX` instead.")] -pub const INT_FAST16_MAX: int_fast16_t = 2147483647; +pub const INT_FAST16_MAX: int_fast16_t = int_fast16_t::MAX; #[deprecated(since = "0.2.190", note = "Use `int_fast32_t::MAX` instead.")] -pub const INT_FAST32_MAX: int_fast32_t = 2147483647; +pub const INT_FAST32_MAX: int_fast32_t = int_fast32_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uint_fast8_t::MAX` instead.")] -pub const UINT_FAST8_MAX: uint_fast8_t = 255; +pub const UINT_FAST8_MAX: uint_fast8_t = uint_fast8_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uint_fast16_t::MAX` instead.")] -pub const UINT_FAST16_MAX: uint_fast16_t = 4294967295; +pub const UINT_FAST16_MAX: uint_fast16_t = uint_fast16_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uint_fast32_t::MAX` instead.")] -pub const UINT_FAST32_MAX: uint_fast32_t = 4294967295; +pub const UINT_FAST32_MAX: uint_fast32_t = uint_fast32_t::MAX; #[deprecated(since = "0.2.190", note = "Use `intptr_t::MIN` instead.")] -pub const INTPTR_MIN: __intptr_t = -2147483648; +pub const INTPTR_MIN: intptr_t = intptr_t::MIN; #[deprecated(since = "0.2.190", note = "Use `intptr_t::MAX` instead.")] -pub const INTPTR_MAX: __intptr_t = 2147483647; +pub const INTPTR_MAX: intptr_t = intptr_t::MAX; #[deprecated(since = "0.2.190", note = "Use `uintptr_t::MAX` instead.")] -pub const UINTPTR_MAX: usize = 4294967295; +pub const UINTPTR_MAX: uintptr_t = uintptr_t::MAX; #[deprecated(since = "0.2.190", note = "Use `ptrdiff_t::MIN` instead.")] -pub const PTRDIFF_MIN: __ptrdiff_t = -2147483648; +pub const PTRDIFF_MIN: ptrdiff_t = ptrdiff_t::MIN; #[deprecated(since = "0.2.190", note = "Use `ptrdiff_t::MAX` instead.")] -pub const PTRDIFF_MAX: __ptrdiff_t = 2147483647; +pub const PTRDIFF_MAX: ptrdiff_t = ptrdiff_t::MAX; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const SIG_ATOMIC_MIN: __sig_atomic_t = -2147483648; +pub const SIG_ATOMIC_MIN: __sig_atomic_t = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const SIG_ATOMIC_MAX: __sig_atomic_t = 2147483647; +pub const SIG_ATOMIC_MAX: __sig_atomic_t = c_int::MAX; #[deprecated(since = "0.2.190", note = "Use `size_t::MAX` instead.")] -pub const SIZE_MAX: usize = 4294967295; +pub const SIZE_MAX: size_t = size_t::MAX; #[deprecated(since = "0.2.190", note = "Use `wint_t::MIN` instead.")] -pub const WINT_MIN: wint_t = 0; +pub const WINT_MIN: wint_t = wint_t::MIN; #[deprecated(since = "0.2.190", note = "Use `wint_t::MAX` instead.")] -pub const WINT_MAX: wint_t = 4294967295; +pub const WINT_MAX: wint_t = wint_t::MAX; pub const INT8_WIDTH: usize = 8; pub const UINT8_WIDTH: usize = 8; pub const INT16_WIDTH: usize = 16; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index b0863c49bb05e..b15b0633c55af 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -232,9 +232,9 @@ s! { } #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483648; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 25ae648cc24c9..07bf8b49ec4dc 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -681,9 +681,9 @@ pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 0x7fffffff; +pub const INT_MAX: c_int = c_int::MAX; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -0x7fffffff - 1; +pub const INT_MIN: c_int = c_int::MIN; // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 50a7866e9a943..d2d6c281346a9 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -97,9 +97,9 @@ s! { } #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483648; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; diff --git a/src/xous.rs b/src/xous.rs index cf4a343e228f9..713eab6f4107a 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -15,6 +15,6 @@ pub type off_t = i64; pub type wchar_t = u32; #[deprecated(since = "0.2.190", note = "Use `c_int::MIN` instead.")] -pub const INT_MIN: c_int = -2147483648; +pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] -pub const INT_MAX: c_int = 2147483647; +pub const INT_MAX: c_int = c_int::MAX; From 66f7e6846bd45836d83113e8b6393c1f3be2c3bf Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Aug 2026 20:19:05 +0200 Subject: [PATCH 34/88] Use correct target_arch macOS link_name overrides This makes it clearer where these overrides are required. There should be no functional changes here (since the only three architectures we support for macOS are x86, x86_64 and aarch64). (backport ) (cherry picked from commit 6bf10ade8df1f67b34498654d6b60f5db51fe3bd) --- src/unix/bsd/apple/mod.rs | 8 ++++---- src/unix/bsd/mod.rs | 2 +- src/unix/mod.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index f3c40cc02b225..fad8f93313330 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4645,12 +4645,12 @@ extern "C" { ); pub fn backtrace_async(array: *mut *mut c_void, length: size_t, task_id: *mut u32) -> size_t; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "statfs$INODE64" )] pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "fstatfs$INODE64" )] pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; @@ -4903,12 +4903,12 @@ extern "C" { pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "getmntinfo$INODE64" )] pub fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "getfsstat$INODE64" )] pub fn getfsstat(mntbufp: *mut statfs, bufsize: c_int, flags: c_int) -> c_int; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a734ec4776a5a..a656bcbd1ee8c 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -572,7 +572,7 @@ extern "C" { pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "glob$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] diff --git a/src/unix/mod.rs b/src/unix/mod.rs index b15b0633c55af..43d7346aca9a0 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -928,7 +928,7 @@ extern "C" { pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "fstat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] @@ -947,7 +947,7 @@ extern "C" { pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "stat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] @@ -1015,7 +1015,7 @@ extern "C" { pub fn fdopendir(fd: c_int) -> *mut crate::DIR; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "readdir$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] @@ -1053,7 +1053,7 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "fstatat$INODE64" )] #[cfg_attr( @@ -1265,7 +1265,7 @@ extern "C" { pub fn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "lstat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] @@ -2250,7 +2250,7 @@ cfg_if! { )] pub fn pause() -> c_int; #[cfg_attr( - all(target_os = "macos", not(target_arch = "aarch64")), + all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "readdir_r$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] From a8a26001ca458bdf43eb6a0a19e82cd399ec4e2b Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Aug 2026 20:24:19 +0200 Subject: [PATCH 35/88] Use target_vendor = "apple" when possible This fixes: - The value of `FNM_PATHNAME` and `FNM_NOESCAPE` on iOS, tvOS, watchOS and visionOS. - `memmem` and `task_set_info` not being available on watchOS. - `sigqueue` not being available on iOS, tvOS, watchOS and visionOS. (backport ) (cherry picked from commit e931965c6e922bfeb35216f1b0d3691aab9edb86) --- libc-test/tests/makedev.rs | 8 +------- src/unix/bsd/apple/mod.rs | 8 ++------ src/unix/bsd/mod.rs | 18 ++--------------- src/unix/mod.rs | 40 +++++++------------------------------- 4 files changed, 12 insertions(+), 62 deletions(-) diff --git a/libc-test/tests/makedev.rs b/libc-test/tests/makedev.rs index 9e76b30acfb79..6620294ce0385 100644 --- a/libc-test/tests/makedev.rs +++ b/libc-test/tests/makedev.rs @@ -44,13 +44,7 @@ cfg_if::cfg_if! { ))] { pub type MajorRetType = libc::c_int; pub type MinorRetType = libc::c_int; - } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ))] { + } else if #[cfg(target_vendor = "apple")] { pub type MajorRetType = i32; pub type MinorRetType = i32; } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index fad8f93313330..681803f614121 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5218,6 +5218,7 @@ pub unsafe fn mach_task_self() -> crate::mach_port_t { } cfg_if! { + // Prohibited on iOS/tvOS/watchOS/visionOS if #[cfg(target_os = "macos")] { extern "C" { pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; @@ -5225,12 +5226,7 @@ cfg_if! { } } cfg_if! { - if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "visionos" - ))] { + if #[cfg(target_vendor = "apple")] { extern "C" { pub fn memmem( haystack: *const c_void, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a656bcbd1ee8c..30178694005a8 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -40,15 +40,7 @@ s! { pub pw_shell: *mut c_char, pub pw_expire: crate::time_t, - #[cfg(not(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", - target_os = "netbsd", - target_os = "openbsd" - )))] + #[cfg(not(any(target_vendor = "apple", target_os = "netbsd", target_os = "openbsd")))] pub pw_fields: c_int, } @@ -848,13 +840,7 @@ extern "C" { } cfg_if! { - if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ))] { + if #[cfg(target_vendor = "apple")] { mod apple; pub use self::apple::*; } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 43d7346aca9a0..3a34d68d6be9f 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -386,7 +386,7 @@ cfg_if! { cfg_if! { if #[cfg(any( - target_os = "macos", + target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "android", @@ -402,7 +402,7 @@ cfg_if! { cfg_if! { if #[cfg(any( - target_os = "macos", + target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "android", @@ -574,11 +574,7 @@ cfg_if! { #[link(name = "c", cfg(not(target_feature = "crt-static")))] extern "C" {} } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", + target_vendor = "apple", target_os = "android", target_os = "openbsd", target_os = "nto", @@ -1313,16 +1309,7 @@ extern "C" { #[cfg_attr(musl_redir_time64, link_name = "__getrusage_time64")] pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; - #[cfg_attr( - any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ), - link_name = "realpath$DARWIN_EXTSN" - )] + #[cfg_attr(target_vendor = "apple", link_name = "realpath$DARWIN_EXTSN")] pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; #[cfg_attr(target_os = "netbsd", link_name = "__times13")] @@ -1500,16 +1487,7 @@ extern "C" { ), link_name = "__res_init" )] - #[cfg_attr( - any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos" - ), - link_name = "res_9_init" - )] + #[cfg_attr(target_vendor = "apple", link_name = "res_9_init")] #[cfg_attr(target_os = "aix", link_name = "_res_init")] #[cfg(not(target_os = "l4re"))] pub fn res_init() -> c_int; @@ -2193,7 +2171,7 @@ cfg_if! { target_os = "dragonfly", target_os = "emscripten", target_os = "hurd", - target_os = "macos", + target_vendor = "apple", target_os = "openbsd", target_os = "l4re", )))] { @@ -2489,11 +2467,7 @@ cfg_if! { mod linux_like; pub use self::linux_like::*; } else if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", + target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", From bbc690bbc7287207d4297e554f919b7d1db708c7 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Aug 2026 22:16:03 +0200 Subject: [PATCH 36/88] Mark a bunch of items as only available on macOS These either don't exist in the iOS, tvOS, watchOS and visionOS SDKs, or are marked as unavailable on those platforms. (backport ) (cherry picked from commit 00f55f680e60f2da07eeb85a2e068ee8654faa03) [ needed a slightly unusual resolution due to 790e5c6d3900 ("Remove removed items in OpenBSD") which isn't backported - Trevor ] --- libc-test/semver/apple.txt | 208 ------------- libc-test/semver/ios.txt | 6 + libc-test/semver/macos.txt | 209 ++++++++++++++ src/new/apple/xnu/net/mod.rs | 1 + src/new/apple/xnu/netinet6/mod.rs | 1 + src/new/mod.rs | 2 + src/unix/bsd/apple/b32/mod.rs | 15 +- src/unix/bsd/apple/b64/mod.rs | 15 +- src/unix/bsd/apple/mod.rs | 465 ++++++++++++++++++------------ src/unix/bsd/mod.rs | 122 +++++--- src/unix/mod.rs | 22 +- 11 files changed, 611 insertions(+), 455 deletions(-) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index bfe10bcf45b71..e9936724984bb 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -46,7 +46,6 @@ AF_ROUTE AF_SIP AF_SNA AF_SYSTEM -AF_SYS_CONTROL AIO_ALLDONE AIO_CANCELED AIO_LISTIO_MAX @@ -65,12 +64,6 @@ AI_V4MAPPED_CFG ALTWERASE ALT_DIGITS AM_STR -ARPOP_REPLY -ARPOP_REQUEST -ATF_COM -ATF_PERM -ATF_PUBL -ATF_USETRAILERS ATTR_BIT_MAP_COUNT ATTR_CMNEXT_CLONEID ATTR_CMNEXT_EXT_FLAGS @@ -162,31 +155,7 @@ B14400 B28800 B7200 B76800 -BIOCFLUSH -BIOCGBLEN -BIOCGDLT -BIOCGDLTLIST -BIOCGETIF -BIOCGHDRCMPLT -BIOCGRSIG -BIOCGRTIMEOUT -BIOCGSEESENT -BIOCGSTATS -BIOCIMMEDIATE -BIOCPROMISC -BIOCSBLEN -BIOCSDLT -BIOCSETF -BIOCSETFNR -BIOCSETIF -BIOCSHDRCMPLT -BIOCSRSIG -BIOCSRTIMEOUT -BIOCSSEESENT -BIOCVERSION BOOT_TIME -BPF_ALIGNMENT -BPF_WORDALIGN BS0 BS1 BSDLY @@ -280,7 +249,6 @@ CTLFLAG_RD CTLFLAG_RW CTLFLAG_SECURE CTLFLAG_WR -CTLIOCGINFO CTLTYPE CTLTYPE_INT CTLTYPE_NODE @@ -310,20 +278,6 @@ DAY_6 DAY_7 DEAD_PROCESS DIR_MNTSTATUS_MNTPOINT -DLT_ARCNET -DLT_ATM_RFC1483 -DLT_AX25 -DLT_CHAOS -DLT_EN10MB -DLT_EN3MB -DLT_FDDI -DLT_IEEE802 -DLT_LOOP -DLT_NULL -DLT_PPP -DLT_PRONET -DLT_RAW -DLT_SLIP DT_UNKNOWN D_FMT D_MD_ORDER @@ -528,19 +482,6 @@ IFF_RUNNING IFF_SIMPLEX IFF_UP IMAXBEL -IN6_IFF_ANYCAST -IN6_IFF_AUTOCONF -IN6_IFF_CLAT46 -IN6_IFF_DEPRECATED -IN6_IFF_DETACHED -IN6_IFF_DUPLICATED -IN6_IFF_DYNAMIC -IN6_IFF_NODAD -IN6_IFF_NOPFX -IN6_IFF_OPTIMISTIC -IN6_IFF_SECURED -IN6_IFF_TEMPORARY -IN6_IFF_TENTATIVE INIT_PROCESS IOV_MAX IPC_CREAT @@ -1147,12 +1088,6 @@ PRIO_DARWIN_BG PRIO_DARWIN_NONUI PRIO_DARWIN_PROCESS PRIO_DARWIN_THREAD -PROC_CSM_ALL -PROC_CSM_NOSMT -PROC_CSM_TECS -PROC_PIDTASKALLINFO -PROC_PIDTASKINFO -PROC_PIDTHREADINFO PTHREAD_CANCELED PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_DEFERRED @@ -1177,24 +1112,6 @@ PTHREAD_PROCESS_SHARED PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_SYSTEM PTHREAD_STACK_MIN -PT_ATTACH -PT_ATTACHEXC -PT_CONTINUE -PT_DENY_ATTACH -PT_DETACH -PT_FIRSTMACH -PT_FORCEQUOTA -PT_KILL -PT_READ_D -PT_READ_I -PT_READ_U -PT_SIGEXC -PT_STEP -PT_THUPDATE -PT_TRACE_ME -PT_WRITE_D -PT_WRITE_I -PT_WRITE_U P_ALL P_PGID P_PID @@ -1252,86 +1169,11 @@ RLIMIT_RSS RLIMIT_STACK RLIM_INFINITY RLIM_NLIMITS -RTAX_AUTHOR -RTAX_BRD -RTAX_DST -RTAX_GATEWAY -RTAX_GENMASK -RTAX_IFA -RTAX_IFP -RTAX_MAX -RTAX_NETMASK -RTA_AUTHOR -RTA_BRD -RTA_DST -RTA_GATEWAY -RTA_GENMASK -RTA_IFA -RTA_IFP -RTA_NETMASK -RTF_BLACKHOLE -RTF_BROADCAST -RTF_CLONING -RTF_CONDEMNED -RTF_DEAD -RTF_DELCLONE -RTF_DONE -RTF_DYNAMIC -RTF_GATEWAY -RTF_GLOBAL -RTF_HOST -RTF_IFREF -RTF_IFSCOPE -RTF_LLINFO -RTF_LOCAL -RTF_MODIFIED -RTF_MULTICAST -RTF_NOIFREF -RTF_PINNED -RTF_PRCLONING -RTF_PROTO1 -RTF_PROTO2 -RTF_PROTO3 -RTF_PROXY -RTF_REJECT -RTF_ROUTER -RTF_STATIC -RTF_UP -RTF_WASCLONED -RTF_XRESOLVE RTLD_FIRST RTLD_NEXT RTLD_NODELETE RTLD_NOLOAD RTLD_SELF -RTM_ADD -RTM_CHANGE -RTM_DELADDR -RTM_DELETE -RTM_DELMADDR -RTM_GET -RTM_GET2 -RTM_IFINFO -RTM_IFINFO2 -RTM_LOCK -RTM_LOSING -RTM_MISS -RTM_NEWADDR -RTM_NEWMADDR -RTM_NEWMADDR2 -RTM_OLDADD -RTM_OLDDEL -RTM_REDIRECT -RTM_RESOLVE -RTM_VERSION -RTV_EXPIRE -RTV_HOPCOUNT -RTV_MTU -RTV_RPIPE -RTV_RTT -RTV_RTTVAR -RTV_SPIPE -RTV_SSTHRESH RUN_LVL RUSAGE_CHILDREN RUSAGE_SELF @@ -1384,7 +1226,6 @@ SIOCGETVLAN SIOCGHIWAT SIOCGIF6LOWPAN SIOCGIFADDR -SIOCGIFAFLAG_IN6 SIOCGIFALTMTU SIOCGIFASYNCMAP SIOCGIFBOND @@ -1491,8 +1332,6 @@ ST_RDONLY SUPERPAGE_NONE SUPERPAGE_SIZE_2MB SUPERPAGE_SIZE_ANY -SYSPROTO_CONTROL -SYSPROTO_EVENT S_IEXEC S_IREAD S_IWRITE @@ -1696,8 +1535,6 @@ USER_STREAM_MAX USER_TZNAME_MAX UTIME_NOW UTIME_OMIT -UTUN_OPT_FLAGS -UTUN_OPT_IFNAME VDISCARD VDSUSP VLNEXT @@ -2029,7 +1866,6 @@ __PTHREAD_MUTEX_SIZE__ __PTHREAD_ONCE_SIZE__ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ -__c_anonymous_bfl_u __darwin_mcontext64 __error _dyld_get_image_header @@ -2049,7 +1885,6 @@ aiocb arc4random arc4random_buf arc4random_uniform -arphdr asctime asctime_r attrgroup_t @@ -2063,11 +1898,6 @@ backtrace_symbols backtrace_symbols_fd basename boolean_t -bpf_dltlist -bpf_hdr -bpf_insn -bpf_program -brk bsearch chflags chroot @@ -2088,7 +1918,6 @@ cpu_subtype_t cpu_type_t ctime ctime_r -ctl_info devname difftime dirfd @@ -2100,7 +1929,6 @@ endgrent endpwent endservent endutxent -exchangedata execvP faccessat fchdir @@ -2171,7 +1999,6 @@ group_source_req host_cpu_load_info host_cpu_load_info_data_t host_cpu_load_info_t -icmp6_ifstat iconv iconv_close iconv_open @@ -2187,9 +2014,6 @@ ifconf ifkpi ifreq image_offset -in6_addrlifetime -in6_ifreq -in6_ifstat in6_pktinfo in_pktinfo initgroups @@ -2330,27 +2154,6 @@ posix_spawnattr_setsigmask posix_spawnattr_t posix_spawnp preadv -proc_bsdinfo -proc_bsdshortinfo -proc_kmsgbuf -proc_libversion -proc_listallpids -proc_listchildpids -proc_listpgrppids -proc_listpids -proc_name -proc_pidfdinfo -proc_pidfileportinfo -proc_pidinfo -proc_pidpath -proc_regionfilename -proc_set_csm -proc_set_no_smt -proc_setthread_csm -proc_setthread_no_smt -proc_taskallinfo -proc_taskinfo -proc_threadinfo pseudo_AF_HDRCMPLT pseudo_AF_KEY pseudo_AF_PIP @@ -2386,11 +2189,6 @@ pthread_introspection_getspecific_np pthread_introspection_hook_install pthread_introspection_hook_t pthread_introspection_setspecific_np -pthread_jit_write_callback_t -pthread_jit_write_freeze_callbacks_np -pthread_jit_write_protect_np -pthread_jit_write_protect_supported_np -pthread_jit_write_with_callback_np pthread_kill pthread_main_np pthread_mutexattr_getpshared @@ -2403,7 +2201,6 @@ pthread_set_qos_class_self_np pthread_setname_np pthread_setschedparam pthread_stack_frame_decode_np -ptrace pututxline pwritev qsort @@ -2428,7 +2225,6 @@ renamex_np sa_endpoints_t sae_associd_t sae_connid_t -sbrk sched_get_priority_max sched_get_priority_min sched_param @@ -2469,14 +2265,11 @@ shmctl shmdt shmget shmid_ds -sigaltstack sigevent siginfo_t sigsuspend sigwait -sockaddr_ctl sockaddr_dl -sockaddr_inarp srand stack_t statfs @@ -2490,7 +2283,6 @@ strptime strsignal strtonum sync -syscall sysctl sysctlbyname sysctlnametomib diff --git a/libc-test/semver/ios.txt b/libc-test/semver/ios.txt index 1a5fcd2ac3fe2..b0677a99091da 100644 --- a/libc-test/semver/ios.txt +++ b/libc-test/semver/ios.txt @@ -1,3 +1,9 @@ __darwin_arm_exception_state64 __darwin_arm_neon_state64 __darwin_arm_thread_state64 +brk +exchangedata +sbrk +sigaltstack +syscall +task_set_info diff --git a/libc-test/semver/macos.txt b/libc-test/semver/macos.txt index 048c8a120329b..75785a3cb7491 100644 --- a/libc-test/semver/macos.txt +++ b/libc-test/semver/macos.txt @@ -1,7 +1,216 @@ +AF_SYS_CONTROL +ARPOP_REPLY +ARPOP_REQUEST +ATF_COM +ATF_PERM +ATF_PUBL +ATF_USETRAILERS +BIOCFLUSH +BIOCGBLEN +BIOCGDLT +BIOCGDLTLIST +BIOCGETIF +BIOCGHDRCMPLT +BIOCGRSIG +BIOCGRTIMEOUT +BIOCGSEESENT +BIOCGSTATS +BIOCIMMEDIATE +BIOCPROMISC +BIOCSBLEN +BIOCSDLT +BIOCSETF +BIOCSETFNR +BIOCSETIF +BIOCSHDRCMPLT +BIOCSRSIG +BIOCSRTIMEOUT +BIOCSSEESENT +BIOCVERSION +BPF_ALIGNMENT +BPF_WORDALIGN CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC_RAW_APPROX CLOCK_UPTIME_RAW CLOCK_UPTIME_RAW_APPROX +CTLIOCGINFO +DLT_ARCNET +DLT_ATM_RFC1483 +DLT_AX25 +DLT_CHAOS +DLT_EN10MB +DLT_EN3MB +DLT_FDDI +DLT_IEEE802 +DLT_LOOP +DLT_NULL +DLT_PPP +DLT_PRONET +DLT_RAW +DLT_SLIP +IN6_IFF_ANYCAST +IN6_IFF_AUTOCONF +IN6_IFF_CLAT46 +IN6_IFF_DEPRECATED +IN6_IFF_DETACHED +IN6_IFF_DUPLICATED +IN6_IFF_DYNAMIC +IN6_IFF_NODAD +IN6_IFF_NOPFX +IN6_IFF_OPTIMISTIC +IN6_IFF_SECURED +IN6_IFF_TEMPORARY +IN6_IFF_TENTATIVE +PROC_CSM_ALL +PROC_CSM_NOSMT +PROC_CSM_TECS +PROC_PIDTASKALLINFO +PROC_PIDTASKINFO +PROC_PIDTHREADINFO +PT_ATTACH +PT_ATTACHEXC +PT_CONTINUE +PT_DENY_ATTACH +PT_DETACH +PT_FIRSTMACH +PT_FORCEQUOTA +PT_KILL +PT_READ_D +PT_READ_I +PT_READ_U +PT_SIGEXC +PT_STEP +PT_THUPDATE +PT_TRACE_ME +PT_WRITE_D +PT_WRITE_I +PT_WRITE_U +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_MAX +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK +RTF_BLACKHOLE +RTF_BROADCAST +RTF_CLONING +RTF_CONDEMNED +RTF_DEAD +RTF_DELCLONE +RTF_DONE +RTF_DYNAMIC +RTF_GATEWAY +RTF_GLOBAL +RTF_HOST +RTF_IFREF +RTF_IFSCOPE +RTF_LLINFO +RTF_LOCAL +RTF_MODIFIED +RTF_MULTICAST +RTF_NOIFREF +RTF_PINNED +RTF_PRCLONING +RTF_PROTO1 +RTF_PROTO2 +RTF_PROTO3 +RTF_PROXY +RTF_REJECT +RTF_ROUTER +RTF_STATIC +RTF_UP +RTF_WASCLONED +RTF_XRESOLVE +RTM_ADD +RTM_CHANGE +RTM_DELADDR +RTM_DELETE +RTM_DELMADDR +RTM_GET +RTM_GET2 +RTM_IFINFO +RTM_IFINFO2 +RTM_LOCK +RTM_LOSING +RTM_MISS +RTM_NEWADDR +RTM_NEWMADDR +RTM_NEWMADDR2 +RTM_OLDADD +RTM_OLDDEL +RTM_REDIRECT +RTM_RESOLVE +RTM_VERSION +RTV_EXPIRE +RTV_HOPCOUNT +RTV_MTU +RTV_RPIPE +RTV_RTT +RTV_RTTVAR +RTV_SPIPE +RTV_SSTHRESH +SIOCGIFAFLAG_IN6 +SYSPROTO_CONTROL +SYSPROTO_EVENT +UTUN_OPT_FLAGS +UTUN_OPT_IFNAME +__c_anonymous_bfl_u +arphdr +bpf_dltlist +bpf_hdr +bpf_insn +bpf_program +brk clock_settime +ctl_info +exchangedata +gethostuuid +icmp6_ifstat +in6_addrlifetime +in6_ifreq +in6_ifstat memmem +proc_bsdinfo +proc_bsdshortinfo +proc_kmsgbuf +proc_libversion +proc_listallpids +proc_listchildpids +proc_listpgrppids +proc_listpids +proc_name +proc_pidfdinfo +proc_pidfileportinfo +proc_pidinfo +proc_pidpath +proc_regionfilename +proc_set_csm +proc_set_no_smt +proc_setthread_csm +proc_setthread_no_smt +proc_taskallinfo +proc_taskinfo +proc_threadinfo +pthread_jit_write_callback_t +pthread_jit_write_freeze_callbacks_np +pthread_jit_write_protect_np +pthread_jit_write_protect_supported_np +pthread_jit_write_with_callback_np +ptrace +sbrk +sigaltstack +sockaddr_ctl +sockaddr_inarp +syscall task_set_info diff --git a/src/new/apple/xnu/net/mod.rs b/src/new/apple/xnu/net/mod.rs index c2844db51cf88..967a0a07462cd 100644 --- a/src/new/apple/xnu/net/mod.rs +++ b/src/new/apple/xnu/net/mod.rs @@ -2,4 +2,5 @@ //! //! +#[cfg(target_os = "macos")] pub(crate) mod bpf; diff --git a/src/new/apple/xnu/netinet6/mod.rs b/src/new/apple/xnu/netinet6/mod.rs index 1592863f7314e..daebfb61bedf7 100644 --- a/src/new/apple/xnu/netinet6/mod.rs +++ b/src/new/apple/xnu/netinet6/mod.rs @@ -2,4 +2,5 @@ //! //! +#[cfg(target_os = "macos")] pub(crate) mod in6_var; diff --git a/src/new/mod.rs b/src/new/mod.rs index 06e27f2ad0fa2..397275932c509 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -199,8 +199,10 @@ cfg_if! { #[cfg(target_env = "gnu")] pub use signal::*; } else if #[cfg(target_vendor = "apple")] { + #[cfg(target_os = "macos")] pub use net::bpf::*; pub use netinet::tcp::*; + #[cfg(target_os = "macos")] pub use netinet6::in6_var::*; pub use pthread_::introspection::*; pub use pthread_::pthread_spis::*; diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index d6016483a6c42..f6e861abc3434 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -37,6 +37,7 @@ s! { pub ifi_reserved2: u32, } + #[cfg(target_os = "macos")] pub struct bpf_hdr { pub bh_tstamp: crate::timeval, pub bh_caplen: u32, @@ -56,11 +57,17 @@ s_no_extra_traits! { } } -pub const BIOCSETF: c_ulong = 0x80084267; -pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; -pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; -pub const BIOCSETFNR: c_ulong = 0x8008427e; +cfg_if! { + if #[cfg(target_os = "macos")] { + pub const BIOCSETF: c_ulong = 0x80084267; + pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; + pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; + pub const BIOCSETFNR: c_ulong = 0x8008427e; + } +} extern "C" { + // `exchangedata` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_ulong) -> c_int; } diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index a973f3db11ec3..541d16e3e5608 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -41,6 +41,7 @@ s! { pub ifi_reserved2: u32, } + #[cfg(target_os = "macos")] pub struct bpf_hdr { pub bh_tstamp: crate::timeval32, pub bh_caplen: u32, @@ -49,12 +50,18 @@ s! { } } -pub const BIOCSETF: c_ulong = 0x80104267; -pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; -pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; -pub const BIOCSETFNR: c_ulong = 0x8010427e; +cfg_if! { + if #[cfg(target_os = "macos")] { + pub const BIOCSETF: c_ulong = 0x80104267; + pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; + pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; + pub const BIOCSETFNR: c_ulong = 0x8010427e; + } +} extern "C" { + // `exchangedata` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_uint) -> c_int; } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 681803f614121..f9eee3c66855b 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -130,6 +130,7 @@ pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy; pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy; pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy; +#[cfg(target_os = "macos")] pub type pthread_jit_write_callback_t = Option c_int>; pub type os_clockid_t = u32; @@ -483,6 +484,7 @@ s! { pub ifmam_refcount: i32, } + #[cfg(target_os = "macos")] pub struct rt_metrics { pub rmx_locks: u32, pub rmx_mtu: u32, @@ -500,6 +502,7 @@ s! { pub rmx_filler: [u32; 3], } + #[cfg(target_os = "macos")] pub struct rt_msghdr { pub rtm_msglen: c_ushort, pub rtm_version: c_uchar, @@ -515,6 +518,7 @@ s! { pub rtm_rmx: rt_metrics, } + #[cfg(target_os = "macos")] pub struct rt_msghdr2 { pub rtm_msglen: c_ushort, pub rtm_version: c_uchar, @@ -582,6 +586,7 @@ s! { pub int_n_sign_posn: c_char, } + #[cfg(target_os = "macos")] pub struct proc_taskinfo { pub pti_virtual_size: u64, pub pti_resident_size: u64, @@ -603,6 +608,7 @@ s! { pub pti_priority: i32, } + #[cfg(target_os = "macos")] pub struct proc_bsdinfo { pub pbi_flags: u32, pub pbi_status: u32, @@ -628,6 +634,7 @@ s! { pub pbi_start_tvusec: u64, } + #[cfg(target_os = "macos")] pub struct proc_bsdshortinfo { /// Process ID. pub pbsi_pid: u32, @@ -657,6 +664,7 @@ s! { pbsi_rfu: u32, } + #[cfg(target_os = "macos")] pub struct proc_taskallinfo { pub pbsd: proc_bsdinfo, pub ptinfo: proc_taskinfo, @@ -744,6 +752,7 @@ s! { pub sdl_data: [c_char; 12], } + #[cfg(target_os = "macos")] pub struct sockaddr_inarp { pub sin_len: c_uchar, pub sin_family: c_uchar, @@ -754,6 +763,7 @@ s! { pub sin_other: c_ushort, } + #[cfg(target_os = "macos")] pub struct sockaddr_ctl { pub sc_len: c_uchar, pub sc_family: c_uchar, @@ -787,15 +797,14 @@ s! { } // sys/sem.h - pub struct sembuf { pub sem_num: c_ushort, pub sem_op: c_short, pub sem_flg: c_short, } - // sys/shm.h - + // sys/if_arp.h + #[cfg(target_os = "macos")] pub struct arphdr { pub ar_hrd: u16, pub ar_pro: u16, @@ -809,6 +818,7 @@ s! { } // net/ndrv.h + #[cfg(target_os = "macos")] pub struct sockaddr_ndrv { pub snd_len: c_uchar, pub snd_family: c_uchar, @@ -909,6 +919,7 @@ s! { pub size: crate::vm_size_t, } + #[cfg(target_os = "macos")] pub struct vinfo_stat { pub vst_dev: u32, pub vst_mode: u16, @@ -933,6 +944,7 @@ s! { pub vst_qspare: [i64; 2], } + #[cfg(target_os = "macos")] pub struct vnode_info { pub vi_stat: vinfo_stat, pub vi_type: c_int, @@ -940,6 +952,7 @@ s! { pub vi_fsid: crate::fsid_t, } + #[cfg(target_os = "macos")] pub struct vnode_info_path { pub vip_vi: vnode_info, // Normally it's `vip_path: [c_char; MAXPATHLEN]` but because libc supports an old rustc @@ -947,6 +960,7 @@ s! { pub vip_path: [[c_char; 32]; 32], } + #[cfg(target_os = "macos")] pub struct proc_vnodepathinfo { pub pvi_cdir: vnode_info_path, pub pvi_rdir: vnode_info_path, @@ -1182,6 +1196,7 @@ s! { pub tcpi_rxretransmitpackets: u64, } + #[cfg(target_os = "macos")] pub struct in6_addrlifetime { pub ia6t_expire: time_t, pub ia6t_preferred: time_t, @@ -1189,6 +1204,7 @@ s! { pub ia6t_pltime: u32, } + #[cfg(target_os = "macos")] pub struct in6_ifstat { pub ifs6_in_receive: crate::u_quad_t, pub ifs6_in_hdrerr: crate::u_quad_t, @@ -1217,6 +1233,7 @@ s! { pub ifs6_defrtr_expiry_cnt: crate::u_quad_t, } + #[cfg(target_os = "macos")] pub struct icmp6_ifstat { pub ifs6_in_msg: crate::u_quad_t, pub ifs6_in_error: crate::u_quad_t, @@ -1260,6 +1277,7 @@ s! { } // net/if_mib.h + #[cfg(target_os = "macos")] pub struct ifmibdata { /// Name of interface pub ifmd_name: [c_char; crate::IFNAMSIZ], @@ -1279,6 +1297,7 @@ s! { pub ifmd_data: if_data64, } + #[cfg(target_os = "macos")] pub struct ifs_iso_8802_3 { pub dot3StatsAlignmentErrors: u32, pub dot3StatsFCSErrors: u32, @@ -1299,12 +1318,14 @@ s! { } // kern_control.h + #[cfg(target_os = "macos")] pub struct ctl_info { pub ctl_id: u32, pub ctl_name: [c_char; MAX_KCTL_NAME], } // sys/proc_info.h + #[cfg(target_os = "macos")] pub struct proc_fdinfo { pub proc_fd: i32, pub proc_fdtype: u32, @@ -1347,6 +1368,7 @@ s! { pub shm_internal: *mut c_void, } + #[cfg(target_os = "macos")] pub struct proc_threadinfo { pub pth_user_time: u64, pub pth_system_time: u64, @@ -1648,6 +1670,7 @@ s! { pub ifr_ifru: __c_anonymous_ifr_ifru, } + #[cfg(target_os = "macos")] pub struct in6_ifreq { pub ifr_name: [c_char; crate::IFNAMSIZ], pub ifr_ifru: __c_anonymous_ifr_ifru6, @@ -1688,19 +1711,25 @@ s_no_extra_traits! { pub ifcu_buf: *mut c_char, pub ifcu_req: *mut ifreq, } +} - pub union __c_anonymous_ifr_ifru6 { - pub ifru_addr: crate::sockaddr_in6, - pub ifru_dstaddr: crate::sockaddr_in6, - pub ifru_flags: c_int, - pub ifru_flags6: c_int, - pub ifru_metrics: c_int, - pub ifru_intval: c_int, - pub ifru_data: *mut c_char, - pub ifru_lifetime: in6_addrlifetime, - pub ifru_stat: in6_ifstat, - pub ifru_icmp6stat: icmp6_ifstat, - pub ifru_scope_id: [u32; SCOPE6_ID_MAX], +cfg_if! { + if #[cfg(target_os = "macos")] { + s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru6 { + pub ifru_addr: crate::sockaddr_in6, + pub ifru_dstaddr: crate::sockaddr_in6, + pub ifru_flags: c_int, + pub ifru_flags6: c_int, + pub ifru_metrics: c_int, + pub ifru_intval: c_int, + pub ifru_data: *mut c_char, + pub ifru_lifetime: in6_addrlifetime, + pub ifru_stat: in6_ifstat, + pub ifru_icmp6stat: icmp6_ifstat, + pub ifru_scope_id: [u32; SCOPE6_ID_MAX], + } + } } } @@ -1868,6 +1897,7 @@ cfg_if! { } } + #[cfg(target_os = "macos")] impl PartialEq for __c_anonymous_ifr_ifru6 { fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool { unsafe { @@ -1887,8 +1917,10 @@ cfg_if! { } } + #[cfg(target_os = "macos")] impl Eq for __c_anonymous_ifr_ifru6 {} + #[cfg(target_os = "macos")] impl hash::Hash for __c_anonymous_ifr_ifru6 { fn hash(&self, state: &mut H) { unsafe { @@ -2155,25 +2187,30 @@ pub const PROT_READ: c_int = 1; pub const PROT_WRITE: c_int = 2; pub const PROT_EXEC: c_int = 4; -pub const PT_TRACE_ME: c_int = 0; -pub const PT_READ_I: c_int = 1; -pub const PT_READ_D: c_int = 2; -pub const PT_READ_U: c_int = 3; -pub const PT_WRITE_I: c_int = 4; -pub const PT_WRITE_D: c_int = 5; -pub const PT_WRITE_U: c_int = 6; -pub const PT_CONTINUE: c_int = 7; -pub const PT_KILL: c_int = 8; -pub const PT_STEP: c_int = 9; -pub const PT_ATTACH: c_int = 10; -pub const PT_DETACH: c_int = 11; -pub const PT_SIGEXC: c_int = 12; -pub const PT_THUPDATE: c_int = 13; -pub const PT_ATTACHEXC: c_int = 14; - -pub const PT_FORCEQUOTA: c_int = 30; -pub const PT_DENY_ATTACH: c_int = 31; -pub const PT_FIRSTMACH: c_int = 32; +cfg_if! { + if #[cfg(target_os = "macos")] { + // ptrace.h + pub const PT_TRACE_ME: c_int = 0; + pub const PT_READ_I: c_int = 1; + pub const PT_READ_D: c_int = 2; + pub const PT_READ_U: c_int = 3; + pub const PT_WRITE_I: c_int = 4; + pub const PT_WRITE_D: c_int = 5; + pub const PT_WRITE_U: c_int = 6; + pub const PT_CONTINUE: c_int = 7; + pub const PT_KILL: c_int = 8; + pub const PT_STEP: c_int = 9; + pub const PT_ATTACH: c_int = 10; + pub const PT_DETACH: c_int = 11; + pub const PT_SIGEXC: c_int = 12; + pub const PT_THUPDATE: c_int = 13; + pub const PT_ATTACHEXC: c_int = 14; + + pub const PT_FORCEQUOTA: c_int = 30; + pub const PT_DENY_ATTACH: c_int = 31; + pub const PT_FIRSTMACH: c_int = 32; + } +} pub const MAP_FILE: c_int = 0x0000; pub const MAP_SHARED: c_int = 0x0001; @@ -2595,7 +2632,11 @@ pub const MINCORE_MODIFIED: c_int = 0x4; pub const MINCORE_REFERENCED_OTHER: c_int = 0x8; pub const MINCORE_MODIFIED_OTHER: c_int = 0x10; -pub const CTLIOCGINFO: c_ulong = 0xc0644e03; +cfg_if! { + if #[cfg(target_os = "macos")] { + pub const CTLIOCGINFO: c_ulong = 0xc0644e03; + } +} // // sys/netinet/in.h @@ -2863,10 +2904,15 @@ pub const pseudo_AF_HDRCMPLT: c_int = 35; pub const AF_IEEE80211: c_int = 37; pub const AF_UTUN: c_int = 38; pub const AF_VSOCK: c_int = 40; -pub const AF_SYS_CONTROL: c_int = 2; -pub const SYSPROTO_EVENT: c_int = 1; -pub const SYSPROTO_CONTROL: c_int = 2; +cfg_if! { + if #[cfg(target_os = "macos")] { + // sys/sys_domain.h + pub const AF_SYS_CONTROL: c_int = 2; + pub const SYSPROTO_EVENT: c_int = 1; + pub const SYSPROTO_CONTROL: c_int = 2; + } +} pub const PF_UNSPEC: c_int = AF_UNSPEC; pub const PF_LOCAL: c_int = AF_LOCAL; @@ -3698,84 +3744,95 @@ pub const XATTR_SHOWCOMPRESSION: c_int = 0x0020; pub const NET_RT_IFLIST2: c_int = 0x0006; -// net/route.h -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_NOIFREF: c_int = 0x2000; -pub const RTF_PRCLONING: c_int = 0x10000; -pub const RTF_WASCLONED: c_int = 0x20000; -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 RTF_IFSCOPE: c_int = 0x1000000; -pub const RTF_CONDEMNED: c_int = 0x2000000; -pub const RTF_IFREF: c_int = 0x4000000; -pub const RTF_PROXY: c_int = 0x8000000; -pub const RTF_ROUTER: c_int = 0x10000000; -pub const RTF_DEAD: c_int = 0x20000000; -pub const RTF_GLOBAL: c_int = 0x40000000; - -pub const RTM_VERSION: c_int = 5; - -// Message types -pub const RTM_LOCK: c_int = 0x8; -pub const RTM_OLDADD: c_int = 0x9; -pub const RTM_OLDDEL: c_int = 0xa; -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_IFINFO2: c_int = 0x12; -pub const RTM_NEWMADDR2: c_int = 0x13; -pub const RTM_GET2: c_int = 0x14; - -// Bitmask values for rtm_inits and rmx_locks. -pub const RTV_MTU: c_int = 0x1; -pub const RTV_HOPCOUNT: c_int = 0x2; -pub const RTV_EXPIRE: c_int = 0x4; -pub const RTV_RPIPE: c_int = 0x8; -pub const RTV_SPIPE: c_int = 0x10; -pub const RTV_SSTHRESH: c_int = 0x20; -pub const RTV_RTT: c_int = 0x40; -pub const RTV_RTTVAR: c_int = 0x80; - -/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) -/// for details. -pub const RTAX_MAX: c_int = 8; +cfg_if! { + if #[cfg(target_os = "macos")] { + // net/route.h + 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_NOIFREF: c_int = 0x2000; + pub const RTF_PRCLONING: c_int = 0x10000; + pub const RTF_WASCLONED: c_int = 0x20000; + 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 RTF_IFSCOPE: c_int = 0x1000000; + pub const RTF_CONDEMNED: c_int = 0x2000000; + pub const RTF_IFREF: c_int = 0x4000000; + pub const RTF_PROXY: c_int = 0x8000000; + pub const RTF_ROUTER: c_int = 0x10000000; + pub const RTF_DEAD: c_int = 0x20000000; + pub const RTF_GLOBAL: c_int = 0x40000000; + + pub const RTM_VERSION: c_int = 5; + + // Message types + pub const RTM_LOCK: c_int = 0x8; + pub const RTM_OLDADD: c_int = 0x9; + pub const RTM_OLDDEL: c_int = 0xa; + 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_IFINFO2: c_int = 0x12; + pub const RTM_NEWMADDR2: c_int = 0x13; + pub const RTM_GET2: c_int = 0x14; + + // Bitmask values for rtm_inits and rmx_locks. + pub const RTV_MTU: c_int = 0x1; + pub const RTV_HOPCOUNT: c_int = 0x2; + pub const RTV_EXPIRE: c_int = 0x4; + pub const RTV_RPIPE: c_int = 0x8; + pub const RTV_SPIPE: c_int = 0x10; + pub const RTV_SSTHRESH: c_int = 0x20; + pub const RTV_RTT: c_int = 0x40; + pub const RTV_RTTVAR: c_int = 0x80; + + /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) + /// for details. + pub const RTAX_MAX: c_int = 8; + } +} pub const KERN_PROCARGS2: c_int = 49; -pub const PROC_PIDTASKALLINFO: c_int = 2; -pub const PROC_PIDTBSDINFO: c_int = 3; -pub const PROC_PIDTASKINFO: c_int = 4; -pub const PROC_PIDTHREADINFO: c_int = 5; -pub const PROC_PIDVNODEPATHINFO: c_int = 9; -pub const PROC_PIDT_SHORTBSDINFO: c_int = 13; -pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; - -pub const PROC_PIDLISTFDS: c_int = 1; -pub const PROC_PIDLISTFD_SIZE: c_int = size_of::() as c_int; -pub const PROX_FDTYPE_ATALK: c_int = 0; -pub const PROX_FDTYPE_VNODE: c_int = 1; -pub const PROX_FDTYPE_SOCKET: c_int = 2; -pub const PROX_FDTYPE_PSHM: c_int = 3; -pub const PROX_FDTYPE_PSEM: c_int = 4; -pub const PROX_FDTYPE_KQUEUE: c_int = 5; -pub const PROX_FDTYPE_PIPE: c_int = 6; -pub const PROX_FDTYPE_FSEVENTS: c_int = 7; -pub const PROX_FDTYPE_NETPOLICY: c_int = 9; -pub const PROX_FDTYPE_CHANNEL: c_int = 10; -pub const PROX_FDTYPE_NEXUS: c_int = 11; - -pub const PROC_CSM_ALL: c_uint = 0x0001; -pub const PROC_CSM_NOSMT: c_uint = 0x0002; -pub const PROC_CSM_TECS: c_uint = 0x0004; +cfg_if! { + if #[cfg(target_os = "macos")] { + // sys/proc_info.h + pub const PROC_PIDTASKALLINFO: c_int = 2; + pub const PROC_PIDTBSDINFO: c_int = 3; + pub const PROC_PIDTASKINFO: c_int = 4; + pub const PROC_PIDTHREADINFO: c_int = 5; + pub const PROC_PIDVNODEPATHINFO: c_int = 9; + pub const PROC_PIDT_SHORTBSDINFO: c_int = 13; + pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; + + pub const PROC_PIDLISTFDS: c_int = 1; + pub const PROC_PIDLISTFD_SIZE: c_int = size_of::() as c_int; + pub const PROX_FDTYPE_ATALK: c_int = 0; + pub const PROX_FDTYPE_VNODE: c_int = 1; + pub const PROX_FDTYPE_SOCKET: c_int = 2; + pub const PROX_FDTYPE_PSHM: c_int = 3; + pub const PROX_FDTYPE_PSEM: c_int = 4; + pub const PROX_FDTYPE_KQUEUE: c_int = 5; + pub const PROX_FDTYPE_PIPE: c_int = 6; + pub const PROX_FDTYPE_FSEVENTS: c_int = 7; + pub const PROX_FDTYPE_NETPOLICY: c_int = 9; + pub const PROX_FDTYPE_CHANNEL: c_int = 10; + pub const PROX_FDTYPE_NEXUS: c_int = 11; + + // libproc.h + pub const PROC_CSM_ALL: c_uint = 0x0001; + pub const PROC_CSM_NOSMT: c_uint = 0x0002; + pub const PROC_CSM_TECS: c_uint = 0x0004; + } +} + pub const MAXCOMLEN: usize = 16; pub const MAXTHREADNAMESIZE: usize = 64; @@ -3787,9 +3844,13 @@ pub const LC_SEGMENT_64: u32 = 0x19; pub const MH_MAGIC: u32 = 0xfeedface; pub const MH_MAGIC_64: u32 = 0xfeedfacf; -// net/if_utun.h -pub const UTUN_OPT_FLAGS: c_int = 1; -pub const UTUN_OPT_IFNAME: c_int = 2; +cfg_if! { + if #[cfg(target_os = "macos")] { + // net/if_utun.h + pub const UTUN_OPT_FLAGS: c_int = 1; + pub const UTUN_OPT_IFNAME: c_int = 2; + } +} // sys/mount.h pub const MNT_NODEV: c_int = 0x00000010; @@ -4312,34 +4373,38 @@ pub const MACH_TASK_BASIC_INFO_COUNT: u32 = pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = (size_of::() / size_of::()) as mach_msg_type_number_t; -// bsd/net/if_mib.h -/// Non-interface-specific -pub const IFMIB_SYSTEM: c_int = 1; -/// Per-interface data table -pub const IFMIB_IFDATA: c_int = 2; -/// All interfaces data at once -pub const IFMIB_IFALLDATA: c_int = 3; - -/// Generic stats for all kinds of ifaces -pub const IFDATA_GENERAL: c_int = 1; -/// Specific to the type of interface -pub const IFDATA_LINKSPECIFIC: c_int = 2; -/// Addresses assigned to interface -pub const IFDATA_ADDRS: c_int = 3; -/// Multicast addresses assigned to interface -pub const IFDATA_MULTIADDRS: c_int = 4; - -/// Number of interfaces configured -pub const IFMIB_IFCOUNT: c_int = 1; - -/// Functions not specific to a type of iface -pub const NETLINK_GENERIC: c_int = 0; - -pub const DOT3COMPLIANCE_STATS: c_int = 1; -pub const DOT3COMPLIANCE_COLLS: c_int = 2; - -// kern_control.h -pub const MAX_KCTL_NAME: usize = 96; +cfg_if! { + if #[cfg(target_os = "macos")] { + // bsd/net/if_mib.h + /// Non-interface-specific + pub const IFMIB_SYSTEM: c_int = 1; + /// Per-interface data table + pub const IFMIB_IFDATA: c_int = 2; + /// All interfaces data at once + pub const IFMIB_IFALLDATA: c_int = 3; + + /// Generic stats for all kinds of ifaces + pub const IFDATA_GENERAL: c_int = 1; + /// Specific to the type of interface + pub const IFDATA_LINKSPECIFIC: c_int = 2; + /// Addresses assigned to interface + pub const IFDATA_ADDRS: c_int = 3; + /// Multicast addresses assigned to interface + pub const IFDATA_MULTIADDRS: c_int = 4; + + /// Number of interfaces configured + pub const IFMIB_IFCOUNT: c_int = 1; + + /// Functions not specific to a type of iface + pub const NETLINK_GENERIC: c_int = 0; + + pub const DOT3COMPLIANCE_STATS: c_int = 1; + pub const DOT3COMPLIANCE_COLLS: c_int = 2; + + // kern_control.h + pub const MAX_KCTL_NAME: usize = 96; + } +} f! { pub unsafe fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { @@ -4548,7 +4613,9 @@ extern "C" { pub fn pthread_main_np() -> c_int; pub fn pthread_threadid_np(thread: crate::pthread_t, thread_id: *mut u64) -> c_int; + #[cfg(target_os = "macos")] pub fn pthread_jit_write_protect_np(enabled: c_int); + #[cfg(target_os = "macos")] pub fn pthread_jit_write_protect_supported_np() -> c_int; // An array of pthread_jit_write_with_callback_np must declare // the list of callbacks e.g. @@ -4556,10 +4623,12 @@ extern "C" { // static callbacks: [libc::pthread_jit_write_callback_t; 2] = [native_jit_write_cb, // std::mem::transmute::(std::ptr::null())]; // (a handy PTHREAD_JIT_WRITE_CALLBACK_NP macro for other languages). + #[cfg(target_os = "macos")] pub fn pthread_jit_write_with_callback_np( callback: crate::pthread_jit_write_callback_t, ctx: *mut c_void, ) -> c_int; + #[cfg(target_os = "macos")] pub fn pthread_jit_write_freeze_callbacks_np(); pub fn pthread_cpu_number_np(cpu_number_out: *mut size_t) -> c_int; @@ -4678,6 +4747,7 @@ extern "C" { data: *mut c_void, ) -> c_int; pub fn fmount(src: *const c_char, fd: c_int, flags: c_int, data: *mut c_void) -> c_int; + #[cfg(target_os = "macos")] pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_char, data: c_int) -> c_int; pub fn quotactl(special: *const c_char, cmd: c_int, id: c_int, data: *mut c_char) -> c_int; pub fn sethostname(name: *const c_char, len: c_int) -> c_int; @@ -4786,7 +4856,11 @@ extern "C" { infop: *mut crate::siginfo_t, options: c_int, ) -> c_int; + // `brk` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn brk(addr: *const c_void) -> *mut c_void; + // `sbrk` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn sbrk(increment: c_int) -> *mut c_void; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] @@ -4984,52 +5058,10 @@ extern "C" { ) -> *mut c_void; pub fn malloc_zone_free(zone: *mut crate::malloc_zone_t, ptr: *mut c_void); - pub fn proc_listpids(t: u32, typeinfo: u32, buffer: *mut c_void, buffersize: c_int) -> c_int; - pub fn proc_listallpids(buffer: *mut c_void, buffersize: c_int) -> c_int; - pub fn proc_listpgrppids(pgrpid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) - -> c_int; - pub fn proc_listchildpids(ppid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) -> c_int; - pub fn proc_pidinfo( - pid: c_int, - flavor: c_int, - arg: u64, - buffer: *mut c_void, - buffersize: c_int, - ) -> c_int; - pub fn proc_pidfdinfo( - pid: c_int, - fd: c_int, - flavor: c_int, - buffer: *mut c_void, - buffersize: c_int, - ) -> c_int; - pub fn proc_pidfileportinfo( - pid: c_int, - fileport: u32, - flavor: c_int, - buffer: *mut c_void, - buffersize: c_int, - ) -> c_int; - pub fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; - pub fn proc_name(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; - pub fn proc_regionfilename( - pid: c_int, - address: u64, - buffer: *mut c_void, - buffersize: u32, - ) -> c_int; - pub fn proc_kmsgbuf(buffer: *mut c_void, buffersize: u32) -> c_int; - pub fn proc_libversion(major: *mut c_int, minor: *mut c_int) -> c_int; - pub fn proc_pid_rusage(pid: c_int, flavor: c_int, buffer: *mut rusage_info_t) -> c_int; - - // Available from Big Sur - pub fn proc_set_no_smt() -> c_int; - pub fn proc_setthread_no_smt() -> c_int; - pub fn proc_set_csm(flags: u32) -> c_int; - pub fn proc_setthread_csm(flags: u32) -> c_int; /// # Notes /// /// `id` is of type [`uuid_t`]. + #[cfg(target_os = "macos")] pub fn gethostuuid(id: *mut u8, timeout: *const crate::timespec) -> c_int; pub fn gethostid() -> c_long; @@ -5222,9 +5254,66 @@ cfg_if! { if #[cfg(target_os = "macos")] { extern "C" { pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + + // libproc.h + pub fn proc_listpids( + t: u32, + typeinfo: u32, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_listallpids(buffer: *mut c_void, buffersize: c_int) -> c_int; + pub fn proc_listpgrppids( + pgrpid: crate::pid_t, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_listchildpids( + ppid: crate::pid_t, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidinfo( + pid: c_int, + flavor: c_int, + arg: u64, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidfdinfo( + pid: c_int, + fd: c_int, + flavor: c_int, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidfileportinfo( + pid: c_int, + fileport: u32, + flavor: c_int, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_name(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_regionfilename( + pid: c_int, + address: u64, + buffer: *mut c_void, + buffersize: u32, + ) -> c_int; + pub fn proc_kmsgbuf(buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_libversion(major: *mut c_int, minor: *mut c_int) -> c_int; + pub fn proc_pid_rusage(pid: c_int, flavor: c_int, buffer: *mut rusage_info_t) -> c_int; + // Available from Big Sur + pub fn proc_set_no_smt() -> c_int; + pub fn proc_setthread_no_smt() -> c_int; + pub fn proc_set_csm(flags: u32) -> c_int; + pub fn proc_setthread_csm(flags: u32) -> c_int; } } } + cfg_if! { if #[cfg(target_vendor = "apple")] { extern "C" { @@ -5234,6 +5323,8 @@ cfg_if! { needle: *const c_void, needlelen: size_t, ) -> *mut c_void; + // `task_set_info` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn task_set_info( target_task: crate::task_t, flavor: crate::task_flavor_t, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 30178694005a8..426d8df45e7f9 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -383,8 +383,14 @@ pub const POLLRDBAND: c_short = 0x080; pub const POLLWRBAND: c_short = 0x100; cfg_if! { - // Not yet implemented on NetBSD - if #[cfg(not(any(target_os = "netbsd")))] { + // Not yet implemented on NetBSD, and not present on iOS/tvOS/watchOS/visionOS. + if #[cfg(not(any( + target_os = "netbsd", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )))] { pub const BIOCGBLEN: c_ulong = 0x40044266; pub const BIOCSBLEN: c_ulong = 0xc0044266; pub const BIOCFLUSH: c_uint = 0x20004268; @@ -397,10 +403,13 @@ cfg_if! { pub const BIOCVERSION: c_ulong = 0x40044271; pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; - pub const SIOCGIFADDR: c_ulong = 0xc0206921; } } +// Not yet implemented on NetBSD. +#[cfg(not(target_os = "netbsd"))] +pub const SIOCGIFADDR: c_ulong = 0xc0206921; + cfg_if! { // Redefined in `new/apple` if #[cfg(not(target_vendor = "apple"))] { @@ -417,48 +426,58 @@ 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; +cfg_if! { + // Not present on iOS/tvOS/watchOS/visionOS + if #[cfg(not(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )))] { + // 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 unsafe fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { @@ -547,7 +566,6 @@ extern "C" { pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; pub fn kqueue() -> c_int; pub fn unmount(target: *const c_char, arg: c_int) -> c_int; - pub fn syscall(num: c_int, ...) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")] pub fn getpwent() -> *mut passwd; pub fn setpwent(); @@ -679,6 +697,8 @@ extern "C" { link_name = "sigaltstack$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + // `sigaltstack` is prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")] pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; @@ -839,6 +859,16 @@ extern "C" { pub fn issetugid() -> c_int; } +cfg_if! { + // `syscall` is prohibited on tvOS and watchOS (and strongly discouraged + // on iOS and macOS). + if #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] { + extern "C" { + pub fn syscall(num: c_int, ...) -> c_int; + } + } +} + cfg_if! { if #[cfg(target_vendor = "apple")] { mod apple; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 3a34d68d6be9f..7ffec383934d0 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -355,13 +355,23 @@ pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], }; -pub const ARPOP_REQUEST: u16 = 1; -pub const ARPOP_REPLY: u16 = 2; +cfg_if! { + // Not present on iOS/tvOS/watchOS/visionOS + if #[cfg(not(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )))] { + pub const ARPOP_REQUEST: u16 = 1; + pub const ARPOP_REPLY: u16 = 2; -pub const ATF_COM: c_int = 0x02; -pub const ATF_PERM: c_int = 0x04; -pub const ATF_PUBL: c_int = 0x08; -pub const ATF_USETRAILERS: c_int = 0x10; + pub const ATF_COM: c_int = 0x02; + pub const ATF_PERM: c_int = 0x04; + pub const ATF_PUBL: c_int = 0x08; + pub const ATF_USETRAILERS: c_int = 0x10; + } +} cfg_if! { if #[cfg(any(target_os = "nto", target_os = "qnx", target_os = "aix"))] { From 304d2fc31c39b5383dfed90e0153b55f07016e8c Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Aug 2026 20:49:28 +0200 Subject: [PATCH 37/88] Make system as unavailable on iOS/tvOS/watchOS/visionOS (backport ) (cherry picked from commit 7f866765fce6b8c9e8d41d51d1996d823fa1036e) --- libc-test/semver/cygwin.txt | 1 + libc-test/semver/dragonfly.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/fuchsia.txt | 1 + libc-test/semver/illumos.txt | 1 + libc-test/semver/linux.txt | 1 + libc-test/semver/macos.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + libc-test/semver/redox.txt | 1 + libc-test/semver/solarish.txt | 1 + libc-test/semver/unix.txt | 1 - src/unix/mod.rs | 7 +++++++ 13 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index a978f7312d9c3..76f0971d3b446 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -859,6 +859,7 @@ strncasecmp_l strptime strsep sync +system telldir timer_create timer_delete diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 8cabbf2b63499..0b3cd27f94cbd 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1685,6 +1685,7 @@ syscall sysctl sysctlbyname sysctlnametomib +system telldir timex truncate diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 51a04be7c7d31..872dabd47103b 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2460,6 +2460,7 @@ syscall sysctl sysctlbyname sysctlnametomib +system tcp_fastopen tcp_function_set tcp_info diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index 88bd6db31a7e0..d96908c8ae23a 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1466,6 +1466,7 @@ sync sync_file_range syscall sysinfo +system tee telldir termios2 diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index f66ee1d873226..38a9e92b723f5 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -30,6 +30,7 @@ pthread_attr_getstackaddr pthread_attr_setstack ptsname_r syncfs +system timerfd_create timerfd_gettime timerfd_settime diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 07ab97d980527..4414b1a9cab78 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -4553,6 +4553,7 @@ sync_file_range syncfs syscall sysinfo +system tee telldir timer_create diff --git a/libc-test/semver/macos.txt b/libc-test/semver/macos.txt index 75785a3cb7491..ce5a8003cba84 100644 --- a/libc-test/semver/macos.txt +++ b/libc-test/semver/macos.txt @@ -213,4 +213,5 @@ sigaltstack sockaddr_ctl sockaddr_inarp syscall +system task_set_info diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index b5e8664cbb1ed..da0cb7b2ed6c5 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1622,6 +1622,7 @@ sysctl sysctlbyname sysctldesc sysctlnametomib +system tcp_info telldir timer_create diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 859457ea63cd0..0c8b127913a8c 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1406,6 +1406,7 @@ strtonum sync syscall sysctl +system tcp_info telldir tmpfs_args diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index ef9caaed63e42..77a43db3c0bbb 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -378,5 +378,6 @@ strlcpy strncasecmp strndup strsignal +system ttyname_r utimensat diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index fb596019d5370..6480c47df1625 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -81,3 +81,4 @@ sendmsg sigqueue strftime strftime_l +system diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 052c24178dfcc..cee0fdfc76035 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -845,7 +845,6 @@ symlink symlinkat sysconf syslog -system tcdrain tcflag_t tcflow diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 7ffec383934d0..4f1d948199a9e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -757,6 +757,13 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "system$UNIX2003" )] + // Not available on iOS/tvOS/watchOS/visionOS + #[cfg(not(any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + )))] pub fn system(s: *const c_char) -> c_int; pub fn getenv(s: *const c_char) -> *mut c_char; From 4a2b79b52858358b3b9f08eae98ff18bbf37e54c Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Aug 2026 22:17:15 +0200 Subject: [PATCH 38/88] Mark exec* and fork as unavailable on tvOS and watchOS (backport ) (cherry picked from commit 0f1943a4e395341ed4cbf5aaf71cc10c98545380) --- libc-test/semver/apple.txt | 1 - libc-test/semver/cygwin.txt | 7 +++++++ libc-test/semver/dragonfly.txt | 7 +++++++ libc-test/semver/freebsd.txt | 7 +++++++ libc-test/semver/fuchsia.txt | 7 +++++++ libc-test/semver/hermit.txt | 9 ++++++++- libc-test/semver/illumos.txt | 7 +++++++ libc-test/semver/ios.txt | 8 ++++++++ libc-test/semver/linux.txt | 7 +++++++ libc-test/semver/macos.txt | 8 ++++++++ libc-test/semver/netbsd.txt | 7 +++++++ libc-test/semver/openbsd.txt | 7 +++++++ libc-test/semver/redox.txt | 7 +++++++ libc-test/semver/solarish.txt | 7 +++++++ libc-test/semver/unix.txt | 7 ------- src/unix/bsd/apple/mod.rs | 3 +++ src/unix/mod.rs | 8 ++++++++ 17 files changed, 105 insertions(+), 9 deletions(-) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index e9936724984bb..009b0cd280438 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1929,7 +1929,6 @@ endgrent endpwent endservent endutxent -execvP faccessat fchdir fchflags diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index 76f0971d3b446..691271e61ac7b 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -653,6 +653,12 @@ eaccess endpwent erand48 euidaccess +execl +execle +execlp +execv +execve +execvp execvpe explicit_bzero faccessat @@ -666,6 +672,7 @@ ffsll fls flsl flsll +fork forkpty freelocale fstatfs diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 0b3cd27f94cbd..45e67dc8541e1 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1371,8 +1371,14 @@ eui64_aton eui64_hostton eui64_ntoa eui64_ntohost +execl +execle +execlp exect +execv execvP +execve +execvp exit_status explicit_bzero extattr_delete_file @@ -1385,6 +1391,7 @@ fdatasync fdopendir fexecve fmemopen +fork forkpty fparseln freeifaddrs diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 872dabd47103b..bfed64661a7c2 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1998,8 +1998,14 @@ eui64_ntoa eui64_ntohost eventfd_read eventfd_write +execl +execle +execlp exect +execv execvP +execve +execvp execvpe explicit_bzero extattr_delete_fd @@ -2034,6 +2040,7 @@ fls flsl flsll fmemopen +fork forkpty fparseln freeifaddrs diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index d96908c8ae23a..656ff4d6c0b13 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1276,6 +1276,12 @@ duplocale endpwent epoll_event eventfd +execl +execle +execlp +execv +execve +execvp execvpe faccessat fallocate @@ -1291,6 +1297,7 @@ ff_ramp_effect ff_replay ff_rumble_effect ff_trigger +fork fpos64_t freeifaddrs freelocale diff --git a/libc-test/semver/hermit.txt b/libc-test/semver/hermit.txt index 43ca11b6acf74..6212926d41003 100644 --- a/libc-test/semver/hermit.txt +++ b/libc-test/semver/hermit.txt @@ -185,7 +185,7 @@ IP_TTL MSG_PEEK O_APPEND O_CREAT -O_DIRECTORY +O_DIRECTORY O_EXCL O_NONBLOCK O_RDONLY @@ -246,6 +246,13 @@ S_IXUSR TCP_NODELAY addrinfo dirent64 +execl +execle +execlp +execv +execve +execvp +fork in6_addr in_addr iovec diff --git a/libc-test/semver/illumos.txt b/libc-test/semver/illumos.txt index 38a9e92b723f5..9a575222f29a3 100644 --- a/libc-test/semver/illumos.txt +++ b/libc-test/semver/illumos.txt @@ -22,6 +22,13 @@ TFD_NONBLOCK TFD_TIMER_ABSTIME TFD_TIMER_CANCEL_ON_SET _CS_PATH +execl +execle +execlp +execv +execve +execvp +fork posix_fadvise posix_fallocate posix_spawn_file_actions_addfchdir_np diff --git a/libc-test/semver/ios.txt b/libc-test/semver/ios.txt index b0677a99091da..ea09d96dccf56 100644 --- a/libc-test/semver/ios.txt +++ b/libc-test/semver/ios.txt @@ -3,6 +3,14 @@ __darwin_arm_neon_state64 __darwin_arm_thread_state64 brk exchangedata +execl +execle +execlp +execv +execvP +execve +execvp +fork sbrk sigaltstack syscall diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 4414b1a9cab78..98c291e24a84e 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -4099,6 +4099,12 @@ erand48 eventfd eventfd_read eventfd_write +execl +execle +execlp +execv +execve +execvp execvpe faccessat fallocate @@ -4129,6 +4135,7 @@ file_handle flistxattr fmemopen fopen64 +fork forkpty fpos64_t fread_unlocked diff --git a/libc-test/semver/macos.txt b/libc-test/semver/macos.txt index ce5a8003cba84..306366e964c96 100644 --- a/libc-test/semver/macos.txt +++ b/libc-test/semver/macos.txt @@ -175,6 +175,14 @@ brk clock_settime ctl_info exchangedata +execl +execle +execlp +execv +execvP +execve +execvp +fork gethostuuid icmp6_ifstat in6_addrlifetime diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index da0cb7b2ed6c5..c70af78952e06 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1298,6 +1298,12 @@ estrndup estrtoi estrtou evasprintf +execl +execle +execlp +execv +execve +execvp explicit_memset extattr_delete_fd extattr_delete_file @@ -1322,6 +1328,7 @@ fgetxattr flags_to_string flistxattr fmemopen +fork forkpty freeifaddrs freelocale diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 0c8b127913a8c..b4d9da0f6f3e9 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1158,6 +1158,12 @@ endgrent endpwent endservent erand48 +execl +execle +execlp +execv +execve +execvp execvpe explicit_bzero export_args @@ -1167,6 +1173,7 @@ fchflags fdatasync fdopendir fmemopen +fork forkpty freeifaddrs freelocale diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 77a43db3c0bbb..e305cb9a442c4 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -311,11 +311,18 @@ epoll_create1 epoll_ctl epoll_event epoll_wait +execl +execle +execlp +execv +execve +execvp explicit_bzero faccessat fchdir fdopendir fmemopen +fork getdtablesize getgrent getgrgid diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index 6480c47df1625..86af2ec6a4c94 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -46,6 +46,13 @@ aio_waitn aio_write aiocb bind +execl +execle +execlp +execv +execve +execvp +fork in6_pktinfo in_pktinfo lio_listio diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index cee0fdfc76035..07b6a9cd61c40 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -505,12 +505,6 @@ dlopen dlsym dup dup2 -execl -execle -execlp -execv -execve -execvp exit fchmod fchmodat @@ -530,7 +524,6 @@ fileno flock fnmatch fopen -fork fpathconf fpos_t fprintf diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index f9eee3c66855b..c1589f2257b4d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5228,6 +5228,9 @@ extern "C" { pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int; + + // exec* marked as prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execvP( file: *const c_char, search_path: *const c_char, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 4f1d948199a9e..e0f2de84f2357 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1125,19 +1125,27 @@ extern "C" { pub fn dup(fd: c_int) -> c_int; pub fn dup2(src: c_int, dst: c_int) -> c_int; + // exec* marked as prohibited on tvOS and watchOS. + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int; // DIFF(main): changed to `*const *mut` in e77f551de9 + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execv(prog: *const c_char, argv: *const *const c_char) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execve( prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char, ) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn fork() -> pid_t; pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; From dc34cb0013b1bfe07fd3e0522b857cbf9bccc6f9 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Aug 2026 21:33:32 +0200 Subject: [PATCH 39/88] Fix iOS, tvOS, watchOS and visionOS tests (backport ) (cherry picked from commit f3b2c50d6a974e1e22a542a11356652083b91dec) --- ci/run.sh | 3 ++ libc-test/build/main.rs | 81 ++++++++++++++++++++++++--------------- libc-test/build/target.rs | 20 ++++++++++ libc-test/tests/style.rs | 9 +++++ 4 files changed, 82 insertions(+), 31 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 6668b821c0a19..61b7e30fd2e9b 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -26,6 +26,9 @@ case "$target" in # FIXME(android): unit tests fail to start on Android *android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; *s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; + # ctest's own tests don't work on Apple devices, since these don't have + # host tooling such as `rustc` or a C compiler. + *ios*|*tvos*|*watchos*|*visionos*) cmd="$cmd --workspace --exclude ctest" ;; # For all other platforms, test everything in the workspace *) cmd="$cmd --workspace" ;; esac diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index d179566ceb3a9..ce266e615099c 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -137,7 +137,10 @@ fn test_apple(t: &Target) { assert!(t.apple()); let x86_64 = t.x86_64(); let x86_32 = t.x86_32(); - let macos = VERSIONS.macos; + let macos = t.macos(); + let tvos = t.tvos(); + let watchos = t.watchos(); + let apple = VERSIONS.apple; let mut cfg = ctest_cfg(); @@ -165,7 +168,7 @@ fn test_apple(t: &Target) { "ifaddrs.h", "langinfo.h", "libgen.h", - "libproc.h", + (macos, "libproc.h"), "limits.h", "locale.h", "mach-o/dyld.h", @@ -177,23 +180,24 @@ fn test_apple(t: &Target) { "mach/thread_act.h", "mach/thread_policy.h", "malloc/malloc.h", - "net/bpf.h", - "net/dlil.h", + (macos, "net/bpf.h"), + (macos, "net/dlil.h"), "net/if.h", - "net/if_arp.h", + (macos, "net/if_arp.h"), "net/if_dl.h", - "net/if_mib.h", - "net/if_utun.h", + (macos, "net/if_mib.h"), + (macos, "net/if_utun.h"), "net/if_var.h", - "net/ndrv.h", - "net/route.h", + (macos, "net/ndrv.h"), + (macos, "net/route.h"), "netdb.h", - "netinet/if_ether.h", + (macos, "netinet/if_ether.h"), "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", - "netinet6/in6_var.h", + "netinet6/scope6_var.h", + (macos, "netinet6/in6_var.h"), "os/clock.h", "os/lock.h", "os/signpost.h", @@ -224,13 +228,13 @@ fn test_apple(t: &Target) { "sys/file.h", "sys/ioctl.h", "sys/ipc.h", - "sys/kern_control.h", + (macos, "sys/kern_control.h"), "sys/mman.h", "sys/mount.h", - "sys/proc_info.h", - "sys/ptrace.h", + (macos, "sys/proc_info.h"), + (macos, "sys/ptrace.h"), "sys/quota.h", - "sys/random.h", + (macos, "sys/random.h"), "sys/resource.h", "sys/sem.h", "sys/shm.h", @@ -238,7 +242,7 @@ fn test_apple(t: &Target) { "sys/sockio.h", "sys/stat.h", "sys/statvfs.h", - "sys/sys_domain.h", + (macos, "sys/sys_domain.h"), "sys/sysctl.h", "sys/time.h", "sys/times.h", @@ -259,7 +263,7 @@ fn test_apple(t: &Target) { "utmpx.h", "wchar.h", "xlocale.h", - (x86_64, "crt_externs.h"), + "crt_externs.h", ); cfg.skip_struct(move |s| { @@ -295,11 +299,11 @@ fn test_apple(t: &Target) { // https://github.com/apple-oss-distributions/xnu/commit/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea "ELAST" => true, - // FIXME(macos): bumped up on macOS 27, it's sizeof `vm_statistics64_data_t` - "HOST_VM_INFO64_COUNT" => macos.unwrap() < (27, 0), + // FIXME(macos): bumped up on macOS/iOS/... 27, it's sizeof `vm_statistics64_data_t` + "HOST_VM_INFO64_COUNT" => apple.unwrap() < (27, 0), - // FIXME(macos): bumped up on macOS 27, from 16 to 32 - "AIO_LISTIO_MAX" => macos.unwrap() < (27, 0), + // FIXME(macos): bumped up on macOS/iOS/... 27, from 16 to 32 + "AIO_LISTIO_MAX" => apple.unwrap() < (27, 0), _ => false, } @@ -307,8 +311,8 @@ fn test_apple(t: &Target) { cfg.skip_alias(move |ty| { match ty.ident() { - // FIXME(macos): The size is changed in macOS 27. - "vm_statistics64_data_t" => macos.unwrap() < (27, 0), + // FIXME(macos): The size is changed in macOS/iOS/... 27. + "vm_statistics64_data_t" => apple.unwrap() < (27, 0), _ => false, } }); @@ -322,6 +326,10 @@ fn test_apple(t: &Target) { "close" if x86_64 => true, // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, + // https://github.com/rust-lang/libc/issues/5409 + "getentropy" => !macos, + // https://github.com/rust-lang/libc/issues/5410 + ident if ident.starts_with("posix_spawn") => tvos || watchos, _ => false, } }); @@ -6453,7 +6461,7 @@ struct Versions { freebsd: Option<(u32, u32)>, openbsd: Option<(u32, u32)>, netbsd: Option<(u32, u32)>, - macos: Option<(u32, u32)>, + apple: Option<(u32, u32)>, emscripten: Option<(u32, u32)>, wasi_sdk: Option<(u32, WasiVersion)>, /// Android API level (no minor version). @@ -6495,16 +6503,19 @@ impl Versions { #if defined(__FreeBSD__) \ || defined(__NetBSD__) \ - || defined(__OpenBSD__) \ - || defined(__APPLE__) + || defined(__OpenBSD__) /* FreeBSD: __FreeBSD_version (MMmmRxx string, e.g. 1600018) * NetBSD: __NetBSD_Version__ (MMmmrrpp00 string, e.g. 1001000000) * OpenBSD: OpenBSD (release date, e.g. 202510) and OpenBSDM_m (e.g. OpenBSD7_8) - * Apple: __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_M_m (e.g. __MAC_26_5) */ #include "sys/param.h" #endif + #if defined(__APPLE__) + /* Apple: __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_M_m (e.g. __MAC_26_5) */ + #include "Availability.h" + #endif + #ifdef __EMSCRIPTEN__ /* Provides __EMSCRIPTEN_MAJOR__, __EMSCRIPTEN_MINOR__ */ #include "emscripten/version.h" @@ -6544,7 +6555,7 @@ impl Versions { // Allow spaces everywhere so we match things like `\n # define foo bar \n`. let re = Regex::new(r"^\s*#\s*define\s+(\w+)\s+(.*?)\s*$").unwrap(); let obsd_re = Regex::new(r"^OpenBSD(\d+)_(\d+)$").unwrap(); - let mac_re = Regex::new(r"^__MAC_(\d+)_(\d+)").unwrap(); + let apple_re = Regex::new(r"^__[A-Z]*_(\d+)_(\d+)").unwrap(); for line in out.lines() { let Some(caps) = re.captures(line) else { @@ -6567,11 +6578,19 @@ impl Versions { // the other version macros above and let a missing value fail loudly at // the unwrap in `test_android` rather than silently skipping tests. "__ANDROID_MIN_SDK_VERSION__" => ret.android = Some(value.parse().unwrap()), - "__MAC_OS_X_VERSION_MAX_ALLOWED" => { - let caps = mac_re.captures(value).unwrap(); + "__MAC_OS_X_VERSION_MAX_ALLOWED" + | "__IPHONE_OS_VERSION_MAX_ALLOWED" + | "__WATCH_OS_VERSION_MAX_ALLOWED" + | "__TV_OS_VERSION_MAX_ALLOWED" + | "__VISION_OS_VERSION_MAX_ALLOWED" => { + let caps = apple_re.captures(value).unwrap(); let major: u32 = caps[1].parse().unwrap(); let minor: u32 = caps[2].parse().unwrap(); - ret.macos = Some((major, minor)); + // Override any previous value. + // + // (`__IPHONE_OS_VERSION_MAX_ALLOWED` is defined first, + // and is set on watchOS, tvOS and visionOS too). + ret.apple = Some((major, minor)); } "__FreeBSD_version" => { // Format: MmmRxx where M is major (possibly multi-digit), mm is minor, R diff --git a/libc-test/build/target.rs b/libc-test/build/target.rs index 2d80e30d79a9d..e1fd3b1fe0e86 100644 --- a/libc-test/build/target.rs +++ b/libc-test/build/target.rs @@ -298,6 +298,26 @@ impl Target { self.os == "windows" } + pub fn macos(&self) -> bool { + self.os == "macos" + } + + pub fn ios(&self) -> bool { + self.os == "ios" + } + + pub fn tvos(&self) -> bool { + self.os == "tvos" + } + + pub fn watchos(&self) -> bool { + self.os == "watchos" + } + + pub fn visionos(&self) -> bool { + self.os == "visionos" + } + /* vendor */ pub fn apple(&self) -> bool { diff --git a/libc-test/tests/style.rs b/libc-test/tests/style.rs index 3cc70586d15e8..be734f2a1184a 100644 --- a/libc-test/tests/style.rs +++ b/libc-test/tests/style.rs @@ -29,6 +29,15 @@ const SKIP_PREFIXES: &[&str] = &[ ]; #[test] +#[cfg_attr( + any( + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + ), + ignore = "source code is not available for cross-compiled tests" +)] fn check_style() { let src_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src"); walk(&src_root).unwrap(); From 88542f1be29d7fbc599648acc567500f9b5c84fd Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 9 Jun 2026 13:36:55 +0200 Subject: [PATCH 40/88] Use cargo-apple-runner for testing iOS and tvOS (backport ) (cherry picked from commit c859fcc87e9a8fe9848d8b15989e578e1895d93e) --- .github/workflows/ci.yaml | 22 ++- ci/README.md | 4 +- ci/ios/deploy_and_run_on_ios_simulator.rs | 187 ---------------------- ci/run-apple-simulator.sh | 41 +++++ 4 files changed, 63 insertions(+), 191 deletions(-) delete mode 100644 ci/ios/deploy_and_run_on_ios_simulator.rs create mode 100755 ci/run-apple-simulator.sh diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cfbc588dd5b26..9faeffbbd0d70 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -243,6 +243,15 @@ jobs: # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu + + # Testing iOS and tvOS should give us reasonably good coverage for Apple platforms. + # (watchOS is similar to tvOS, and visionOS is similar to iOS). + - target: aarch64-apple-ios-sim + os: macos-26 + cargo-apple-runner: true + - target: aarch64-apple-tvos-sim + os: macos-26 + cargo-apple-runner: true runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }} timeout-minutes: 25 env: @@ -264,12 +273,21 @@ jobs: jq -r 'to_entries | map("\(.key)=\(.value|tostring)") | .[]' >>$GITHUB_ENV shell: bash + - name: Install `cargo-apple-runner` + if: matrix.cargo-apple-runner + uses: taiki-e/install-action@6c6fd71fe4fb72c3697d269963d0e15df8adedad # v2.85.10 + with: + tool: cargo-apple-runner + - name: Run natively - if: runner.os != 'Linux' + if: runner.os != 'Linux' && !matrix.cargo-apple-runner run: ./ci/run.sh ${{ matrix.target }} - name: Run in Docker - if: runner.os == 'Linux' + if: runner.os == 'Linux' && !matrix.cargo-apple-runner run: ./ci/run-docker.sh ${{ matrix.target }} + - name: Run on Apple's simulator + if: matrix.cargo-apple-runner + run: ./ci/run-apple-simulator.sh ${{ matrix.target }} - name: Create CI artifacts id: create_artifacts diff --git a/ci/README.md b/ci/README.md index 54017ccc0d6eb..9b1388bb9b3a0 100644 --- a/ci/README.md +++ b/ci/README.md @@ -41,13 +41,13 @@ The remaining architectures look like: the generated binary to actually verify the tests pass. * The MUSL build just has to download a MUSL compiler and target libraries and then otherwise runs tests normally. -* iOS builds need an extra linker flag currently, but beyond that they're built - as standard as everything else. +* iOS and tvOS is tested using [`cargo-apple-runner`][cargo-apple-runner]. * The BSD builds, currently OpenBSD and FreeBSD, use QEMU to boot up a system and compile/run tests. More information on that below. [Actions config]: https://github.com/rust-lang/libc/tree/HEAD/.github/workflows [android-docker]: https://github.com/rust-lang/libc/blob/HEAD/ci/docker/x86_64-linux-android/Dockerfile +[cargo-apple-runner]: https://github.com/madsmtm/cargo-apple-runner ## QEMU diff --git a/ci/ios/deploy_and_run_on_ios_simulator.rs b/ci/ios/deploy_and_run_on_ios_simulator.rs deleted file mode 100644 index 5c2d2fbad328d..0000000000000 --- a/ci/ios/deploy_and_run_on_ios_simulator.rs +++ /dev/null @@ -1,187 +0,0 @@ -// This is a script to deploy and execute a binary on an iOS simulator. -// The primary use of this is to be able to run unit tests on the simulator and -// retrieve the results. -// -// To do this through Cargo instead, use Dinghy -// (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy -// test. - -use std::fs::{ - self, - File, -}; -use std::io::Write; -use std::path::Path; -use std::process::Command; -use std::{ - env, - process, -}; - -macro_rules! t { - ($e:expr) => { - match $e { - Ok(e) => e, - Err(e) => panic!("{} failed with: {e}", stringify!($e)), - } - }; -} - -// Step one: Wrap as an app -fn package_as_simulator_app(crate_name: &str, test_binary_path: &Path) { - println!("Packaging simulator app"); - drop(fs::remove_dir_all("ios_simulator_app")); - t!(fs::create_dir("ios_simulator_app")); - t!(fs::copy( - test_binary_path, - Path::new("ios_simulator_app").join(crate_name) - )); - - let mut f = t!(File::create("ios_simulator_app/Info.plist")); - t!(f.write_all( - format!( - r#" - - - - - CFBundleExecutable - {} - CFBundleIdentifier - com.rust.unittests - - - "#, - crate_name - ) - .as_bytes() - )); -} - -// Step two: Start the iOS simulator -fn start_simulator() { - println!("Looking for iOS simulator"); - let output = t!(Command::new("xcrun").arg("simctl").arg("list").output()); - assert!(output.status.success()); - let mut simulator_exists = false; - let mut simulator_booted = false; - let mut found_rust_sim = false; - let stdout = t!(String::from_utf8(output.stdout)); - for line in stdout.lines() { - if line.contains("rust_ios") { - if found_rust_sim { - panic!( - "Duplicate rust_ios simulators found. Please \ - double-check xcrun simctl list." - ); - } - simulator_exists = true; - simulator_booted = line.contains("(Booted)"); - found_rust_sim = true; - } - } - - if simulator_exists == false { - println!("Creating iOS simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("create") - .arg("rust_ios") - .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") - .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") - .check_status(); - } else if simulator_booted == true { - println!("Shutting down already-booted simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("shutdown") - .arg("rust_ios") - .check_status(); - } - - println!("Starting iOS simulator"); - // We can't uninstall the app (if present) as that will hang if the - // simulator isn't completely booted; just erase the simulator instead. - Command::new("xcrun") - .arg("simctl") - .arg("erase") - .arg("rust_ios") - .check_status(); - Command::new("xcrun") - .arg("simctl") - .arg("boot") - .arg("rust_ios") - .check_status(); -} - -// Step three: Install the app -fn install_app_to_simulator() { - println!("Installing app to simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("install") - .arg("booted") - .arg("ios_simulator_app/") - .check_status(); -} - -// Step four: Run the app -fn run_app_on_simulator() { - println!("Running app"); - let output = t!(Command::new("xcrun") - .arg("simctl") - .arg("launch") - .arg("--console") - .arg("booted") - .arg("com.rust.unittests") - .output()); - - println!("status: {}", output.status); - println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout)); - println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr)); - - let stdout = String::from_utf8_lossy(&output.stdout); - let passed = stdout - .lines() - .find(|l| (l.contains("PASSED") && l.contains("tests")) || l.contains("test result: ok")) - .unwrap_or(false); - - println!("Shutting down simulator"); - Command::new("xcrun") - .arg("simctl") - .arg("shutdown") - .arg("rust_ios") - .check_status(); - if !passed { - panic!("tests didn't pass"); - } -} - -trait CheckStatus { - fn check_status(&mut self); -} - -impl CheckStatus for Command { - fn check_status(&mut self) { - println!("\trunning: {self:?}"); - assert!(t!(self.status()).success()); - } -} - -fn main() { - let args: Vec = env::args().collect(); - if args.len() != 2 { - println!("Usage: {} ", args[0]); - process::exit(-1); - } - - let test_binary_path = Path::new(&args[1]); - let crate_name = test_binary_path.file_name().unwrap(); - - package_as_simulator_app(crate_name.to_str().unwrap(), test_binary_path); - start_simulator(); - install_app_to_simulator(); - run_app_on_simulator(); -} diff --git a/ci/run-apple-simulator.sh b/ci/run-apple-simulator.sh new file mode 100755 index 0000000000000..1fcd3e7242c7f --- /dev/null +++ b/ci/run-apple-simulator.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Runs `run.sh` on a non-macOS Apple target. +# +# This requires `cargo-apple-runner`, which you can get with `cargo install cargo-apple-runner`. + +set -eux + +target="$1" + +# Find reasonable simulator device. +case "$target" in + *ios-sim) SIMULATOR_DEVICE="iPhone 17" ;; + *tvos-sim) SIMULATOR_DEVICE="Apple TV" ;; + *watchos-sim) SIMULATOR_DEVICE="Apple Watch SE 3 (40mm)" ;; + *visionos-sim) SIMULATOR_DEVICE="Apple Vision Pro" ;; + *) echo "Unknown simulator target: $target"; exit 1 ;; +esac + +# Start the simulator. +# If this fails, the user is likely already running a simulator, +# in that case we don't want to shut it down on exit. +if xcrun simctl boot "$SIMULATOR_DEVICE"; then + echo "Successfully booted simulator" + trap 'xcrun simctl shutdown "$SIMULATOR_DEVICE"' EXIT +else + echo "Didn't boot simulator; one is probably already running (?)" +fi + +# Set the Cargo runner to `cargo-apple-runner` for the simulator targets. +export CARGO_TARGET_AARCH64_APPLE_IOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_AARCH64_APPLE_TVOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_AARCH64_APPLE_WATCHOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_AARCH64_APPLE_VISIONOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=cargo-apple-runner +export CARGO_TARGET_X86_64_APPLE_WATCHOS_SIM_RUNNER=cargo-apple-runner +export CARGO_TARGET_X86_64_APPLE_TVOS_RUNNER=cargo-apple-runner +export CARGO_TARGET_I386_APPLE_IOS_RUNNER=cargo-apple-runner + +# Delegate to run.sh for the rest. +"$(dirname "$0")/run.sh" "$target" From 66ce579278b3bb55226492c35f71ba543ac1e3ce Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:24 +0200 Subject: [PATCH 41/88] aix(powerpc64): correct padding and reorganize Tweak padding fields in records where they were public or not using the dedicated `Padding` type. Simplify item paths to use module-level paths instead of crate-relative paths. Rename `pollfd_ext` into using the `typedef`fed identifier instead of the `struct` tag. Rename the anonymous union for `ld_info`'s `_file` field to fit the skipping pattern in the test suite. (backport ) (cherry picked from commit b83cd79baea50c00f8e89581c36134cac77feeb6) --- src/unix/aix/powerpc64.rs | 137 +++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index cd439044d196f..5009ba69aa80f 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -1,4 +1,3 @@ -use crate::off_t; use crate::prelude::*; // Define lock_data_instrumented as an empty enum @@ -21,8 +20,8 @@ s! { pub l_sysid: c_uint, pub l_pid: crate::pid_t, pub l_vfs: c_int, - pub l_start: off_t, - pub l_len: off_t, + pub l_start: crate::off_t, + pub l_len: crate::off_t, } pub struct statvfs { @@ -34,7 +33,7 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, + pub f_fsid: crate::fsid_t, pub f_basetype: [c_char; 16], pub f_flag: c_ulong, pub f_namemax: c_ulong, @@ -78,8 +77,8 @@ s! { pub st_type: c_uint, pub st_gen: c_uint, st_reserved: Padding<[c_uint; 9]>, - pub st_padto_ll: c_uint, - pub st_size: off_t, + st_padto_ll: Padding, + pub st_size: crate::off_t, } pub struct statfs { @@ -107,7 +106,7 @@ s! { pub aio_lio_opcode: c_int, pub aio_fildes: c_int, pub aio_word1: c_int, - pub aio_offset: off_t, + pub aio_offset: crate::off_t, pub aio_buf: *mut c_void, pub aio_return: ssize_t, pub aio_errno: c_int, @@ -126,11 +125,11 @@ s! { } pub struct __vmx_context_t { - pub __vr: [crate::__vmxreg_t; 32], - pub __pad1: [c_uint; 3], + pub __vr: [__vmxreg_t; 32], + __pad1: Padding<[c_uint; 3]>, pub __vscr: c_uint, pub __vrsave: c_uint, - pub __pad2: [c_uint; 3], + __pad2: Padding<[c_uint; 3]>, } pub struct __vsx_context_t { @@ -138,8 +137,8 @@ s! { } pub struct __tm_context_t { - pub vmx: crate::__vmx_context_t, - pub vsx: crate::__vsx_context_t, + pub vmx: __vmx_context_t, + pub vsx: __vsx_context_t, pub gpr: [c_ulonglong; 32], pub lr: c_ulonglong, pub ctr: c_ulonglong, @@ -158,7 +157,7 @@ s! { pub tmcontext: c_char, pub tmstate: c_char, pub prevowner: c_char, - pub pad: [c_char; 5], + pad: Padding<[c_char; 5]>, } pub struct __context64 { @@ -176,7 +175,7 @@ s! { pub fpeu: c_char, pub fpinfo: c_char, pub fpscr24_31: c_char, - pub pad: [c_char; 1], + pad: Padding<[c_char; 1]>, pub excp_type: c_int, } @@ -187,24 +186,24 @@ s! { pub struct __extctx_t { pub __flags: c_uint, pub __rsvd1: [c_uint; 3], - pub __vmx: crate::__vmx_context_t, + pub __vmx: __vmx_context_t, pub __ukeys: [c_uint; 2], - pub __vsx: crate::__vsx_context_t, - pub __tm: crate::__tm_context_t, + pub __vsx: __vsx_context_t, + pub __tm: __tm_context_t, __reserved: Padding<[c_char; 1860]>, pub __extctx_magic: c_int, } pub struct ucontext_t { - pub __sc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub __sc_uerror: c_int, - pub uc_mcontext: crate::mcontext_t, + __sc_onstack: c_int, + pub uc_sigmask: sigset_t, + __sc_uerror: c_int, + pub uc_mcontext: mcontext_t, pub uc_link: *mut ucontext_t, pub uc_stack: crate::stack_t, - pub __extctx: *mut crate::__extctx_t, - pub __extctx_magic: c_int, - pub __pad: [c_int; 1], + __extctx: *mut __extctx_t, + __extctx_magic: c_int, + __pad: Padding<[c_int; 1]>, } pub struct utmpx { @@ -215,17 +214,17 @@ s! { pub ut_type: c_short, pub ut_tv: crate::timeval, pub ut_host: [c_char; 256], - pub __dbl_word_pad: c_int, - pub __reservedA: [c_int; 2], - pub __reservedV: [c_int; 6], + __dbl_word_pad: Padding, + __reservedA: Padding<[c_int; 2]>, + __reservedV: Padding<[c_int; 6]>, } pub struct pthread_spinlock_t { - pub __sp_word: [c_long; 3], + __sp_word: [c_long; 3], } pub struct pthread_barrier_t { - pub __br_word: [c_long; 5], + __br_word: [c_long; 5], } pub struct msqid_ds { @@ -255,15 +254,37 @@ s! { pub si_addr: *mut c_void, pub si_band: c_long, pub si_value: crate::sigval, - pub __si_flags: c_int, - pub __pad: [c_int; 3], + __si_flags: c_int, + __pad: Padding<[c_int; 3]>, } - pub struct pollfd_ext { + pub struct pollfd_ext_t { pub fd: c_int, pub events: c_short, pub revents: c_short, - pub data: __pollfd_ext_u, + pub u: __c_anonymous_pollfd_ext_t_u, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status } } @@ -306,8 +327,8 @@ s_no_extra_traits! { pub f_type: c_short, // Should be pointer to 'vnode' pub f_data: *mut c_void, - pub f_offset: c_longlong, - pub f_dir_off: c_long, + pub f_offset: crate::offset_t, + pub f_dir_off: crate::off_t, // Should be pointer to 'cred' pub f_cred: *mut c_void, pub f_lock: _kernel_simple_lock, @@ -319,16 +340,10 @@ s_no_extra_traits! { pub f_fdata: [c_char; 160], } - pub union __ld_info_file { - pub _ldinfo_fd: c_int, - pub _ldinfo_fp: *mut file, - pub _core_offset: c_long, - } - pub struct ld_info { pub ldinfo_next: c_uint, pub ldinfo_flags: c_uint, - pub _file: __ld_info_file, + pub _file: __c_anonymous_ld_info__file, pub ldinfo_textorg: *mut c_void, pub ldinfo_textsize: c_ulong, pub ldinfo_dataorg: *mut c_void, @@ -336,7 +351,13 @@ s_no_extra_traits! { pub ldinfo_filename: [c_char; 2], } - pub union __pollfd_ext_u { + pub union __c_anonymous_ld_info__file { + pub _ldinfo_fd: c_int, + pub _ldinfo_fp: *mut file, + pub _core_offset: c_long, + } + + pub union __c_anonymous_pollfd_ext_t_u { pub addr: *mut c_void, pub data32: u32, pub data: u64, @@ -347,32 +368,10 @@ s_no_extra_traits! { } } -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - self.si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - self.si_value - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.si_status - } -} - cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __pollfd_ext_u { - fn eq(&self, other: &__pollfd_ext_u) -> bool { + impl PartialEq for __c_anonymous_pollfd_ext_t_u { + fn eq(&self, other: &__c_anonymous_pollfd_ext_t_u) -> bool { unsafe { self.addr == other.addr && self.data32 == other.data32 @@ -380,8 +379,8 @@ cfg_if! { } } } - impl Eq for __pollfd_ext_u {} - impl hash::Hash for __pollfd_ext_u { + impl Eq for __c_anonymous_pollfd_ext_t_u {} + impl hash::Hash for __c_anonymous_pollfd_ext_t_u { fn hash(&self, state: &mut H) { unsafe { self.addr.hash(state); From bfbe9da83ce298e8af9001b543a7fe5c3c076847 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:24 +0200 Subject: [PATCH 42/88] aix(powerpc64): deprecate `_kernel_simple_lock` Add deprecation attribute to `_kernel_simple_lock` and change uses of it to use the `_simple_lock` type. This type doesn't exist in AIX 7.3 header files. (backport ) (cherry picked from commit 38c878f3055b1ad586b3b31fbbc44be35f8bb4f7) --- src/unix/aix/powerpc64.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 5009ba69aa80f..177a01db61a83 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -5,6 +5,8 @@ extern_ty! { pub type lock_data_instrumented; } +pub type simple_lock_data = c_int; + s! { pub struct sigset_t { pub ss_set: [c_ulong; 4], @@ -289,6 +291,15 @@ impl siginfo_t { } s_no_extra_traits! { + pub union _simple_lock { + _slock: simple_lock_data, + _slockp: *mut lock_data_instrumented, + } + + #[deprecated( + since = "0.2.187", + note = "Use `_simple_lock` instead. This type doesn't exist upstream." + )] pub union _kernel_simple_lock { pub _slock: c_long, pub _slockp: *mut lock_data_instrumented, @@ -331,8 +342,8 @@ s_no_extra_traits! { pub f_dir_off: crate::off_t, // Should be pointer to 'cred' pub f_cred: *mut c_void, - pub f_lock: _kernel_simple_lock, - pub f_offset_lock: _kernel_simple_lock, + pub f_lock: _simple_lock, + pub f_offset_lock: _simple_lock, pub f_vinfo: crate::caddr_t, pub f_ops: *mut fileops_t, pub f_parentp: crate::caddr_t, From b4b610d3a2b2a812065d9e55f3eceb708d60156b Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Tue, 11 Aug 2026 08:14:04 +0200 Subject: [PATCH 43/88] aix(powerpc64): correct `fileops_t` field Change field of `fileops_t` using a function pointer to take one more parameter. AIX 7.3 headers under `sys/file.h` use an additional field. (backport ) (cherry picked from commit eb73414c4d216b34e6bb169f503e7018bc3742d8) --- src/unix/aix/powerpc64.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 177a01db61a83..5e3a448ef518d 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -325,7 +325,13 @@ s_no_extra_traits! { ) -> c_int, >, pub fo_select: Option< - extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int, + extern "C" fn( + file: *mut file, + a: c_int, + b: c_ushort, + c: *mut c_ushort, + c: extern "C" fn(), + ) -> c_int, >, pub fo_close: Option c_int>, pub fo_fstat: Option c_int>, From 3ad57fbde93eda14c288b10992da0bd1056e31a1 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Tue, 11 Aug 2026 08:20:57 +0200 Subject: [PATCH 44/88] aix(powerpc64): annotate `unsafe` fn ptrs Add `unsafe` annotations to function pointer fields of `fileops_t`. Make one non-`Option` function pointer passed as an argument to one of the above function pointer fields use an `Option`. This should slightly improve the chances of UB from null function pointers. (backport ) (cherry picked from commit 92a2616d7864c9f03e2b0f1b7b95a15fbb871eeb) --- src/unix/aix/powerpc64.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 5e3a448ef518d..e79852e7de9ee 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -307,30 +307,24 @@ s_no_extra_traits! { pub struct fileops_t { pub fo_rw: Option< - extern "C" fn( - file: *mut file, - rw: crate::uio_rw, - io: *mut c_void, - ext: c_long, - secattr: *mut c_void, + unsafe extern "C" fn( + *mut file, + crate::uio_rw, + *mut c_void, + c_long, + *mut c_void, ) -> c_int, >, pub fo_ioctl: Option< - extern "C" fn( - file: *mut file, - a: c_long, - b: crate::caddr_t, - c: c_long, - d: c_long, - ) -> c_int, + unsafe extern "C" fn(*mut file, c_long, crate::caddr_t, c_long, c_long) -> c_int, >, pub fo_select: Option< - extern "C" fn( - file: *mut file, - a: c_int, - b: c_ushort, - c: *mut c_ushort, - c: extern "C" fn(), + unsafe extern "C" fn( + *mut file, + c_int, + c_ushort, + *mut c_ushort, + Option, ) -> c_int, >, pub fo_close: Option c_int>, From 714ca5a9c0e72248c78735888a4c65a8f2473759 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 12 Aug 2026 14:02:22 +0200 Subject: [PATCH 45/88] aix(powerpc64): add align. req. to type `file` Add `repr(align = 256)` to type `file` to fit the upstream definition under `sys/file.h` in an AIX 7.3 machine. This is the version that has been checked against. (backport ) (cherry picked from commit 7ce8d44f9a9dbf1e09892674a02db7444a3fe729) --- src/unix/aix/powerpc64.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index e79852e7de9ee..2077c7ad71584 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -331,6 +331,7 @@ s_no_extra_traits! { pub fo_fstat: Option c_int>, } + #[repr(align(256))] pub struct file { pub f_flag: c_long, pub f_count: c_int, From 8b5e0ea52687d409ca56bf3edef4e9958797a815 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:04:24 +0200 Subject: [PATCH 46/88] aix(powerpc64): add system header comments (backport ) (cherry picked from commit df65648ed34ef002c16c19e11f8cc62dbab82324) --- src/unix/aix/powerpc64.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 2077c7ad71584..37f0d0f743cbe 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -417,6 +417,7 @@ cfg_if! { } } +// pthread.h pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __mt_word: [0, 2, 0, 0, 0, 0, 0, 0], }; @@ -426,11 +427,11 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], }; - pub const PTHREAD_ONCE_INIT: pthread_once_t = pthread_once_t { __on_word: [0, 0, 0, 0, 0, 2, 0, 0, 0], }; +// sys/resource.h pub const RLIM_INFINITY: c_ulong = 0x7fffffffffffffff; extern "C" { From 1b78bede369ebfb633551cdbc382e42a4de86b0f Mon Sep 17 00:00:00 2001 From: kay-lambdadelta Date: Sun, 16 Aug 2026 22:32:48 -0700 Subject: [PATCH 47/88] Correct open flags for modern NuttX Permalink for further reference: https://github.com/apache/nuttx/blob/273c77128b6698f0c95f0d7cde1d0bb803782021/include/fcntl.h#L47 (backport ) (cherry picked from commit fa0c8bde083ccda2d91ab6875ab7b1947f33e8fd) --- src/unix/nuttx/mod.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index b1100342b8bce..2380bba1ba40f 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -473,23 +473,23 @@ pub const F_GETFL: i32 = 0x2; pub const F_SETFD: i32 = 8; pub const F_SETFL: i32 = 9; // open flag settings for open() (and related APIs) -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_RDONLY: i32 = 0x0; +pub const O_WRONLY: i32 = 0x1; +pub const O_RDWR: i32 = 0x2; +pub const O_CREAT: i32 = 0x40; +pub const O_EXCL: i32 = 0x80; +pub const O_NOCTTY: i32 = 0x100; +pub const O_TRUNC: i32 = 0x200; +pub const O_APPEND: i32 = 0x400; +pub const O_NONBLOCK: i32 = 0x800; +pub const O_DSYNC: i32 = 0x1000; +pub const O_DIRECT: i32 = 0x4000; +pub const O_LARGEFILE: i32 = 0x8000; +pub const O_DIRECTORY: i32 = 0x10000; +pub const O_NOFOLLOW: i32 = 0x20000; pub const O_NOATIME: i32 = 0x40000; -pub const O_CLOEXEC: i32 = 0x400; -pub const O_ACCMODE: i32 = 0x0003; +pub const O_CLOEXEC: i32 = 0x80000; +pub const O_ACCMODE: i32 = 0x3; pub const AT_FDCWD: i32 = -100; pub const AT_REMOVEDIR: i32 = 0x200; From 1e73f7395eba4f947733af2ae6e292b71adb7190 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 18 Aug 2026 16:23:25 -0700 Subject: [PATCH 48/88] emscripten: Add epoll support Emscripten restored the `sys/epoll.h` header in 6.0.2 and implements `epoll_create`, `epoll_create1`, `epoll_ctl`, `epoll_wait` and `epoll_pwait` in the JS filesystem as of 6.0.8. Version detection in libc-test now also tracks the tiny version component so that point releases can be distinguished, and parses the uppercase `__EMSCRIPTEN_MAJOR__` macro forms used since Emscripten 5.0.1, where the lowercase names became non-integer aliases. Link: https://github.com/emscripten-core/emscripten/blob/4483d70a78098ed5d860dff2dc21f3025b2da2ee/system/lib/libc/musl/include/sys/epoll.h#L17 Link: https://github.com/emscripten-core/emscripten/blob/4483d70a78098ed5d860dff2dc21f3025b2da2ee/system/lib/libc/musl/include/sys/epoll.h#L70-L74 Link: https://github.com/emscripten-core/emscripten/pull/27206 Link: https://github.com/emscripten-core/emscripten/pull/27207 (backport ) (cherry picked from commit 04c162b47b352e19984e68a1bd1304e5e7b1c86a) --- libc-test/build/main.rs | 57 +++++++++++++++++++-------- libc-test/semver/emscripten.txt | 25 ++++++++++++ src/unix/linux_like/emscripten/mod.rs | 18 +++++++++ 3 files changed, 83 insertions(+), 17 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index ce266e615099c..ed6434346f636 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -3338,6 +3338,9 @@ fn test_emscripten(t: &Target) { "stdio.h", "stdlib.h", "string.h", + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + (emscripten >= (6, 0, 2), "sys/epoll.h"), "sys/file.h", "sys/ioctl.h", "sys/ipc.h", @@ -3413,11 +3416,11 @@ fn test_emscripten(t: &Target) { } }); - cfg.skip_union(|union_| { + cfg.skip_union(move |union_| { match union_.ident() { - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - ty if ty.starts_with("epoll") => true, + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + ty if ty.starts_with("epoll") => emscripten < (6, 0, 2), _ => false, } @@ -3444,9 +3447,9 @@ fn test_emscripten(t: &Target) { // Extern types "DIR" | "FILE" | "fpos_t" | "fpos64_t" | "timezone" => true, - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - ty if ty.starts_with("epoll") => true, + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + ty if ty.starts_with("epoll") => emscripten < (6, 0, 2), ty if ty.starts_with("signalfd") => true, _ => false, @@ -3460,7 +3463,15 @@ fn test_emscripten(t: &Target) { "execv" | "execve" | "execvp" | "execvpe" | "fexecve" | "wait4" => true, // Emscripten's `pthread_kill` used to only be linkable when building with `-pthread` - "pthread_kill" if emscripten < (6, 0) => true, + "pthread_kill" if emscripten < (6, 0, 0) => true, + + // epoll support was added in Emscripten 6.0.8 + // https://github.com/emscripten-core/emscripten/pull/27207 + "epoll_create" | "epoll_create1" | "epoll_ctl" | "epoll_wait" | "epoll_pwait" + if emscripten < (6, 0, 8) => + { + true + } _ => false, } @@ -3471,9 +3482,9 @@ fn test_emscripten(t: &Target) { // FIXME(emscripten): emscripten uses different constants to constructs these n if n.contains("__SIZEOF_PTHREAD") => true, - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - n if n.starts_with("EPOLL") => true, + // `sys/epoll.h` was restored in Emscripten 6.0.2 + // https://github.com/emscripten-core/emscripten/pull/27206 + n if n.starts_with("EPOLL") => emscripten < (6, 0, 2), // No ptrace.h // https://github.com/emscripten-core/emscripten/pull/17704 @@ -6462,7 +6473,7 @@ struct Versions { openbsd: Option<(u32, u32)>, netbsd: Option<(u32, u32)>, apple: Option<(u32, u32)>, - emscripten: Option<(u32, u32)>, + emscripten: Option<(u32, u32, u32)>, wasi_sdk: Option<(u32, WasiVersion)>, /// Android API level (no minor version). android: Option, @@ -6517,7 +6528,7 @@ impl Versions { #endif #ifdef __EMSCRIPTEN__ - /* Provides __EMSCRIPTEN_MAJOR__, __EMSCRIPTEN_MINOR__ */ + /* Provides __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__ */ #include "emscripten/version.h" #endif @@ -6612,11 +6623,23 @@ impl Versions { let minor: u32 = caps[2].parse().unwrap(); ret.openbsd = Some((major, minor)); } - "__EMSCRIPTEN_major__" => { - ret.emscripten.get_or_insert_default().0 = value.parse().unwrap() + // Versions before 5.0.1 define the lowercase names as integers; 5.0.1 and + // later define the uppercase names as integers and the lowercase names as + // non-integer aliases of them. + "__EMSCRIPTEN_major__" | "__EMSCRIPTEN_MAJOR__" => { + if let Ok(v) = value.parse() { + ret.emscripten.get_or_insert_default().0 = v; + } + } + "__EMSCRIPTEN_minor__" | "__EMSCRIPTEN_MINOR__" => { + if let Ok(v) = value.parse() { + ret.emscripten.get_or_insert_default().1 = v; + } } - "__EMSCRIPTEN_minor__" => { - ret.emscripten.get_or_insert_default().1 = value.parse().unwrap() + "__EMSCRIPTEN_tiny__" | "__EMSCRIPTEN_TINY__" => { + if let Ok(v) = value.parse() { + ret.emscripten.get_or_insert_default().2 = v; + } } "__wasi_sdk_major__" => { ret.wasi_sdk.get_or_insert_default().0 = value.parse().unwrap() diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 763addcdda6b4..879b096a39b14 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,5 +1,30 @@ AT_EACCESS +EPOLLERR +EPOLLET +EPOLLEXCLUSIVE +EPOLLHUP +EPOLLIN +EPOLLMSG +EPOLLONESHOT +EPOLLOUT +EPOLLPRI +EPOLLRDBAND +EPOLLRDHUP +EPOLLRDNORM +EPOLLWAKEUP +EPOLLWRBAND +EPOLLWRNORM +EPOLL_CLOEXEC +EPOLL_CTL_ADD +EPOLL_CTL_DEL +EPOLL_CTL_MOD SIGEV_THREAD_ID +epoll_create +epoll_create1 +epoll_ctl +epoll_event +epoll_pwait +epoll_wait getentropy getgrgid getgrgid_r diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 35f4bd87df698..3a2fddcf03b4a 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -807,6 +807,8 @@ pub const O_TRUNC: c_int = 512; pub const O_NOATIME: c_int = 0o1000000; pub const O_CLOEXEC: c_int = 0x80000; +pub const EPOLL_CLOEXEC: c_int = 0x80000; + // Defined as wasi value. pub const EPERM: c_int = 63; pub const ENOENT: c_int = 44; @@ -1477,6 +1479,22 @@ extern "C" { timeout: *const crate::timespec, ) -> c_int; pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn epoll_create(size: c_int) -> c_int; + pub fn epoll_create1(flags: c_int) -> c_int; + pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; + pub fn epoll_wait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + ) -> c_int; + pub fn epoll_pwait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + sigmask: *const crate::sigset_t, + ) -> c_int; } // Alias to 64 to mimic glibc's LFS64 support From ed6c701285d0f0ff997613504754b14a83e17566 Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Wed, 19 Aug 2026 16:31:03 +0200 Subject: [PATCH 49/88] linux/l4re: remove IPPROTO_MAX from shared file (backport ) (cherry picked from commit 1e84ea3d7bb6690731e191a174d2464bd3071830) --- src/unix/linux_like/l4re/uclibc/mod.rs | 2 ++ src/unix/linux_like/linux/mod.rs | 5 +++++ src/unix/linux_like/linux_l4re_shared.rs | 5 ----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index 06806d1051f0e..79cfa555903a5 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -410,6 +410,8 @@ pub const ENOTSUP: c_int = EOPNOTSUPP; pub const IPV6_JOIN_GROUP: c_int = 20; pub const IPV6_LEAVE_GROUP: c_int = 21; +pub const IPPROTO_MAX: c_int = 256; + // Different than Gnu. pub const FILENAME_MAX: c_uint = 4095; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 75f49b8babb04..f5bf60eb838d6 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1326,6 +1326,11 @@ pub const IPV6_FREEBIND: c_int = 78; pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x000fffff; pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0ff00000; +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +pub const IPPROTO_MAX: c_int = 263; + // SO_MEMINFO offsets pub const SK_MEMINFO_RMEM_ALLOC: c_int = 0; pub const SK_MEMINFO_RCVBUF: c_int = 1; diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index ae6f57c9c45a2..fd169ab0d9d84 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -945,11 +945,6 @@ pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; #[cfg(not(target_os = "l4re"))] pub const __SIZEOF_PTHREAD_COND_T: usize = 48; -// netinet/in.h -// NOTE: These are in addition to the constants defined in src/unix/mod.rs - -pub const IPPROTO_MAX: c_int = 263; - // System V IPC pub const IPC_PRIVATE: crate::key_t = 0; From 6da370aa948bd3bbafb598b9530ffe935d9c826d Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Mon, 3 Aug 2026 14:49:57 -0400 Subject: [PATCH 50/88] redox: clock_settime, pause Related: bytecodealliance/rustix#1638 clock_settime: https://gitlab.redox-os.org/redox-os/relibc/-/blob/3628bf4677029f0a3186f7d859789a573c47a334/src/header/time/mod.rs#L301 pause: https://gitlab.redox-os.org/redox-os/relibc/-/blob/b3d55c929ed11f276310b32659d0171e063b8448/src/header/unistd/mod.rs#L851 (backport ) (cherry picked from commit a0f07d9c111949f1b8510669f4a33180f0bd14ed) --- libc-test/semver/redox.txt | 2 ++ src/unix/mod.rs | 10 +++++----- src/unix/redox/mod.rs | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index e305cb9a442c4..8753284191f4b 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -301,6 +301,7 @@ chroot clearerr clock_getres clock_gettime +clock_settime difftime dirfd endgrent @@ -353,6 +354,7 @@ open_memstream open_wmemstream openat openpty +pause pipe2 pthread_condattr_setclock qsort diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e0f2de84f2357..bf2cd72ea6f61 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1171,6 +1171,11 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")] pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pause$UNIX2003" + )] + pub fn pause() -> c_int; pub fn pipe(fds: *mut c_int) -> c_int; pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; @@ -2247,11 +2252,6 @@ cfg_if! { if #[cfg(not(target_os = "redox"))] { extern "C" { pub fn getsid(pid: pid_t) -> pid_t; - #[cfg_attr( - all(target_os = "macos", target_arch = "x86"), - link_name = "pause$UNIX2003" - )] - pub fn pause() -> c_int; #[cfg_attr( all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")), link_name = "readdir_r$INODE64" diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index ce0efa12ebd6c..bb73e71ddf2b5 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1432,6 +1432,7 @@ extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; pub fn strftime( s: *mut c_char, max: size_t, From 13d59d78ceaf87d0e82b1e3e63e470fd20da4baf Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 18 Aug 2026 09:15:35 +0000 Subject: [PATCH 51/88] deps: Update `syn` to 3.0 (backport ) (cherry picked from commit 764b10dae4f54ad6ea81c65b2bffc75b7ed4ba63) --- Cargo.lock | 2 +- ctest/src/template.rs | 728 ++++++++++++++++++++++++++++++++++++++++ ctest/src/translator.rs | 428 +++++++++++++++++++++++ libc-test/Cargo.toml | 2 +- 4 files changed, 1158 insertions(+), 2 deletions(-) create mode 100644 ctest/src/template.rs create mode 100644 ctest/src/translator.rs diff --git a/Cargo.lock b/Cargo.lock index 70bfea50a5c57..513e31dab0828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,7 +149,7 @@ dependencies = [ "libc", "proc-macro2", "regex", - "syn 2.0.119", + "syn 3.0.4", ] [[package]] diff --git a/ctest/src/template.rs b/ctest/src/template.rs new file mode 100644 index 0000000000000..4ed9fe559e52f --- /dev/null +++ b/ctest/src/template.rs @@ -0,0 +1,728 @@ +//! Generation of tests from templates for both Rust and C. + +use askama::Template; +use proc_macro2::Span; +use quote::ToTokens; +use syn::spanned::Spanned; + +use crate::cdecl::Constness; +use crate::ffi_items::FfiItems; +use crate::translator::{ + TranslationErrorKind, + Translator, +}; +use crate::{ + BoxStr, + Field, + MapInput, + Result, + TestGenerator, + TranslationError, + VolatileItemKind, + cdecl, +}; + +/// Represents the Rust side of the generated testing suite. +#[derive(Template, Clone)] +#[template(path = "test.rs")] +pub(crate) struct RustTestTemplate { + pub template: TestTemplate, + pub extern_keyword: BoxStr, +} + +impl RustTestTemplate { + pub(crate) fn new( + ffi_items: &FfiItems, + generator: &TestGenerator, + ) -> Result { + Ok(Self { + template: TestTemplate::new(ffi_items, generator)?, + extern_keyword: "extern".into(), + }) + } + + /// Modify the generated template such that it supports edition 2024. + pub(crate) fn edition(&mut self, edition: u32) -> &Self { + match edition { + 2021 => { + self.extern_keyword = "extern".into(); + } + 2024 => { + // For now we only use this to convert extern to unsafe extern. + self.extern_keyword = "unsafe extern".into(); + } + _ => panic!("unsupported or invalid edition: {edition}"), + } + self + } +} + +/// Represents the C side of the generated testing suite. +#[derive(Template, Clone)] +#[template(path = "test.c")] +pub(crate) struct CTestTemplate { + pub template: TestTemplate, + pub headers: Vec<(BoxStr, Vec)>, +} + +impl CTestTemplate { + pub(crate) fn new( + ffi_items: &FfiItems, + generator: &TestGenerator, + ) -> Result { + Ok(Self { + template: TestTemplate::new(ffi_items, generator)?, + headers: generator.headers.clone(), + }) + } +} + +/// Stores all information necessary for generation of tests for all items. +#[derive(Clone, Debug, Default)] +pub(crate) struct TestTemplate { + pub foreign_static_tests: Vec, + pub field_ptr_tests: Vec, + pub field_size_offset_tests: Vec, + pub roundtrip_tests: Vec, + pub foreign_fn_tests: Vec, + pub signededness_tests: Vec, + pub size_align_tests: Vec, + pub const_cstr_tests: Vec, + pub const_tests: Vec, + pub test_idents: Vec, +} + +impl TestTemplate { + /// Populate all tests for all items depending on the configuration provided. + pub(crate) fn new( + ffi_items: &FfiItems, + generator: &TestGenerator, + ) -> Result { + let helper = TranslateHelper::new(ffi_items, generator); + + let mut template = Self::default(); + template.populate_const_and_cstr_tests(&helper)?; + template.populate_size_align_tests(&helper)?; + template.populate_signededness_tests(&helper)?; + template.populate_field_size_offset_tests(&helper)?; + template.populate_field_ptr_tests(&helper)?; + template.populate_roundtrip_tests(&helper)?; + template.populate_foreign_fn_tests(&helper)?; + template.populate_foreign_static_tests(&helper)?; + + Ok(template) + } + + /// Populates tests for constants and C-str constants, keeping track of the names of each test. + fn populate_const_and_cstr_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for constant in helper.filtered_ffi_items.constants() { + if let syn::Type::Ptr(ptr) = &constant.ty + && let syn::Type::Path(path) = &*ptr.elem + && path.path.segments.last().unwrap().ident == "c_char" + && matches!(ptr.mutability, syn::PointerMutability::Const(_)) + { + let item = TestCStr { + id: constant.ident().into(), + test_name: cstr_test_ident(constant.ident()), + rust_val: constant.ident().into(), + c_val: helper.c_ident(constant).into(), + }; + self.const_cstr_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } else { + let item = TestConst { + id: constant.ident().into(), + test_name: const_test_ident(constant.ident()), + rust_val: constant.ident().into(), + rust_ty: constant.ty.to_token_stream().to_string().into_boxed_str(), + c_val: helper.c_ident(constant).into(), + c_ty: helper.c_type(constant)?.into(), + }; + self.const_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + } + + Ok(()) + } + + /// Populates size and alignment tests for aliases, structs, and unions. + /// + /// It also keeps track of the names of each test. + fn populate_size_align_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for alias in helper.filtered_ffi_items.aliases() { + let item = TestSizeAlign { + test_name: size_align_test_ident(alias.ident()), + id: alias.ident().into(), + rust_ty: alias.ident().into(), + c_ty: helper.c_type(alias)?.into(), + }; + self.size_align_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + for struct_ in helper.filtered_ffi_items.structs() { + let item = TestSizeAlign { + test_name: size_align_test_ident(struct_.ident()), + id: struct_.ident().into(), + rust_ty: struct_.ident().into(), + c_ty: helper.c_type(struct_)?.into(), + }; + self.size_align_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + for union_ in helper.filtered_ffi_items.unions() { + let item = TestSizeAlign { + test_name: size_align_test_ident(union_.ident()), + id: union_.ident().into(), + rust_ty: union_.ident().into(), + c_ty: helper.c_type(union_)?.into(), + }; + self.size_align_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates signededness tests for aliases. + /// + /// It also keeps track of the names of each test. + fn populate_signededness_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for alias in helper.filtered_ffi_items.aliases() { + let should_skip_signededness_test = helper + .generator + .skip_signededness + .as_ref() + .is_some_and(|skip| skip(alias.ident())); + + if !helper.translator.is_signed(&alias.ty) || should_skip_signededness_test { + continue; + } + let item = TestSignededness { + test_name: signededness_test_ident(alias.ident()), + id: alias.ident().into(), + c_ty: helper.c_type(alias)?.into(), + }; + self.signededness_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates field size and offset tests for structs/unions. + /// + /// It also keeps track of the names of each test. + fn populate_field_size_offset_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + let should_skip = |map_input| helper.generator.skips.iter().any(|f| f(&map_input)); + + let struct_fields = helper + .filtered_ffi_items + .structs() + .iter() + .flat_map(|struct_| struct_.fields.iter().map(move |field| (struct_, field))) + .filter(|(struct_, field)| { + !should_skip(MapInput::StructField(struct_, field)) && field.public + }) + .map(|(struct_, field)| { + ( + struct_.ident(), + field, + helper.c_type(struct_), + helper.c_ident(MapInput::StructField(struct_, field)), + ) + }); + let union_fields = helper + .filtered_ffi_items + .unions() + .iter() + .flat_map(|union_| union_.fields.iter().map(move |field| (union_, field))) + .filter(|(union_, field)| { + !should_skip(MapInput::UnionField(union_, field)) && field.public + }) + .map(|(union_, field)| { + ( + union_.ident(), + field, + helper.c_type(union_), + helper.c_ident(MapInput::UnionField(union_, field)), + ) + }); + + for (id, field, c_ty, c_field) in struct_fields.chain(union_fields) { + let item = TestFieldSizeOffset { + test_name: field_size_offset_test_ident(id, field.ident()), + id: id.into(), + c_ty: c_ty?.into(), + field: field.clone(), + c_field: c_field.into_boxed_str(), + }; + self.field_size_offset_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates roundtrip tests for aliases/structs/unions. + /// + /// It also keeps track of the names of each test. + fn populate_roundtrip_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for alias in helper.filtered_ffi_items.aliases() { + // Arrays cannot be roundtripped, and are automatically skipped. + if let syn::Type::Array(_) = alias.ty { + continue; + } + let c_ty = helper.c_type(alias)?; + self.add_roundtrip_test(helper, alias.ident(), &[], &c_ty, true); + } + for struct_ in helper.filtered_ffi_items.structs() { + let c_ty = helper.c_type(struct_)?; + self.add_roundtrip_test(helper, struct_.ident(), &struct_.fields, &c_ty, false); + } + for union_ in helper.filtered_ffi_items.unions() { + let c_ty = helper.c_type(union_)?; + self.add_roundtrip_test(helper, union_.ident(), &union_.fields, &c_ty, false); + } + + Ok(()) + } + + fn add_roundtrip_test( + &mut self, + helper: &TranslateHelper, + ident: &str, + fields: &[Field], + c_ty: &str, + is_alias: bool, + ) { + let should_skip_roundtrip_test = helper + .generator + .skip_roundtrip + .as_ref() + .is_some_and(|skip| skip(ident)); + if !should_skip_roundtrip_test { + let item = TestRoundtrip { + test_name: roundtrip_test_ident(ident), + id: ident.into(), + fields: fields.iter().filter(|f| f.public).cloned().collect(), + c_ty: c_ty.into(), + is_alias, + }; + self.roundtrip_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + } + + /// Populates field tests for structs/unions. + /// + /// It also keeps track of the names of each test. + fn populate_field_ptr_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + let should_skip = |map_input| helper.generator.skips.iter().any(|f| f(&map_input)); + + let struct_fields = helper + .filtered_ffi_items + .structs() + .iter() + .flat_map(|s| s.fields.iter().map(move |f| (s, f))) + .filter(|(s, f)| { + !(should_skip(MapInput::StructField(s, f)) + || should_skip(MapInput::StructFieldType(s, f)) + || !f.public) + }) + .map(|(s, f)| { + ( + s.ident(), + f, + helper.c_type(s), + helper.c_ident(MapInput::StructField(s, f)), + if !helper.generator.volatile_items.is_empty() + && helper + .generator + .volatile_items + .iter() + .any(|vf| vf(VolatileItemKind::StructField(s.clone(), f.clone()))) + { + "volatile " + } else { + "" + }, + ) + }); + let union_fields = helper + .filtered_ffi_items + .unions() + .iter() + .flat_map(|u| u.fields.iter().map(move |f| (u, f))) + .filter(|(u, f)| { + !(should_skip(MapInput::UnionField(u, f)) + || should_skip(MapInput::UnionFieldType(u, f)) + || !f.public) + }) + .map(|(u, f)| { + ( + u.ident(), + f, + helper.c_type(u), + helper.c_ident(MapInput::UnionField(u, f)), + "", + ) + }); + + for (id, field, c_ty, c_field, volatile_keyword) in struct_fields.chain(union_fields) { + let field_return_type = cdecl::cdecl( + &cdecl::ptr( + helper.translator.translate_type(&field.ty)?, + cdecl::Constness::Mut, + ), + format!("ctest_field_ty__{}__{}", id, field.ident()), + ) + .map_err(|_| { + TranslationError::new( + TranslationErrorKind::InvalidReturn, + &field.ty.to_token_stream().to_string(), + field.ty.span(), + ) + })? + .into_boxed_str(); + let item = TestFieldPtr { + test_name: field_ptr_test_ident(id, field.ident()), + id: id.into(), + c_ty: c_ty?.into(), + field: field.clone(), + c_field: c_field.into_boxed_str(), + volatile_keyword: volatile_keyword.into(), + field_return_type, + }; + self.field_ptr_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates tests for extern functions. + /// + /// It also keeps track of the names of each test. + fn populate_foreign_fn_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + let should_skip_fn_test = |ident| { + helper + .generator + .skip_fn_ptrcheck + .as_ref() + .is_some_and(|skip| skip(ident)) + }; + for func in helper.filtered_ffi_items.foreign_functions() { + if should_skip_fn_test(func.ident()) { + continue; + } + + let item = TestForeignFn { + test_name: foreign_fn_test_ident(func.ident()), + id: func.ident().into(), + c_val: helper.c_ident(func).into_boxed_str(), + }; + + self.foreign_fn_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } + + /// Populates tests for foreign statics, keeping track of the names of each test. + fn populate_foreign_static_tests( + &mut self, + helper: &TranslateHelper, + ) -> Result<(), TranslationError> { + for static_ in helper.filtered_ffi_items.foreign_statics() { + let rust_ty = static_.ty.to_token_stream().to_string().into_boxed_str(); + + let item = TestForeignStatic { + test_name: static_test_ident(static_.ident()), + id: static_.ident().into(), + c_val: helper.c_ident(static_).into_boxed_str(), + rust_ty, + }; + + self.foreign_static_tests.push(item.clone()); + self.test_idents.push(item.test_name); + } + + Ok(()) + } +} + +/* Many test structures have the following fields: + * + * - `test_name`: The function name. + * - `id`: An identifier that can be used to create functions related to this type without conflict, + * usually also part of `test_name`. + * - `rust_val`: Identifier for a Rust value, with path qualifications if needed. + * - `rust_ty`: The Rust type of the relevant item, with path qualifications if needed. + * - `c_val`: Identifier for a C value (e.g. `#define`) + * - `c_ty`: The C type of the constant, qualified with `struct` or `union` if needed. + */ + +#[derive(Clone, Debug)] +pub(crate) struct TestSignededness { + pub test_name: BoxStr, + pub id: BoxStr, + pub c_ty: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestSizeAlign { + pub test_name: BoxStr, + pub id: BoxStr, + pub rust_ty: BoxStr, + pub c_ty: BoxStr, +} + +/// Information required to test a constant CStr. +#[derive(Clone, Debug)] +pub(crate) struct TestCStr { + pub test_name: BoxStr, + pub id: BoxStr, + pub rust_val: BoxStr, + pub c_val: BoxStr, +} + +/// Information required to test a constant. +#[derive(Clone, Debug)] +pub(crate) struct TestConst { + pub test_name: BoxStr, + pub id: BoxStr, + pub rust_val: BoxStr, + pub c_val: BoxStr, + pub rust_ty: BoxStr, + pub c_ty: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestFieldPtr { + pub test_name: BoxStr, + pub id: BoxStr, + pub field: Field, + pub c_field: BoxStr, + pub c_ty: BoxStr, + pub volatile_keyword: BoxStr, + pub field_return_type: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestFieldSizeOffset { + pub test_name: BoxStr, + pub id: BoxStr, + pub field: Field, + pub c_field: BoxStr, + pub c_ty: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestRoundtrip { + pub test_name: BoxStr, + pub id: BoxStr, + pub fields: Vec, + pub c_ty: BoxStr, + pub is_alias: bool, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestForeignFn { + pub test_name: BoxStr, + pub c_val: BoxStr, + pub id: BoxStr, +} + +#[derive(Clone, Debug)] +pub(crate) struct TestForeignStatic { + pub test_name: BoxStr, + pub id: BoxStr, + pub c_val: BoxStr, + pub rust_ty: BoxStr, +} + +fn signededness_test_ident(ident: &str) -> BoxStr { + format!("ctest_signededness_{ident}").into() +} + +fn size_align_test_ident(ident: &str) -> BoxStr { + format!("ctest_size_align_{ident}").into() +} + +fn cstr_test_ident(ident: &str) -> BoxStr { + format!("ctest_const_cstr_{ident}").into() +} + +fn const_test_ident(ident: &str) -> BoxStr { + format!("ctest_const_{ident}").into() +} + +fn field_ptr_test_ident(ident: &str, field_ident: &str) -> BoxStr { + format!("ctest_field_ptr_{ident}_{field_ident}").into() +} + +fn field_size_offset_test_ident(ident: &str, field_ident: &str) -> BoxStr { + format!("ctest_field_size_offset_{ident}_{field_ident}").into() +} + +fn roundtrip_test_ident(ident: &str) -> BoxStr { + format!("ctest_roundtrip_{ident}").into() +} + +fn foreign_fn_test_ident(ident: &str) -> BoxStr { + format!("ctest_foreign_fn_{ident}").into() +} + +fn static_test_ident(ident: &str) -> BoxStr { + format!("ctest_static_{ident}").into() +} + +/// Wrap methods that depend on both ffi items and the generator. +pub(crate) struct TranslateHelper<'a> { + filtered_ffi_items: FfiItems, + generator: &'a TestGenerator, + translator: Translator<'a>, +} + +impl<'a> TranslateHelper<'a> { + /// Create a new translation helper. + pub(crate) fn new(ffi_items: &'a FfiItems, generator: &'a TestGenerator) -> Self { + let mut helper = Self { + filtered_ffi_items: ffi_items.clone(), + generator, + translator: Translator::new(ffi_items, generator), + }; + helper.filter_ffi_items(); + + helper + } + + /// Skips entire items such as structs, constants, and aliases from being tested. + /// + /// Does not skip specific tests or specific fields. If `skip_private` is true, + /// it will skip tests for all private items. + fn filter_ffi_items(&mut self) { + let verbose = self.generator.verbose_skip; + + let skipped = self.filtered_ffi_items.aliases.extract_if(.., |alias| { + self.generator + .skips + .iter() + .any(|f| f(&MapInput::CEnumType(alias.ident()))) + }); + + for item in skipped { + if verbose { + eprintln!("Skipping C enum type {}", item.ident()); + } + } + + let skipped = self + .filtered_ffi_items + .constants + .extract_if(.., |constant| { + self.generator.skips.iter().any(|f| { + f(&MapInput::CEnumType( + &constant.ty.to_token_stream().to_string(), + )) + }) + }); + + for item in skipped { + if verbose { + eprintln!("Skipping C enum constant {}", item.ident()); + } + } + + macro_rules! filter { + ($field:ident, $variant:ident, $label:literal) => {{ + let skipped = self.filtered_ffi_items.$field.extract_if(.., |item| { + (self.generator.skip_private && !item.public) + || self + .generator + .skips + .iter() + .any(|f| f(&MapInput::$variant(item))) + }); + for item in skipped { + if verbose { + eprintln!("Skipping {} \"{}\"", $label, item.ident()) + } + } + }}; + } + + filter!(aliases, Alias, "alias"); + filter!(constants, Const, "const"); + filter!(structs, Struct, "struct"); + filter!(unions, Union, "union"); + filter!(foreign_functions, Fn, "fn"); + filter!(foreign_statics, Static, "static"); + } + + /// Returns the equivalent C/Cpp identifier of the Rust item. + pub(crate) fn c_ident(&self, item: impl Into>) -> String { + self.generator.rty_to_cty(item) + } + + /// Returns the equivalent C/Cpp type of the Rust item. + pub(crate) fn c_type(&self, item: impl Into>) -> Result { + let item: MapInput = item.into(); + + let (ident, ty) = match item { + MapInput::Const(c) => (c.ident(), self.translator.translate_type(&c.ty)?), + MapInput::StructField(_, f) => (f.ident(), self.translator.translate_type(&f.ty)?), + MapInput::UnionField(_, f) => (f.ident(), self.translator.translate_type(&f.ty)?), + MapInput::Static(s) => (s.ident(), self.translator.translate_type(&s.ty)?), + // For functions, their type would be a bare fn signature, which would need to be saved + // inside of `Fn` when parsed. + MapInput::Fn(_) => unimplemented!(), + // For structs/unions/aliases, their type is the same as their identifier. + MapInput::Alias(a) => (a.ident(), cdecl::named(a.ident(), Constness::Mut)), + MapInput::Struct(s) => (s.ident(), cdecl::named(s.ident(), Constness::Mut)), + MapInput::Union(u) => (u.ident(), cdecl::named(u.ident(), Constness::Mut)), + + MapInput::StructType(_) => panic!("MapInput::StructType is not allowed!"), + MapInput::UnionType(_) => panic!("MapInput::UnionType is not allowed!"), + MapInput::CEnumType(_) => panic!("MapInput::CEnumType is not allowed!"), + MapInput::StructFieldType(_, _) => panic!("MapInput::StructFieldType is not allowed!"), + MapInput::UnionFieldType(_, _) => panic!("MapInput::UnionFieldType is not allowed!"), + MapInput::Type(_) => panic!("MapInput::Type is not allowed!"), + }; + + let ty = cdecl::cdecl(&ty, "".to_string()).map_err(|_| { + TranslationError::new( + TranslationErrorKind::InvalidReturn, + ident, + Span::call_site(), + ) + })?; + + let item = self.translator.map_rust_name_to_c(&ty); + + Ok(self.generator.rty_to_cty(item)) + } +} diff --git a/ctest/src/translator.rs b/ctest/src/translator.rs new file mode 100644 index 0000000000000..9f14fe65154d3 --- /dev/null +++ b/ctest/src/translator.rs @@ -0,0 +1,428 @@ +//! Translation of Rust types to C for test generation. +//! +//! Simple to semi complex types are supported only. + +use std::fmt; +use std::ops::{ + Deref, + DerefMut, +}; + +use proc_macro2::Span; +use quote::ToTokens; +use syn::spanned::Spanned; +use thiserror::Error; + +use crate::cdecl::Constness; +use crate::ffi_items::FfiItems; +use crate::{ + BoxStr, + MapInput, + TestGenerator, + cdecl, +}; + +/// An error that occurs during translation, detailing cause and location. +#[derive(Debug, Error)] +pub struct TranslationError { + #[source] + kind: TranslationErrorKind, + source: String, + span: BoxStr, +} + +impl TranslationError { + /// Create a new translation error. + pub(crate) fn new(kind: TranslationErrorKind, source: &str, span: Span) -> Self { + Self { + kind, + source: source.to_string(), + span: format!( + "{fname}:{line}:{col}", + fname = span.file(), + line = span.start().line, + col = span.start().column, + ) + .into(), + } + } +} + +impl From for askama::Error { + fn from(err: TranslationError) -> Self { + askama::Error::Custom(err.into()) + } +} + +impl fmt::Display for TranslationError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}: `{}` at {}", self.kind, self.source, self.span) + } +} + +/// Errors that can occur during the translation of a type. +#[derive(Debug, Error, PartialEq, Eq)] +pub(crate) enum TranslationErrorKind { + /// The provided type is unknown or unrecognized. + #[error("unsupported type")] + UnsupportedType, + + /// A reference to a non-primitive type was encountered, which is not supported. + #[error("references to non-primitive types are not allowed")] + NonPrimitiveReference, + + /// Lifetimes were found in the type or function signature, which are not supported. + #[error("lifetimes cannot be translated")] + HasLifetimes, + + /// A type that is not ffi compatible was found. + #[error( + "this type is not guaranteed to have a C compatible layout. See improper_ctypes_definitions lint" + )] + NotFfiCompatible, + + /// An array or function was attempted to be returned by a function. + #[error("invalid return type")] + InvalidReturn, +} + +#[derive(Clone)] +/// A Rust to C/Cxx translator. +pub(crate) struct Translator<'a> { + ffi_items: &'a FfiItems, + generator: &'a TestGenerator, +} + +impl<'a> Translator<'a> { + /// Create a new translator. + pub(crate) fn new(ffi_items: &'a FfiItems, generator: &'a TestGenerator) -> Self { + Self { + ffi_items, + generator, + } + } + + /// Translate a Rust type into its equivalent C type. + pub(crate) fn translate_type(&self, ty: &syn::Type) -> Result { + match ty { + syn::Type::Ptr(ptr) => self.translate_ptr(ptr), + syn::Type::Path(path) => self.translate_path(path), + syn::Type::Tuple(tuple) if tuple.elems.is_empty() => { + Ok(cdecl::named("void", Constness::Mut)) + } + syn::Type::Array(array) => self.translate_array(array), + syn::Type::Reference(reference) => self.translate_reference(reference), + syn::Type::FnPtr(function) => self.translate_bare_fn(function), + syn::Type::Never(_) => Ok(cdecl::named("void", Constness::Mut)), + syn::Type::Slice(slice) => Err(TranslationError::new( + TranslationErrorKind::NotFfiCompatible, + &slice.to_token_stream().to_string(), + slice.span(), + )), + syn::Type::Paren(paren) => self.translate_type(&paren.elem), + syn::Type::Group(group) => self.translate_type(&group.elem), + ty => Err(TranslationError::new( + TranslationErrorKind::UnsupportedType, + &ty.to_token_stream().to_string(), + ty.span(), + )), + } + } + + /// Translate a Rust reference to its C equivalent. + fn translate_reference( + &self, + reference: &syn::TypeReference, + ) -> Result { + match reference.elem.deref() { + syn::Type::Path(path) => { + let last_segment = path.path.segments.last().unwrap(); + let ident = last_segment.ident.to_string(); + + match ident.as_str() { + "str" => { + // &str is not ABI safe and should not be supported. + Err(TranslationError::new( + TranslationErrorKind::NotFfiCompatible, + "&str", + path.span(), + )) + } + c if is_rust_primitive(c) => { + let type_name = translate_primitive_type(&last_segment.ident.to_string()); + Ok(ptr_with_inner( + cdecl::named(&type_name, Constness::Mut), + translate_mut(reference.mutability), + )) + } + _ => Err(TranslationError::new( + TranslationErrorKind::NonPrimitiveReference, + &ident, + path.span(), + )), + } + } + syn::Type::Reference(_) + | syn::Type::Ptr(_) + | syn::Type::Array(_) + | syn::Type::FnPtr(_) => { + let ty = self.translate_type(reference.elem.deref())?; + Ok(ptr_with_inner(ty, translate_mut(reference.mutability))) + } + + _ => Err(TranslationError::new( + TranslationErrorKind::UnsupportedType, + &reference.elem.to_token_stream().to_string(), + reference.elem.span(), + )), + } + } + + /// Translate a Rust function pointer type to its C equivalent. + pub(crate) fn translate_bare_fn( + &self, + function: &syn::TypeFnPtr, + ) -> Result { + if function.lifetimes.is_some() { + return Err(TranslationError::new( + TranslationErrorKind::HasLifetimes, + &function.to_token_stream().to_string(), + function.span(), + )); + } + + let mut parameters = function + .inputs + .iter() + .map(|arg| self.translate_type(&arg.ty)) + .collect::, TranslationError>>()?; + + let return_type = match &function.output { + syn::ReturnType::Default => cdecl::named("void", Constness::Mut), + syn::ReturnType::Type(_, ty) => self.translate_type(ty)?, + }; + + if function.variadic.is_some() { + parameters.push(cdecl::variadic()); + } else if parameters.is_empty() { + parameters.push(cdecl::named("void", Constness::Mut)); + } + + Ok(cdecl::func_ptr(parameters, return_type)) + } + + /// Translate a Rust path into its C equivalent. + fn translate_path(&self, path: &syn::TypePath) -> Result { + let last = path.path.segments.last().unwrap(); + if let syn::PathArguments::AngleBracketed(args) = &last.arguments + && let syn::GenericArgument::Type(inner_ty) = args.args.first().unwrap() + { + // Option is ONLY ffi-safe if it contains a function pointer, or a reference. + match inner_ty { + syn::Type::Reference(_) | syn::Type::FnPtr(_) => { + return self.translate_type(inner_ty); + } + _ => { + return Err(TranslationError::new( + TranslationErrorKind::NotFfiCompatible, + &path.to_token_stream().to_string(), + inner_ty.span(), + )); + } + } + } + + let name = last.ident.to_string(); + let item = self.map_rust_name_to_c(&name); + + Ok(cdecl::named( + &self.generator.rty_to_cty(item), + Constness::Mut, + )) + } + + /// Translate a Rust array declaration into its C equivalent. + fn translate_array(&self, array: &syn::TypeArray) -> Result { + Ok(cdecl::array( + self.translate_type(array.elem.deref())?, + Some(&translate_expr(&array.len)), + )) + } + + /// Translate a Rust pointer into its equivalent C pointer. + fn translate_ptr(&self, ptr: &syn::TypePtr) -> Result { + let inner_type = self.translate_type(ptr.elem.deref())?; + Ok(ptr_with_inner( + inner_type, + translate_ptr_mut(&ptr.mutability), + )) + } + + /// Determine whether a C type is a signed type. + /// + /// For primitive types it checks against a known list of signed types, but for aliases + /// which are the only thing other than primitives that can be signed, it recursively checks + /// the underlying type of the alias. + pub(crate) fn is_signed(&self, ty: &syn::Type) -> bool { + match ty { + syn::Type::Path(path) => { + let ident = path.path.segments.last().unwrap().ident.clone(); + if let Some(aliased) = self.ffi_items.aliases().iter().find(|a| ident == a.ident()) + { + return self.is_signed(&aliased.ty); + } + match translate_primitive_type(&ident.to_string()).as_str() { + "char" | "short" | "long" | "long long" | "size_t" | "ssize_t" => true, + s => { + s.starts_with("int") + || s.starts_with("uint") | s.starts_with("signed ") + || s.starts_with("unsigned ") + } + } + } + _ => false, + } + } + + pub(crate) fn map_rust_name_to_c<'name>(&self, name: &'name str) -> MapInput<'name> { + if self.ffi_items.contains_struct(name) { + MapInput::StructType(name) + } else if self.ffi_items.contains_union(name) { + MapInput::UnionType(name) + } else if self.generator.c_enums.iter().any(|f| f(name)) { + MapInput::CEnumType(name) + } else { + MapInput::Type(name) + } + } +} + +/// Translate Rust mutability from a raw pointer to C non-constness. +fn translate_ptr_mut(mutability: &syn::PointerMutability) -> Constness { + match mutability { + syn::PointerMutability::Const(_) => Constness::Const, + syn::PointerMutability::Mut(_) => Constness::Mut, + } +} + +/// Translate Rust mutability from a reference to C non-constness. +fn translate_mut(mutability: Option) -> Constness { + mutability.map_or(Constness::Const, |_| Constness::Mut) +} + +/// Translate a Rust primitive type into its C equivalent. +pub(crate) fn translate_primitive_type(ty: &str) -> String { + match ty { + "usize" => "size_t".to_string(), + "isize" => "ssize_t".to_string(), + "u8" => "uint8_t".to_string(), + "u16" => "uint16_t".to_string(), + "u32" => "uint32_t".to_string(), + "u64" => "uint64_t".to_string(), + "u128" => "unsigned __int128".to_string(), + "i8" => "int8_t".to_string(), + "i16" => "int16_t".to_string(), + "i32" => "int32_t".to_string(), + "i64" => "int64_t".to_string(), + "i128" => "__int128".to_string(), + "f32" => "float".to_string(), + "f64" => "double".to_string(), + "()" => "void".to_string(), + + "c_longdouble" | "c_long_double" => "long double".to_string(), + ty if ty.starts_with("c_") => { + let ty = &ty[2..].replace("long", " long"); + match ty.as_str() { + "short" => "short".to_string(), + s if s.starts_with('u') => format!("unsigned {}", &s[1..]), + s if s.starts_with('s') => format!("signed {}", &s[1..]), + s => s.to_string(), + } + } + // Pass typedefs as is. + s => s.to_string(), + } +} + +/// Construct a CTy and modify the constness of the inner type. +/// +/// Basically, `syn` always gives us the `constness` of the inner type of a pointer. +/// However `cdecl::ptr` wants the `constness` of the pointer. So we just modify +/// the way it is built so that `cdecl::ptr` takes the `constness` of the inner type. +pub(crate) fn ptr_with_inner(inner: cdecl::CTy, constness: Constness) -> cdecl::CTy { + let mut ty = Box::new(inner); + match ty.deref_mut() { + cdecl::CTy::Named { name: _, qual } => qual.constness = constness, + cdecl::CTy::Ptr { ty: _, qual } => qual.constness = constness, + _ => (), + } + cdecl::CTy::Ptr { + ty, + qual: cdecl::Qual { + constness: Constness::Mut, + volatile: false, + restrict: false, + }, + } +} + +/// Translate a simple Rust expression to C. +/// +/// This function will just pass the expression as is in most cases. In more complex cases it can +/// convert `Type as u8 + 5` to `(uint8_t)CType + 5`. +pub(crate) fn translate_expr(expr: &syn::Expr) -> String { + match expr { + syn::Expr::Index(i) => { + let base = translate_expr(&i.expr); + let index = translate_expr(&i.index); + format!("{base}[{index}]") + } + syn::Expr::Lit(l) => match &l.lit { + syn::Lit::Int(i) => { + let suffix = translate_primitive_type(i.suffix()); + let val = i.base10_digits().to_string(); + if suffix.is_empty() { + val + } else { + format!("({suffix}){val}") + } + } + _ => l.to_token_stream().to_string(), + }, + syn::Expr::Path(p) => p.path.segments.last().unwrap().ident.to_string(), + syn::Expr::Cast(c) => { + let val = translate_expr(&c.expr); + let ty = translate_primitive_type(&c.ty.to_token_stream().to_string()); + format!("({ty}){val}") + } + syn::Expr::Binary(b) => { + let left = translate_expr(&b.left); + let op = b.op.to_token_stream().to_string(); + let right = translate_expr(&b.right); + format!("{left} {op} {right}") + } + expr => expr.to_token_stream().to_string(), + } +} + +/// Return whether a type is a Rust primitive type. +fn is_rust_primitive(ty: &str) -> bool { + let rustc_types = [ + "usize", "u8", "u16", "u32", "u64", "u128", "isize", "i8", "i16", "i32", "i64", "i128", + "f32", "f64", + ]; + ty.starts_with("c_") || rustc_types.contains(&ty) +} + +/// Translate ABI of a rust extern function to its C equivalent. +#[expect(unused)] +pub(crate) fn translate_abi(abi: &syn::Abi, target: &str) -> Option<&'static str> { + let abi_name = abi.name.as_ref().map(|lit| lit.value()); + + match abi_name.as_deref() { + Some("stdcall") => "__stdcall ".into(), + Some("system") if target.contains("i686-pc-windows") => "__stdcall ".into(), + Some("C") | Some("system") | None => None, + Some(a) => panic!("unknown ABI: {a}"), + } +} diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 12be9b3fafb70..3244561d35695 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -13,7 +13,7 @@ cfg-if = "1.0.4" libc = { path = "..", version = "0.2.189", default-features = false } [dev-dependencies] -syn = { version = "2.0.108", features = ["full", "visit"] } +syn = { version = "3.0.0", features = ["full", "visit"] } proc-macro2 = { version = "1.0.103", features = ["span-locations"] } glob = "0.3.3" annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } From 973987a39b9246e34dcf43ea33be3e91cad7a238 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 20 Aug 2026 16:24:57 -0400 Subject: [PATCH 52/88] Fix the CI for AIX by skipping the unnamed union symbol and updating semver list. (backport ) (cherry picked from commit 2eda1e52fe2efdf93c1e5c65e346343a530d8bc3) --- libc-test/build/main.rs | 1 + libc-test/semver/aix.txt | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index ed6434346f636..f122b91d75e0f 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -6139,6 +6139,7 @@ fn test_aix(t: &Target) { match s.ident() { // The field 'u' is actually a unnamed union in the AIX header. "poll_ctl_ext" if field.ident() == "u" => true, + "pollfd_ext_t" if field.ident() == "u" => true, // The field 'data' is actually a unnamed union in the AIX header. "pollfd_ext" if field.ident() == "data" => true, diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index ac82c5576f34c..aa337c44d3a13 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -1789,10 +1789,10 @@ _W_SFWTED _W_SLWTED _W_STOPPED _W_STRC +__c_anonymous_ld_info__file +__c_anonymous_pollfd_ext_t_u __context64 __extctx_t -__ld_info_file -__pollfd_ext_u __tm_context_t __vmx_context_t __vmxreg_t @@ -2182,7 +2182,7 @@ poll poll_ctl poll_ctl_ext pollfd -pollfd_ext +pollfd_ext_t pollset_create pollset_ctl pollset_destroy From dee33b1ebab07b48c2fadd6a9dc317fcb3ed7204 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Mon, 3 Aug 2026 08:53:07 +0200 Subject: [PATCH 53/88] l4re: deprecate lfs bindings Add deprecation warnings to LFS bindings under L4Re uClibc. This patch adds notices to types and routines. The only supported target is 64-bits wide. Its suffixed and unsuffixed types should always be equivalent. (backport ) (cherry picked from commit 747d151df0aec7832309cdef9abe14a67aca01e9) --- libc-test/build/main.rs | 6 +- src/unix/linux_like/l4re/mod.rs | 38 ++++++- src/unix/linux_like/l4re/uclibc/mod.rs | 103 +++++++++++------- src/unix/linux_like/l4re/uclibc/x86_64/mod.rs | 39 +++++-- src/unix/linux_like/linux_l4re_shared.rs | 38 +++++++ src/unix/linux_like/mod.rs | 30 +++++ 6 files changed, 196 insertions(+), 58 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index f122b91d75e0f..656f1148b97a2 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4372,7 +4372,7 @@ fn test_linux(t: &Target) { "Ioctl" => Some("int".to_string()), // LFS64 types have been removed in musl 1.2.4+ "off64_t" if musl => Some("off_t".to_string()), - "fsword_t" if uclibc => Some("__SWORD_TYPE".to_string()), + "__sword_type" if uclibc => Some("__SWORD_TYPE".to_string()), _ => None, } }); @@ -4433,6 +4433,10 @@ fn test_linux(t: &Target) { // specific type. "Ioctl" => true, + // This type was renamed to more closely match upstream's + // `__SWORD_TYPE`; It now goes by `__sword_type`. + "fsword_t" if uclibc => true, + t => { if musl { // LFS64 types have been removed in musl 1.2.4+ diff --git a/src/unix/linux_like/l4re/mod.rs b/src/unix/linux_like/l4re/mod.rs index 5ac4868f7d1c2..b3c768623f7f7 100644 --- a/src/unix/linux_like/l4re/mod.rs +++ b/src/unix/linux_like/l4re/mod.rs @@ -10,10 +10,6 @@ pub type pthread_t = *mut c_void; pub type dev_t = u64; pub type socklen_t = u32; pub type mode_t = u32; -pub type ino64_t = u64; -pub type off64_t = i64; -pub type blkcnt64_t = i64; -pub type rlim64_t = u64; pub type nfds_t = c_ulong; pub type nl_item = c_int; pub type idtype_t = c_uint; @@ -22,6 +18,40 @@ pub type pthread_key_t = c_uint; pub type pthread_once_t = c_int; pub type pthread_spinlock_t = c_int; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `ino_t` instead. LFS is being phased out, see rust-lang/libc#4805." + ) +)] +pub type ino64_t = u64; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `off_t` instead. LFS is being phased out, see rust-lang/libc#4805." + ) +)] +pub type off64_t = i64; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `blkcnt_t` instead. LFS is being phased out, see + rust-lang/libc#4805." + ) +)] +pub type blkcnt64_t = i64; +#[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `rlim_t` instead. LFS is being phased out, see rust-lang/libc#4805." + ) +)] +pub type rlim64_t = u64; + s! { /// CPU sets. pub struct l4_sched_cpu_set_t { diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index 79cfa555903a5..5d819e0212a68 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -1,4 +1,3 @@ -use crate::off64_t; use crate::prelude::*; pub type shmatt_t = c_ulong; @@ -10,6 +9,12 @@ pub type __priority_which_t = c_uint; pub type _pthread_descr = *mut c_void; pub type __pthread_cond_align_t = c_long; +#[cfg(target_pointer_width = "64")] +pub type __sword_type = c_long; + +#[cfg(target_pointer_width = "32")] +pub type __sword_type = c_int; + cfg_if! { if #[cfg(doc)] { // Used in `linux::arch` to define ioctl constants. @@ -44,48 +49,33 @@ s! { } pub struct statfs { - pub f_type: fsword_t, - pub f_bsize: fsword_t, + pub f_type: __sword_type, + pub f_bsize: __sword_type, pub f_blocks: crate::fsblkcnt_t, pub f_bfree: crate::fsblkcnt_t, pub f_bavail: crate::fsblkcnt_t, pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_fsid: crate::fsid_t, - pub f_namelen: fsword_t, - pub f_frsize: fsword_t, - pub f_flags: fsword_t, - pub f_spare: [fsword_t; 4], + pub f_namelen: __sword_type, + pub f_frsize: __sword_type, + pub f_flags: __sword_type, + pub f_spare: [__sword_type; 4], } pub struct statfs64 { - pub f_type: fsword_t, - pub f_bsize: fsword_t, + pub f_type: __sword_type, + pub f_bsize: __sword_type, pub f_blocks: crate::fsblkcnt64_t, pub f_bfree: crate::fsblkcnt64_t, pub f_bavail: crate::fsblkcnt64_t, pub f_files: crate::fsfilcnt64_t, pub f_ffree: crate::fsfilcnt64_t, pub f_fsid: crate::fsid_t, - pub f_namelen: fsword_t, - pub f_frsize: fsword_t, - pub f_flags: fsword_t, - pub f_spare: [fsword_t; 4], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsfilcnt64_t, - pub f_bfree: crate::fsfilcnt64_t, - pub f_bavail: crate::fsfilcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], + pub f_namelen: __sword_type, + pub f_frsize: __sword_type, + pub f_flags: __sword_type, + pub f_spare: [__sword_type; 4], } pub struct ipc_perm { @@ -99,11 +89,11 @@ s! { #[cfg(target_pointer_width = "64")] pub mode: c_uint, #[cfg(target_pointer_width = "32")] - __pad1: c_ushort, + __pad1: Padding, pub __seq: c_ushort, - __pad2: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, } pub struct statvfs { @@ -116,15 +106,30 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - #[cfg(target_endian = "little")] pub f_fsid: c_ulong, #[cfg(target_pointer_width = "32")] - __f_unused: c_int, - #[cfg(target_endian = "big")] + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: Padding<[c_int; 6]>, + } + + pub struct statvfs64 { + // Different than GNU! + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct sysinfo { @@ -300,8 +305,8 @@ s! { pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: crate::shmatt_t, - __unused4: c_ulong, - __unused5: c_ulong, + __unused4: Padding, + __unused5: Padding, } } @@ -538,10 +543,26 @@ extern "C" { flags: c_int, ) -> c_int; - pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; - pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; - + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `getrlimit` instead. LFS is being phased out, see rust-lang/libc#4805." + ), + allow(deprecated) + )] pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `setrlimit` instead. LFS is being phased out, see rust-lang/libc#4805." + ), + allow(deprecated) + )] pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) -> c_int; pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; diff --git a/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs b/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs index ed62740e99ed6..b6ae57d870571 100644 --- a/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs @@ -11,13 +11,22 @@ pub type fsfilcnt_t = c_ulong; pub type ino_t = c_ulong; pub type nlink_t = c_ulong; pub type off_t = c_long; +#[deprecated(since = "0.2.190", note = "Use `__sword_type` instead.")] pub type fsword_t = c_long; pub type suseconds_t = c_long; pub type blksize_t = c_long; pub type blkcnt_t = c_long; +#[deprecated( + since = "0.2.190", + note = "Use `fsblkcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805." +)] pub type fsblkcnt64_t = c_ulong; +#[deprecated( + since = "0.2.190", + note = "Use `fsfilcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805." +)] pub type fsfilcnt64_t = c_ulong; pub type __u32 = c_uint; @@ -25,41 +34,39 @@ pub type __u64 = c_ulong; s! { pub struct stat { - pub st_dev: c_ulong, + pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, - // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of - // nlink and mode are swapped on 64 bit systems. pub st_nlink: nlink_t, pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, - pub st_rdev: c_ulong, + __pad0: Padding, + pub st_rdev: crate::dev_t, pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + pub st_blocks: crate::blkcnt_t, pub st_atim: crate::timespec, pub st_mtim: crate::timespec, pub st_ctim: crate::timespec, - __uclibc_unused: [c_long; 3], + __uclibc_unused: Padding<[c_long; 3]>, } pub struct stat64 { - pub st_dev: c_ulong, + pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, pub st_nlink: nlink_t, pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: c_int, - pub st_rdev: c_ulong, + __pad0: Padding, + pub st_rdev: crate::dev_t, pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, + pub st_blocks: crate::blkcnt_t, pub st_atim: crate::timespec, pub st_mtim: crate::timespec, pub st_ctim: crate::timespec, - st_pad4: [c_long; 3], + __uclibc_unused: Padding<[c_long; 3]>, } #[allow(unpredictable_function_pointer_comparisons)] @@ -96,6 +103,14 @@ s! { pub l_pid: crate::pid_t, } + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index fd169ab0d9d84..1f4a760ebab6c 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1930,18 +1930,56 @@ extern "C" { cfg_if! { if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] { extern "C" { + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64",), + deprecated( + since = "0.2.190", + note = "Use `freopen` instead. LFS is being phased out, see \ + rust-lang/libc#4805." + ) + )] pub fn freopen64( filename: *const c_char, mode: *const c_char, file: *mut crate::FILE, ) -> *mut crate::FILE; + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `fseeko` instead. LFS is being phased out, see rust-lang/libc#4805." + ) + )] pub fn fseeko64( stream: *mut crate::FILE, + #[cfg(any( + not(target_os = "l4re"), + all(target_os = "l4re", not(target_pointer_width = "64")) + ))] offset: crate::off64_t, + #[cfg(all(target_os = "l4re", target_pointer_width = "64"))] offset: crate::off_t, whence: c_int, ) -> c_int; + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + deprecated( + since = "0.2.190", + note = "Use `fsetpos` instead. LFS is being phased out, see \ + rust-lang/libc#4805." + ) + )] pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const crate::fpos64_t) -> c_int; + #[cfg(any( + not(target_os = "l4re"), + all(target_os = "l4re", not(target_pointer_width = "64")) + ))] pub fn ftello64(stream: *mut crate::FILE) -> crate::off64_t; + #[cfg(all(target_os = "l4re", target_pointer_width = "64"))] + #[deprecated( + since = "0.2.190", + note = "Use `ftello` instead. LFS is being phased out, see rust-lang/libc#4805." + )] + pub fn ftello64(stream: *mut crate::FILE) -> crate::off_t; } } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 3b041166323ec..1b92f819b3083 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -515,6 +515,8 @@ pub const XATTR_REPLACE: c_int = 0x2; cfg_if! { if #[cfg(target_os = "android")] { pub const RLIM64_INFINITY: c_ulonglong = !0; + } else if #[cfg(all(target_os = "l4re", target_pointer_width = "64"))] { + pub const RLIM64_INFINITY: crate::rlim_t = !0; } else { pub const RLIM64_INFINITY: crate::rlim64_t = !0; } @@ -2135,14 +2137,26 @@ cfg_if! { flags: c_int, ) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] #[cfg(not(target_os = "l4re"))] // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn mmap64( addr: *mut c_void, len: size_t, @@ -2156,6 +2170,10 @@ cfg_if! { // FIXME(1.0,deprecate): lfs binding to be removed pub fn openat64(fd: c_int, path: *const c_char, oflag: c_int, ...) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn posix_fadvise64( fd: c_int, offset: off64_t, @@ -2163,8 +2181,16 @@ cfg_if! { advise: c_int, ) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn pwrite64( fd: c_int, buf: *const c_void, @@ -2184,6 +2210,10 @@ cfg_if! { // FIXME(1.0,deprecate): lfs binding to be removed pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg_attr( + all(target_os = "l4re", target_pointer_width = "64"), + allow(deprecated) + )] pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; } } From cc639921af4fb75fa50fc5f3fb52e84633844038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Volf?= Date: Thu, 27 Mar 2025 17:35:48 +0100 Subject: [PATCH 54/88] add HelenOS support (backport ) (cherry picked from commit 75b2850150d0c50fa012ce965b7466d46da8e4e3) --- Cargo.toml | 5 +++ build.rs | 1 + ci/verify-build.py | 5 +++ src/helenos.rs | 77 ++++++++++++++++++++++++++++++++ src/lib.rs | 8 ++++ src/new/helenos/abi/errno.rs | 43 ++++++++++++++++++ src/new/helenos/bits.rs | 9 ++++ src/new/helenos/dirent_mod.rs | 25 +++++++++++ src/new/helenos/errno.rs | 7 +++ src/new/helenos/fibril.rs | 33 ++++++++++++++ src/new/helenos/fibril_synch.rs | 64 ++++++++++++++++++++++++++ src/new/helenos/inet/addr.rs | 26 +++++++++++ src/new/helenos/inet/dnsr.rs | 23 ++++++++++ src/new/helenos/inet/endpoint.rs | 23 ++++++++++ src/new/helenos/inet/tcp.rs | 74 ++++++++++++++++++++++++++++++ src/new/helenos/ipc/mod.rs | 12 +++++ src/new/helenos/loc.rs | 5 +++ src/new/helenos/mod.rs | 29 ++++++++++++ src/new/helenos/offset.rs | 5 +++ src/new/helenos/stdio.rs | 34 ++++++++++++++ src/new/helenos/stdlib.rs | 18 ++++++++ src/new/helenos/time.rs | 19 ++++++++ src/new/helenos/vfs/vfs.rs | 43 ++++++++++++++++++ src/new/mod.rs | 13 ++++++ 24 files changed, 601 insertions(+) create mode 100644 src/helenos.rs create mode 100644 src/new/helenos/abi/errno.rs create mode 100644 src/new/helenos/bits.rs create mode 100644 src/new/helenos/dirent_mod.rs create mode 100644 src/new/helenos/errno.rs create mode 100644 src/new/helenos/fibril.rs create mode 100644 src/new/helenos/fibril_synch.rs create mode 100644 src/new/helenos/inet/addr.rs create mode 100644 src/new/helenos/inet/dnsr.rs create mode 100644 src/new/helenos/inet/endpoint.rs create mode 100644 src/new/helenos/inet/tcp.rs create mode 100644 src/new/helenos/ipc/mod.rs create mode 100644 src/new/helenos/loc.rs create mode 100644 src/new/helenos/mod.rs create mode 100644 src/new/helenos/offset.rs create mode 100644 src/new/helenos/stdio.rs create mode 100644 src/new/helenos/stdlib.rs create mode 100644 src/new/helenos/time.rs create mode 100644 src/new/helenos/vfs/vfs.rs diff --git a/Cargo.toml b/Cargo.toml index 5ac3f724f41fc..afc199db5a633 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,6 +100,7 @@ targets = [ # Tier 3 targets that are distinct enough to be useful, or have historically # been documented. "aarch64-unknown-freebsd", + "aarch64-unknown-helenos", "aarch64-unknown-hermit", "aarch64-unknown-illumos", "aarch64-unknown-netbsd", @@ -117,6 +118,7 @@ targets = [ "armv7r-none-eabihf", "hexagon-unknown-linux-musl", "i686-unknown-haiku", + "i686-unknown-helenos", "i686-unknown-netbsd", "i686-unknown-openbsd", "i686-wrs-vxworks", @@ -129,6 +131,7 @@ targets = [ "mipsel-sony-psp", "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", + "powerpc-unknown-helenos", "powerpc-unknown-linux-gnuspe", "powerpc-unknown-netbsd", "powerpc-wrs-vxworks", @@ -150,6 +153,7 @@ targets = [ "riscv64imac-unknown-none-elf", "s390x-unknown-linux-musl", "sparc-unknown-linux-gnu", + "sparc64-unknown-helenos", "sparc64-unknown-netbsd", "thumbv6m-none-eabi", "thumbv7em-none-eabi", @@ -160,6 +164,7 @@ targets = [ "x86_64-pc-cygwin", "x86_64-unknown-dragonfly", "x86_64-unknown-haiku", + "x86_64-unknown-helenos", "x86_64-unknown-hermit", "x86_64-unknown-hurd-gnu", "x86_64-unknown-l4re-uclibc", diff --git a/build.rs b/build.rs index 17d9b832867ae..28467e7da033f 100644 --- a/build.rs +++ b/build.rs @@ -48,6 +48,7 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ "target_os", &[ "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "qurt", "qnx", + "helenos", ], ), ( diff --git a/ci/verify-build.py b/ci/verify-build.py index 0219022ab30eb..83863d0a7e620 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -157,6 +157,7 @@ class TargetResult: # there is no need to do this given the target tier policy, but the cost is small # and the saved churn from accidental breakage is significant, so we keep it around. Target("aarch64-unknown-freebsd", dist=False), + Target("aarch64-unknown-helenos", dist=False), Target("aarch64-unknown-hermit", dist=False), Target("aarch64-unknown-illumos", dist=False), Target("aarch64-unknown-netbsd", dist=False), @@ -171,6 +172,7 @@ class TargetResult: Target("i386-apple-ios", dist=False), Target("i686-apple-darwin", dist=False), Target("i686-unknown-haiku", dist=False), + Target("i686-unknown-helenos", dist=False), Target("i686-unknown-hurd-gnu", dist=False), Target("i686-unknown-netbsd", dist=False), Target("i686-unknown-openbsd", dist=False), @@ -183,6 +185,7 @@ class TargetResult: Target("mips64el-unknown-linux-muslabi64", dist=False), Target("mipsel-unknown-linux-gnu", dist=False), Target("mipsel-unknown-linux-musl", dist=False), + Target("powerpc-unknown-helenos", dist=False), Target("powerpc-unknown-linux-gnuspe", dist=False), Target("powerpc-unknown-netbsd", dist=False), Target("powerpc-wrs-vxworks", dist=False), @@ -204,12 +207,14 @@ class TargetResult: Target("riscv64imac-unknown-none-elf", dist=False), Target("s390x-unknown-linux-musl", dist=False), Target("sparc-unknown-linux-gnu", dist=False), + Target("sparc64-unknown-helenos", dist=False), Target("sparc64-unknown-netbsd", dist=False), Target("thumbv7em-none-eabihf", dist=False), Target("thumbv7m-none-eabi", dist=False), Target("thumbv8m.main-none-eabi", dist=False), Target("x86_64-unknown-dragonfly", dist=False), Target("x86_64-unknown-haiku", dist=False), + Target("x86_64-unknown-helenos", dist=False), Target("x86_64-unknown-hermit", dist=False), Target("x86_64-unknown-l4re-uclibc", dist=False), Target("x86_64-unknown-openbsd", dist=False), diff --git a/src/helenos.rs b/src/helenos.rs new file mode 100644 index 0000000000000..96253c1d58925 --- /dev/null +++ b/src/helenos.rs @@ -0,0 +1,77 @@ +use crate::prelude::*; +use crate::{ + errno_t, + timespec, +}; + +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type size_t = usize; +pub type ssize_t = isize; + +// uspace/lib/posix/include/posix/pthread.h +pub type pthread_key_t = c_int; + +// uspace/lib/posix/include/posix/sys/types.h +pub type clockid_t = c_int; +pub type pid_t = c_int; + +s! { + // common/include/adt/list.h + pub struct link_t { + pub next: *mut link_t, + pub prev: *mut link_t, + } + + pub struct list_t { + pub head: link_t, + } +} + +// uspace/lib/posix/include/posix/time.h +pub const CLOCK_REALTIME: clockid_t = 0; +pub const CLOCK_MONOTONIC: clockid_t = 1; + +// 'static inline' functions from libc +// common/include/adt/list.h +f! { + pub safe fn list_initialize(list: &mut list_t) -> () { + list.head.next = &mut list.head; + list.head.prev = &mut list.head; + } +} + +extern "C" { + // common/include/str_error.h + pub fn str_error(err: errno_t) -> *const c_char; + pub fn str_error_name(err: errno_t) -> *const c_char; + + // uspace/lib/posix/include/posix/pthread.h + pub fn pthread_key_create( + key: *mut pthread_key_t, + destructor: Option, + ) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + + // uspace/lib/posix/include/posix/time.h + pub fn clock_getres(clock_id: clockid_t, res: *mut timespec) -> c_int; + pub fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int; + pub fn clock_settime(clock_id: clockid_t, tp: *const timespec) -> c_int; + pub fn clock_nanosleep( + clock_id: clockid_t, + flags: c_int, + rqtp: *const timespec, + rmtp: *mut timespec, + ) -> c_int; + + // uspace/lib/posix/include/posix/unistd.h + pub fn getpid() -> pid_t; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn chdir(buf: *const c_char) -> c_int; + pub static environ: *const *const c_char; + pub fn isatty(fd: c_int) -> c_int; +} diff --git a/src/lib.rs b/src/lib.rs index a95a967e73626..671e2c7dc81be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -254,6 +254,14 @@ cfg_if! { mod unix; pub use crate::unix::*; + prelude!(); + } else if #[cfg(target_os = "helenos")] { + mod primitives; + pub use primitives::*; + + mod helenos; + pub use self::helenos::*; + prelude!(); } else if #[cfg(target_os = "hermit")] { mod primitives; diff --git a/src/new/helenos/abi/errno.rs b/src/new/helenos/abi/errno.rs new file mode 100644 index 0000000000000..040298a720359 --- /dev/null +++ b/src/new/helenos/abi/errno.rs @@ -0,0 +1,43 @@ +//! HelenOS errno codes +//! +//! * Header file: + +use crate::errno_t; + +pub const EOK: errno_t = 0; +pub const ENOENT: errno_t = 1; +pub const ENOMEM: errno_t = 2; +pub const ELIMIT: errno_t = 3; +pub const EREFUSED: errno_t = 4; +pub const EFORWARD: errno_t = 5; +pub const EPERM: errno_t = 6; +pub const EHANGUP: errno_t = 7; +pub const EPARTY: errno_t = 8; +pub const EEXIST: errno_t = 9; +pub const EBADMEM: errno_t = 10; +pub const ENOTSUP: errno_t = 11; +pub const EADDRNOTAVAIL: errno_t = 12; +pub const ETIMEOUT: errno_t = 13; +pub const EINVAL: errno_t = 14; +pub const EBUSY: errno_t = 15; +pub const EOVERFLOW: errno_t = 16; +pub const EINTR: errno_t = 17; +pub const EMFILE: errno_t = 18; +pub const ENAMETOOLONG: errno_t = 19; +pub const EISDIR: errno_t = 20; +pub const ENOTDIR: errno_t = 21; +pub const ENOSPC: errno_t = 22; +pub const ENOTEMPTY: errno_t = 23; +pub const EBADF: errno_t = 24; +pub const EDOM: errno_t = 25; +pub const ERANGE: errno_t = 26; +pub const EXDEV: errno_t = 27; +pub const EIO: errno_t = 28; +pub const EMLINK: errno_t = 29; +pub const ENXIO: errno_t = 30; +pub const ENOFS: errno_t = 31; +pub const EBADCHECKSUM: errno_t = 32; +pub const ESTALL: errno_t = 33; +pub const EEMPTY: errno_t = 34; +pub const ENAK: errno_t = 35; +pub const EAGAIN: errno_t = 36; diff --git a/src/new/helenos/bits.rs b/src/new/helenos/bits.rs new file mode 100644 index 0000000000000..bcb704d8cb038 --- /dev/null +++ b/src/new/helenos/bits.rs @@ -0,0 +1,9 @@ +//! HelenOS ABI bits +//! +//! * Headers: + +// `errno.h` +pub type errno_t = crate::c_int; + +// `native.h` +pub type sysarg_t = crate::uintptr_t; diff --git a/src/new/helenos/dirent_mod.rs b/src/new/helenos/dirent_mod.rs new file mode 100644 index 0000000000000..5fb426e78a404 --- /dev/null +++ b/src/new/helenos/dirent_mod.rs @@ -0,0 +1,25 @@ +//! HelenOS directory entry API +//! +//! * Header file: + +// The module is named to avoid name collision with the dirent struct, which causes issues with +// wildcard imports in the parent module. + +use crate::prelude::*; + +s! { + pub struct dirent { + pub d_name: [c_char; 256], + } +} + +extern_ty! { + pub type DIR; +} + +extern "C" { + pub fn opendir(name: *const c_char) -> *mut DIR; + pub fn readdir(dir: *mut DIR) -> *mut dirent; + pub fn closedir(dir: *mut DIR) -> c_int; + pub fn rewinddir(dir: *mut DIR); +} diff --git a/src/new/helenos/errno.rs b/src/new/helenos/errno.rs new file mode 100644 index 0000000000000..09b303fa5fa3e --- /dev/null +++ b/src/new/helenos/errno.rs @@ -0,0 +1,7 @@ +//! HelenOS errno handling +//! +//! * Header file: + +extern "C" { + pub fn __errno() -> *mut crate::errno_t; +} diff --git a/src/new/helenos/fibril.rs b/src/new/helenos/fibril.rs new file mode 100644 index 0000000000000..7027578e977c1 --- /dev/null +++ b/src/new/helenos/fibril.rs @@ -0,0 +1,33 @@ +//! HelenOS fibrils API +//! +//! * Header file: + +use crate::errno_t; +use crate::prelude::*; +pub use crate::time::*; + +pub type fid_t = *mut fibril_t; + +s! { + pub struct fibril_owner_info_t { + pub owned_by: *mut fibril_t, + } +} + +extern_ty! { + pub type fibril_t; +} + +extern "C" { + pub fn fibril_create_generic( + func: unsafe extern "C" fn(*mut c_void) -> errno_t, + arg: *mut c_void, + stacksize: size_t, + ) -> fid_t; + pub fn fibril_start(f: fid_t); + pub fn fibril_exit(retval: c_long) -> !; + pub fn fibril_detach(f: fid_t); + pub fn fibril_yield(); + pub fn fibril_usleep(usec: usec_t); + pub fn fibril_get_id() -> fid_t; +} diff --git a/src/new/helenos/fibril_synch.rs b/src/new/helenos/fibril_synch.rs new file mode 100644 index 0000000000000..2d58a862022e2 --- /dev/null +++ b/src/new/helenos/fibril_synch.rs @@ -0,0 +1,64 @@ +//! HelenOS fibril synchronization primitives +//! +//! * Header file: + +pub use crate::fibril::*; +use crate::prelude::*; +use crate::{ + errno_t, + list_initialize, + list_t, +}; + +s! { + pub struct fibril_mutex_t { + pub oi: fibril_owner_info_t, + pub counter: c_int, + pub waiters: list_t, + } + + pub struct fibril_rwlock_t { + pub oi: fibril_owner_info_t, + pub writers: c_uint, + pub readers: c_uint, + pub waiters: list_t, + } + + pub struct fibril_condvar_t { + pub waiters: list_t, + } +} + +f! { + pub safe fn fibril_mutex_initialize(fm: &mut fibril_mutex_t) -> () { + fm.oi.owned_by = ptr::null_mut(); + fm.counter = 1; + list_initialize(&mut fm.waiters); + } +} + +extern "C" { + pub fn fibril_mutex_lock(mutex: *mut fibril_mutex_t); + pub fn fibril_mutex_unlock(mutex: *mut fibril_mutex_t); + pub fn fibril_mutex_trylock(mutex: *mut fibril_mutex_t) -> bool; + pub fn fibril_mutex_is_locked(mutex: *mut fibril_mutex_t) -> bool; + + pub fn fibril_rwlock_initialize(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_read_lock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_write_lock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_read_unlock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_write_unlock(rwlock: *mut fibril_rwlock_t); + pub fn fibril_rwlock_is_read_locked(rwlock: *mut fibril_rwlock_t) -> bool; + pub fn fibril_rwlock_is_write_locked(rwlock: *mut fibril_rwlock_t) -> bool; + pub fn fibril_rwlock_is_locked(rwlock: *mut fibril_rwlock_t) -> bool; + + pub fn fibril_condvar_initialize(condvar: *mut fibril_condvar_t); + pub fn fibril_condvar_wait(condvar: *mut fibril_condvar_t, mutex: *mut fibril_mutex_t); + pub fn fibril_condvar_wait_timeout( + condvar: *mut fibril_condvar_t, + mutex: *mut fibril_mutex_t, + timeout: usec_t, + ) -> errno_t; + pub fn fibril_condvar_signal(condvar: *mut fibril_condvar_t); + pub fn fibril_condvar_broadcast(condvar: *mut fibril_condvar_t); +} diff --git a/src/new/helenos/inet/addr.rs b/src/new/helenos/inet/addr.rs new file mode 100644 index 0000000000000..3fab343546650 --- /dev/null +++ b/src/new/helenos/inet/addr.rs @@ -0,0 +1,26 @@ +//! HelenOS internet address types +//! +//! * Header file: + +pub type addr32_t = u32; +pub type addr128_t = [u8; 16]; + +c_enum! { + #[repr(u32)] + pub enum ip_ver_t { + pub ip_any, + pub ip_v4, + pub ip_v6, + } +} +s_no_extra_traits! { + pub union __inet_addr_t_addr_union { + pub addr: addr32_t, + pub addr6: addr128_t, + } + + pub struct inet_addr_t { + pub version: ip_ver_t, + pub addr: __inet_addr_t_addr_union, + } +} diff --git a/src/new/helenos/inet/dnsr.rs b/src/new/helenos/inet/dnsr.rs new file mode 100644 index 0000000000000..4389ace086fce --- /dev/null +++ b/src/new/helenos/inet/dnsr.rs @@ -0,0 +1,23 @@ +//! HelenOS DNS resolver API +//! +//! * Header file: + +use crate::errno_t; +pub use crate::inet::addr::*; +use crate::prelude::*; + +s_no_extra_traits! { + pub struct dnsr_hostinfo_t { + pub cname: *mut c_char, + pub addr: inet_addr_t, + } +} + +extern "C" { + pub fn dnsr_name2host( + name: *const c_char, + info: *mut *mut dnsr_hostinfo_t, + ipver: ip_ver_t, + ) -> errno_t; + pub fn dnsr_hostinfo_destroy(info: *mut dnsr_hostinfo_t); +} diff --git a/src/new/helenos/inet/endpoint.rs b/src/new/helenos/inet/endpoint.rs new file mode 100644 index 0000000000000..2f8fecc88309d --- /dev/null +++ b/src/new/helenos/inet/endpoint.rs @@ -0,0 +1,23 @@ +//! HelenOS internet endpoint types +//! +//! * Header file: + +pub use crate::inet::addr::*; +pub use crate::loc::*; + +s_no_extra_traits! { + pub struct inet_ep2_t { + pub local_link: service_id_t, + pub local: inet_ep_t, + pub remote: inet_ep_t, + } + + pub struct inet_ep_t { + pub addr: inet_addr_t, + pub port: u16, + } +} +extern "C" { + pub fn inet_ep_init(ep: *mut inet_ep_t); + pub fn inet_ep2_init(epp: *mut inet_ep2_t); +} diff --git a/src/new/helenos/inet/tcp.rs b/src/new/helenos/inet/tcp.rs new file mode 100644 index 0000000000000..59a901d5af2b6 --- /dev/null +++ b/src/new/helenos/inet/tcp.rs @@ -0,0 +1,74 @@ +//! HelenOS TCP API +//! +//! * Header file: + +use crate::errno_t; +pub use crate::inet::endpoint::*; +use crate::prelude::*; + +s_no_extra_traits! { + pub struct tcp_cb_t { + pub connected: Option, + pub conn_failed: Option, + pub conn_reset: Option, + pub data_avail: Option, + pub urg_data: Option, + } + pub struct tcp_listen_cb_t { + pub new_conn: + Option, + } +} + +extern_ty! { + pub type tcp_t; + pub type tcp_conn_t; + pub type tcp_listener_t; +} + +extern "C" { + pub fn tcp_create(tcp: *mut *mut tcp_t) -> errno_t; + pub fn tcp_destroy(tcp: *mut tcp_t); + + pub fn tcp_conn_create( + tcp: *mut tcp_t, + epp: *mut inet_ep2_t, + callbacks: *mut tcp_cb_t, + arg: *mut c_void, + conn: *mut *mut tcp_conn_t, + ) -> errno_t; + pub fn tcp_conn_destroy(conn: *mut tcp_conn_t); + + pub fn tcp_listener_create( + tcp: *mut tcp_t, + ep: *mut inet_ep_t, + listen_callbacks: *mut tcp_listen_cb_t, + listen_arg: *mut c_void, + conn_callbacks: *mut tcp_cb_t, + conn_arg: *mut c_void, + listener: *mut *mut tcp_listener_t, + ) -> errno_t; + pub fn tcp_listener_destroy(listener: *mut tcp_listener_t); + + pub fn tcp_conn_userptr(conn: *mut tcp_conn_t) -> *mut c_void; + pub fn tcp_listener_userptr(listener: *mut tcp_listener_t) -> *mut c_void; + + pub fn tcp_conn_wait_connected(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_send(conn: *mut tcp_conn_t, buf: *const c_void, len: size_t) -> errno_t; + pub fn tcp_conn_send_fin(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_push(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_reset(conn: *mut tcp_conn_t) -> errno_t; + + pub fn tcp_conn_recv( + conn: *mut tcp_conn_t, + buf: *mut c_void, + bufsize: size_t, + received_len: *mut size_t, + ) -> errno_t; + pub fn tcp_conn_recv_wait( + conn: *mut tcp_conn_t, + buf: *mut c_void, + bufsize: size_t, + received_len: *mut size_t, + ) -> errno_t; +} diff --git a/src/new/helenos/ipc/mod.rs b/src/new/helenos/ipc/mod.rs new file mode 100644 index 0000000000000..f7fa66ec789c3 --- /dev/null +++ b/src/new/helenos/ipc/mod.rs @@ -0,0 +1,12 @@ +//! HelenOS IPC types +//! +//! Headers: + +pub(crate) mod loc { + pub type service_id_t = crate::sysarg_t; +} + +pub(crate) mod vfs { + pub type fs_handle_t = i16; + pub type fs_index_t = u32; +} diff --git a/src/new/helenos/loc.rs b/src/new/helenos/loc.rs new file mode 100644 index 0000000000000..0cf367785713b --- /dev/null +++ b/src/new/helenos/loc.rs @@ -0,0 +1,5 @@ +//! HelenOS libc/loc +//! +//! * Header file: + +pub use crate::ipc::loc::*; diff --git a/src/new/helenos/mod.rs b/src/new/helenos/mod.rs new file mode 100644 index 0000000000000..3e19ea26f87fa --- /dev/null +++ b/src/new/helenos/mod.rs @@ -0,0 +1,29 @@ +//! HelenOS libraries +//! +//! * HelenOS source tree: (libraries are in uspace/lib, some bits are in abi and common) + +pub(crate) mod abi { + pub(crate) mod errno; +} +pub(crate) mod bits; +pub(crate) mod dirent_mod; +pub(crate) mod errno; +pub(crate) mod fibril; +pub(crate) mod fibril_synch; +pub(crate) mod inet { + pub(crate) mod addr; + pub(crate) mod dnsr; + pub(crate) mod endpoint; + pub(crate) mod tcp; +} +pub(crate) mod ipc; +pub(crate) mod loc; +pub(crate) mod offset; +pub(crate) mod stdio; +pub(crate) mod stdlib; +pub(crate) mod time; +pub(crate) mod vfs { + // The module layout mirrors the `vfs/vfs.h` header path. + #[allow(clippy::module_inception)] + pub(crate) mod vfs; +} diff --git a/src/new/helenos/offset.rs b/src/new/helenos/offset.rs new file mode 100644 index 0000000000000..131d3d72f09ca --- /dev/null +++ b/src/new/helenos/offset.rs @@ -0,0 +1,5 @@ +//! HelenOS libc offset types +//! +//! * Header file: + +pub type aoff64_t = u64; diff --git a/src/new/helenos/stdio.rs b/src/new/helenos/stdio.rs new file mode 100644 index 0000000000000..8cd785c09b490 --- /dev/null +++ b/src/new/helenos/stdio.rs @@ -0,0 +1,34 @@ +//! HelenOS libc standard I/O APIs +//! +//! * Header file: + +use crate::prelude::*; + +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +extern_ty! { + pub type FILE; +} + +extern "C" { + pub static stdin: *mut FILE; + pub static stdout: *mut FILE; + pub static stderr: *mut FILE; + + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn fclose(stream: *mut FILE) -> c_int; + pub fn fflush(stream: *mut FILE) -> c_int; + + pub fn fread(buf: *mut c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(buf: *const c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + + pub fn fileno(stream: *mut FILE) -> c_int; +} diff --git a/src/new/helenos/stdlib.rs b/src/new/helenos/stdlib.rs new file mode 100644 index 0000000000000..1f92a3de4fa55 --- /dev/null +++ b/src/new/helenos/stdlib.rs @@ -0,0 +1,18 @@ +use crate::prelude::*; + +extern "C" { + pub fn malloc(size: usize) -> *mut c_void; + pub fn calloc(nmemb: usize, size: usize) -> *mut c_void; + pub fn realloc(addr: *mut c_void, size: usize) -> *mut c_void; + pub fn free(addr: *mut c_void); + + pub fn memalign(align: usize, size: usize) -> *mut c_void; + + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn exit(code: c_int) -> !; + pub fn abort() -> !; + + pub fn getenv(env: *const c_char) -> *mut c_char; +} diff --git a/src/new/helenos/time.rs b/src/new/helenos/time.rs new file mode 100644 index 0000000000000..0175af24c0061 --- /dev/null +++ b/src/new/helenos/time.rs @@ -0,0 +1,19 @@ +//! HelenOS time handling +//! +//! * Header file: + +use crate::prelude::*; + +pub type time_t = c_longlong; +pub type usec_t = c_longlong; + +s_with_default! { + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } +} + +extern "C" { + pub fn getuptime(tp: *mut timespec); +} diff --git a/src/new/helenos/vfs/vfs.rs b/src/new/helenos/vfs/vfs.rs new file mode 100644 index 0000000000000..df296b4e7cd99 --- /dev/null +++ b/src/new/helenos/vfs/vfs.rs @@ -0,0 +1,43 @@ +//! HelenOS libc virtual file system APIs +//! +//! * Header file: + +use crate::errno_t; +pub use crate::ipc::loc::*; +pub use crate::ipc::vfs::*; +pub use crate::offset::*; +use crate::prelude::*; +pub use crate::stdio::*; + +s! { + pub struct vfs_stat_t { + pub fs_handle: fs_handle_t, + pub service_id: service_id_t, + pub index: fs_index_t, + pub lnkcnt: c_uint, + pub is_file: bool, + pub is_directory: bool, + pub size: aoff64_t, + pub service: service_id_t, + } +} + +c_enum! { + pub enum vfs_file_kind_t { + pub KIND_FILE, + pub KIND_DIRECTORY, + } +} + +extern "C" { + pub fn vfs_fhandle(file: *mut FILE, handle: *mut c_int) -> errno_t; + pub fn vfs_stat(handle: c_int, stat: *mut vfs_stat_t) -> errno_t; + pub fn vfs_link_path( + path: *const c_char, + kind: vfs_file_kind_t, + linkedfd: *mut c_int, + ) -> errno_t; + pub fn vfs_unlink_path(path: *const c_char) -> errno_t; + pub fn vfs_rename_path(oldpath: *const c_char, newpath: *const c_char) -> errno_t; + pub fn vfs_stat_path(path: *const c_char, stat: *mut vfs_stat_t) -> errno_t; +} diff --git a/src/new/mod.rs b/src/new/mod.rs index 397275932c509..0ef6b0b53f7c7 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -72,6 +72,9 @@ cfg_if! { } else if #[cfg(target_os = "haiku")] { mod haiku; pub(crate) use haiku::*; + } else if #[cfg(target_os = "helenos")] { + mod helenos; + pub(crate) use helenos::*; } else if #[cfg(target_os = "hermit")] { mod hermit_abi; // pub(crate) use hermit_abi::*; @@ -240,6 +243,16 @@ cfg_if! { pub use sys::file::*; pub use sys::ioccom::*; pub use sys::socket::*; + } else if #[cfg(target_os = "helenos")] { + pub use abi::errno::*; + pub use bits::*; + pub use dirent_mod::*; + pub use errno::*; + pub use fibril_synch::*; + pub use inet::dnsr::*; + pub use inet::tcp::*; + pub use stdlib::*; + pub use vfs::vfs::*; } } From be1dd9a2a66e7e28a88fe516de0340b355ec08b9 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Thu, 27 Aug 2026 15:51:04 -0400 Subject: [PATCH 55/88] bsd/apple: add missing NET_RT_DUMP2 definition The missing constant is defined here: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/socket.h#L582 It's defined next to NET_RT_IFLIST2, which was already included right next to the new definition. (backport ) (cherry picked from commit bd415df57bc97f3cba6299d2d392bbb65566f923) --- 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 009b0cd280438..e88c7a301a645 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -936,6 +936,7 @@ MS_DEACTIVATE MS_KILLPAGES NANOSECOND NET_RT_DUMP +NET_RT_DUMP2 NET_RT_FLAGS NET_RT_IFLIST NET_RT_IFLIST2 diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c1589f2257b4d..2e1069b12f063 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3743,6 +3743,7 @@ pub const XATTR_NODEFAULT: c_int = 0x0010; pub const XATTR_SHOWCOMPRESSION: c_int = 0x0020; pub const NET_RT_IFLIST2: c_int = 0x0006; +pub const NET_RT_DUMP2: c_int = 0x0007; cfg_if! { if #[cfg(target_os = "macos")] { From ea6f543eb727698508ca7d913b38641e4986a750 Mon Sep 17 00:00:00 2001 From: sakars Date: Wed, 26 Aug 2026 13:20:07 +0300 Subject: [PATCH 56/88] ETH_P_LLDP added to linux https://github.com/torvalds/linux/blob/45c13f3f9e3bb15fd89ff2864c6f627a3b4b4229/include/uapi/linux/if_ether.h#L101 Signed-off-by: sakars (backport ) (cherry picked from commit e54d28e4415cd400d75c5c1d7e3455970533a9f0) --- libc-test/semver/linux.txt | 1 + src/unix/linux_like/linux/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 98c291e24a84e..ba6693d4d2f6f 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -727,6 +727,7 @@ ETH_P_IPX ETH_P_IRDA ETH_P_LAT ETH_P_LINK_CTL +ETH_P_LLDP ETH_P_LOCALTALK ETH_P_LOOP ETH_P_LOOPBACK diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index f5bf60eb838d6..2dbcb069c8abd 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1476,6 +1476,7 @@ pub const ETH_P_AOE: c_int = 0x88A2; pub const ETH_P_8021AD: c_int = 0x88A8; pub const ETH_P_802_EX1: c_int = 0x88B5; pub const ETH_P_TIPC: c_int = 0x88CA; +pub const ETH_P_LLDP: c_int = 0x88CC; pub const ETH_P_MACSEC: c_int = 0x88E5; pub const ETH_P_8021AH: c_int = 0x88E7; pub const ETH_P_MVRP: c_int = 0x88F5; From f0b2b950795d05b3b36fb3ec93a9be5864e4c29e Mon Sep 17 00:00:00 2001 From: Aelin Reidel Date: Sun, 30 Aug 2026 22:25:39 +0200 Subject: [PATCH 57/88] linux_like: Expose statx on all musl versions Exposing the constants and the method in itself is not a breaking change, users are responsible for knowing whether they can call the method without running into linker errors, just like on glibc. (backport ) (cherry picked from commit 823b37fd515dc5fa5f8f56abe4127e776fe80804) --- src/unix/linux_like/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 1b92f819b3083..a55cd72a23ded 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -269,8 +269,8 @@ cfg_if! { cfg_if! { if #[cfg(any( target_env = "gnu", + target_env = "musl", target_os = "android", - all(target_env = "musl", musl_v1_2) ))] { s! { pub struct statx { @@ -1656,8 +1656,8 @@ cfg_if! { cfg_if! { if #[cfg(any( target_env = "gnu", + target_env = "musl", target_os = "android", - all(target_env = "musl", musl_v1_2), target_os = "l4re" ))] { pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; @@ -2271,8 +2271,8 @@ cfg_if! { cfg_if! { if #[cfg(any( target_env = "gnu", + target_env = "musl", target_os = "android", - all(target_env = "musl", musl_v1_2) ))] { extern "C" { pub fn statx( From e441680b6f89d07b073004d694fd8b88e1f8daa7 Mon Sep 17 00:00:00 2001 From: Aelin Reidel Date: Sun, 30 Aug 2026 23:21:17 +0200 Subject: [PATCH 58/88] musl: Decommonize statx definitions from Linux' musl uses different types for the statx fields than the Linux kernel headers, most notably its own uint64_t which is an unsigned long rather than an unsigned long long, so the __u64 definitions would be incompatible from ctest's perspective. (backport ) (cherry picked from commit d2b8ca1f935cd1b9fdc79afbb305a8fbb4ad3ca2) --- src/unix/linux_like/linux/musl/mod.rs | 41 +++++++++++++++++++++++++++ src/unix/linux_like/mod.rs | 6 +--- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index ecb2f830510c9..a41d62ca7a35c 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -193,6 +193,47 @@ s! { _align: [usize; 0], } + // musl's uint64_t is an unsigned long instead of an unsigned long long on + // 64-bit targets, so it's not a __u64 (which is c_ulonglong), but rather a + // real u64. This is also how we handle musl's uint64_t elsewhere. + pub struct statx { + pub stx_mask: u32, + pub stx_blksize: u32, + pub stx_attributes: u64, + pub stx_nlink: u32, + pub stx_uid: u32, + pub stx_gid: u32, + pub stx_mode: u16, + __statx_pad1: Padding<[u16; 1]>, + pub stx_ino: u64, + pub stx_size: u64, + pub stx_blocks: u64, + pub stx_attributes_mask: u64, + pub stx_atime: statx_timestamp, + pub stx_btime: statx_timestamp, + pub stx_ctime: statx_timestamp, + pub stx_mtime: statx_timestamp, + pub stx_rdev_major: u32, + pub stx_rdev_minor: u32, + pub stx_dev_major: u32, + pub stx_dev_minor: u32, + pub stx_mnt_id: u64, + pub stx_dio_mem_align: u32, + pub stx_dio_offset_align: u32, + pub stx_subvol: u64, + pub stx_atomic_write_unit_min: u32, + pub stx_atomic_write_unit_max: u32, + pub stx_atomic_write_segments_max: u32, + __statx_pad2: Padding<[u32; 1]>, + __statx_pad3: Padding<[u64; 9]>, + } + + pub struct statx_timestamp { + pub tv_sec: i64, + pub tv_nsec: u32, + __statx_timestamp_pad1: Padding<[i32; 1]>, + } + pub struct statvfs { pub f_bsize: c_ulong, pub f_frsize: c_ulong, diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index a55cd72a23ded..2274e595149c1 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -267,11 +267,7 @@ cfg_if! { } cfg_if! { - if #[cfg(any( - target_env = "gnu", - target_env = "musl", - target_os = "android", - ))] { + if #[cfg(any(target_env = "gnu", target_os = "android"))] { s! { pub struct statx { pub stx_mask: crate::__u32, From 5af9d72cc2e6b9044d7184597c466d23f6eeb4ab Mon Sep 17 00:00:00 2001 From: Aelin Reidel Date: Sun, 30 Aug 2026 23:26:17 +0200 Subject: [PATCH 59/88] libc-test: Only skip things added in newer musl on old versions With this, we now actually test e.g. statx in libc-test on newer musl versions. (backport ) (cherry picked from commit bd636128c64dc3e27d470b08e0b2701ba7155aa4) --- libc-test/build/main.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 656f1148b97a2..7a9db954db47a 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4560,8 +4560,8 @@ fn test_linux(t: &Target) { // FIXME(musl): Struct has changed for new musl versions "tcp_info" if musl => true, - // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. - "statx" | "statx_timestamp" if musl => true, + // Added in musl 1.2.5 + "statx" | "statx_timestamp" if old_musl => true, // FIXME(musl): New fields in newer versions "utmpx" if !old_musl => true, @@ -5196,15 +5196,14 @@ fn test_linux(t: &Target) { // assume it's a int instead. "getnameinfo" if uclibc => true, - // FIXME(musl): This needs musl 1.2.2 or later, which is newer than what we test with - // on CI. - "gettid" | "reallocarray" if musl => true, + // Added in musl 1.2.2 + "gettid" | "reallocarray" if old_musl => true, // Needs musl 1.2.3 or later. - "pthread_getname_np" if musl => true, + "pthread_getname_np" if old_musl => true, + // Added in musl 1.2.5 + "preadv2" | "pwritev2" if old_musl => true, // Added in musl 1.2.5 - "preadv2" | "pwritev2" if musl => true, - // FIXME(musl): Supported in new musl but we don't have a new enough version in CI. - "statx" if musl => true, + "statx" if old_musl => true, // FIXME(musl): Supported since musl 1.2.6 but not yet in CI. "renameat2" if musl => true, From d6cf90a3834cf2cd33392faf498b7df5d7c9b25e Mon Sep 17 00:00:00 2001 From: telcharr Date: Tue, 4 Aug 2026 19:49:52 -0400 Subject: [PATCH 60/88] macros: forward `cfg` attributes to generated impls (backport ) (cherry picked from commit 5cd4b86818fb219ea11e0a62dc8e3dee9e6481c6) --- src/macros.rs | 312 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 264 insertions(+), 48 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index d82febea32410..c744679ce8e1b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -215,37 +215,26 @@ macro_rules! s_paren { /// Most structs will prefer to use [`s`]. macro_rules! s_no_extra_traits { ($( - $(#[$attr:meta])* + $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* }); + s_no_extra_traits!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( - #[repr(C)] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - )] - $(#[$attr])* - $pub union $i { $($field)* } - - #[allow(deprecated)] - impl ::core::fmt::Debug for $i { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct(::core::stringify!($i)).finish_non_exhaustive() - } + (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( + union_with_debug! { + $(#$attr)* $pub union $i { $($field)* } } ); - (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( #[repr(C)] #[::core::prelude::v1::derive( ::core::clone::Clone, ::core::marker::Copy, ::core::fmt::Debug, )] - $(#[$attr])* + $(#$attr)* $pub struct $i { $($field)* } ); } @@ -253,19 +242,19 @@ macro_rules! s_no_extra_traits { /// Like [`s`], but also generates a `Default` impl for every struct in the block. macro_rules! s_with_default { ($( - $(#[$attr:meta])* + $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_with_default!(it: $(#[$attr])* $pub $t $i { $($field)* }); + s_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( compile_error!( "unions cannot derive extra traits, use s_no_extra_traits_with_default instead" ); ); - (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( struct_with_default! { attrs: { #[repr(C)] @@ -280,7 +269,7 @@ macro_rules! s_with_default { )] #[allow(deprecated)] } - $(#[$attr])* $pub struct $i { $($field)* } + $(#$attr)* $pub struct $i { $($field)* } } ); } @@ -291,29 +280,19 @@ macro_rules! s_with_default { /// union type supplies its own default via `#[custom_default(...)]`. macro_rules! s_no_extra_traits_with_default { ($( - $(#[$attr:meta])* + $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits_with_default!(it: $(#[$attr])* $pub $t $i { $($field)* }); + s_no_extra_traits_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); - (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( - #[repr(C)] - #[::core::prelude::v1::derive( - ::core::clone::Clone, - ::core::marker::Copy, - )] - $(#[$attr])* - $pub union $i { $($field)* } - - impl ::core::fmt::Debug for $i { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct(::core::stringify!($i)).finish_non_exhaustive() - } + (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( + union_with_debug! { + $(#$attr)* $pub union $i { $($field)* } } ); - (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( struct_with_default! { attrs: { #[repr(C)] @@ -323,11 +302,109 @@ macro_rules! s_no_extra_traits_with_default { ::core::fmt::Debug, )] } - $(#[$attr])* $pub struct $i { $($field)* } + $(#$attr)* $pub struct $i { $($field)* } } ); } +/// Emit a union plus its `Debug` impl. +/// +/// Unions can't derive `Debug`, so it is written out here. Attributes are split like +/// [`struct_with_default`] does. Everything goes on the union, but only the `cfg`s are repeated +/// on the impl, otherwise a union that is configured out leaves an impl behind. +macro_rules! union_with_debug { + ( + $(#$attr:tt)* + $vis:vis union $name:ident { $($body:tt)* } + ) => { + union_with_debug! { + @split_attrs + cfg_attrs: { } + other_attrs: { } + remaining_attrs: { $(#$attr)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // a `cfg` also has to gate the impl + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #[cfg($($cfg:tt)*)] + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + union_with_debug! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } + other_attrs: { $($other_attrs)* } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // anything else belongs to the union only + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #$other:tt + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + union_with_debug! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* #$other } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // done + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + )] + $($other_attrs)* + $($cfg_attrs)* + $vis union $name { $($body)* } + + $($cfg_attrs)* + #[allow(deprecated)] + impl ::core::fmt::Debug for $name { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct(::core::stringify!($name)).finish_non_exhaustive() + } + } + }; +} + /// Emit a struct with the given derive attributes plus a generated `Default` impl. /// /// Fields default to `Default::default()`. A field whose default can't be derived must carry @@ -338,17 +415,92 @@ macro_rules! s_no_extra_traits_with_default { /// for `Default`. If it does not exist, `Default::default()` is used instead. In either case, the /// field is added to `processed_fields` with `#[custom_default]` stripped if necessary, and /// `struct_with_default` is invoked again with the remaining fields. +/// +/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields are scanned. Both +/// go on the struct, but only the `cfg`s are repeated on the `Default` impl. A `cfg` decides +/// whether the type exists at all, so without it a configured-out struct leaves an impl behind +/// referring to a type that isn't there. macro_rules! struct_with_default { // entry; `attrs` is the attribute block the caller wants on the struct (repr, derives, etc.), // which is merged with the struct's own attributes. ( attrs: { $($attrs:tt)* } - $(#[$attr:meta])* + $(#$attr:tt)* $vis:vis struct $name:ident { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { } + other_attrs: { } + remaining_attrs: { $($attrs)* $(#$attr)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // a `cfg` also has to gate the impl + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #[cfg($($cfg:tt)*)] + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } + other_attrs: { $($other_attrs)* } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // anything else belongs to the struct only + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #$other:tt + $($tail:tt)* + } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + struct_with_default! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* #$other } + remaining_attrs: { $($tail)* } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // attributes are split, move on to the fields + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } ) => { struct_with_default! { @struct - attrs: { $($attrs)* $(#[$attr])* } + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } vis: { $vis } name: { $name } processed_fields: { } @@ -360,7 +512,8 @@ macro_rules! struct_with_default { // field led by #[custom_default(...)] ( @struct - attrs: { $($attrs:tt)* } + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -374,7 +527,8 @@ macro_rules! struct_with_default { ) => { struct_with_default! { @struct - attrs: { $($attrs)* } + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -389,7 +543,8 @@ macro_rules! struct_with_default { // plain field ( @struct - attrs: { $($attrs:tt)* } + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -402,7 +557,8 @@ macro_rules! struct_with_default { ) => { struct_with_default! { @struct - attrs: { $($attrs)* } + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -417,16 +573,19 @@ macro_rules! struct_with_default { // done ( @struct - attrs: { $($attrs:tt)* } + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } processed_field_defaults: { $($processed_field_defaults:tt)* } remaining_fields: { } ) => { - $($attrs)* + $($other_attrs)* + $($cfg_attrs)* $vis struct $name { $($processed_fields)* } + $($cfg_attrs)* impl ::core::default::Default for $name { // Field attributes (`#[cfg]`, doc comments) get forwarded to the initializer too. // Docs are harmless there but trip the lint, so silence it. @@ -964,6 +1123,31 @@ mod tests { assert_eq!(s.x, 0); assert_eq!(unsafe { s.u.a }, 0); } + + #[test] + fn s_with_default_keeps_struct_cfg() { + // The opposite of the configured-out types in `macro_checks`. With the `cfg` true the + // type and its `Default` both exist, and the other attributes still apply. + s_with_default! { + #[cfg(true)] + #[repr(align(8))] + /// a doc comment + struct EnabledCfg { + a: u32, + #[cfg(target_arch = "x86_64")] + x86_only: u8, + #[custom_default([1; 40])] + buf: [u8; 40], + } + } + + let s = EnabledCfg::default(); + assert_eq!(s.a, 0); + assert_eq!(s.buf, [1u8; 40]); + assert_eq!(align_of::(), 8); + #[cfg(target_arch = "x86_64")] + assert_eq!(s.x86_only, 0); + } } #[cfg(test)] @@ -1040,4 +1224,36 @@ mod macro_checks { assert_impls_default::(); assert_impls_default::(); } + + // Types configured out entirely, checking that the generated impls carry the same `cfg` as + // the type. Without it they fail to compile with "cannot find type". + s_with_default! { + #[cfg(false)] + pub struct S5 { + pub a: u32, + #[custom_default([1; 64])] + pub buf: [u8; 64], + } + } + + s_no_extra_traits! { + #[cfg(false)] + pub union U4 { + pub a: u32, + b: f32, + } + } + + s_no_extra_traits_with_default! { + #[cfg(false)] + pub union U5 { + pub a: u32, + b: f32, + } + + #[cfg(false)] + pub struct S6 { + pub a: u32, + } + } } From f4b41a930a64a7de492e9294842608047b26f624 Mon Sep 17 00:00:00 2001 From: telcharr Date: Tue, 4 Aug 2026 20:22:10 -0400 Subject: [PATCH 61/88] macros: allow deprecated in generated impls (backport ) (cherry picked from commit 43378e5980a96a6278deb1bb733cc2bcc8c4fa63) --- src/macros.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index c744679ce8e1b..587438c5ec869 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -586,6 +586,8 @@ macro_rules! struct_with_default { $vis struct $name { $($processed_fields)* } $($cfg_attrs)* + // The impl names the type and its fields, which warns if either is deprecated. + #[allow(deprecated)] impl ::core::default::Default for $name { // Field attributes (`#[cfg]`, doc comments) get forwarded to the initializer too. // Docs are harmless there but trip the lint, so silence it. @@ -1256,4 +1258,33 @@ mod macro_checks { pub a: u32, } } + + // The generated impls name the type and its fields, so they need to allow deprecation. + // `deny` turns the warning into an error if that ever stops being the case. + mod deprecated_checks { + #![deny(deprecated)] + + s_with_default! { + #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] + pub struct S7 { + pub a: u32, + } + } + + s_no_extra_traits! { + #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] + pub union U6 { + pub a: u32, + b: f32, + } + } + + s_no_extra_traits_with_default! { + #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] + pub union U7 { + pub a: u32, + b: f32, + } + } + } } From 72a74e69a1b75ba3102194ab6a2d3aedba910d76 Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Fri, 28 Aug 2026 20:43:54 +0300 Subject: [PATCH 62/88] glibc: Move `sys/statvfs.h` definitions to `src/new` This follows the ongoing migration into `src/new`, which reduces duplication and models glibc's source tree. The `__f_unused` padding field is only declared on some targets, so it is gated behind a `cfg`. `riscv32` and `riscv64` declared `__f_spare` as pub, which was inconsistent with the other declarations and had no grounded reason to stay, so it is now private. Links: * https://github.com/sailfishos-mirror/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/sysdeps/unix/sysv/linux/bits/statvfs.h * https://github.com/sailfishos-mirror/glibc/blob/04e750e75b73957cf1c791535a3f4319534a52fc/io/sys/statvfs.h (backport ) (cherry picked from commit fc8a345915b2594fbc1e5c8d1cf28648f3bbe852) --- src/new/glibc/mod.rs | 8 +++ src/new/glibc/sys/statvfs.rs | 15 ++++++ .../glibc/sysdeps/unix/linux/bits/statvfs.rs | 53 +++++++++++++++++++ src/new/glibc/sysdeps/unix/linux/mod.rs | 1 + src/new/mod.rs | 2 + src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 16 ------ src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 16 ------ src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 16 ------ src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 16 ------ src/unix/linux_like/linux/gnu/b32/mod.rs | 16 ------ src/unix/linux_like/linux/gnu/b32/powerpc.rs | 16 ------ .../linux_like/linux/gnu/b32/riscv32/mod.rs | 15 ------ .../linux_like/linux/gnu/b32/sparc/mod.rs | 16 ------ src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 16 ------ .../linux_like/linux/gnu/b64/aarch64/mod.rs | 30 ----------- .../linux/gnu/b64/loongarch64/mod.rs | 30 ----------- .../linux_like/linux/gnu/b64/mips64/mod.rs | 30 ----------- .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 30 ----------- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 30 ----------- src/unix/linux_like/linux/gnu/b64/s390x.rs | 30 ----------- .../linux_like/linux/gnu/b64/sparc64/mod.rs | 30 ----------- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 15 ------ .../linux/gnu/b64/x86_64/not_x32.rs | 17 ------ .../linux_like/linux/gnu/b64/x86_64/x32.rs | 17 ------ src/unix/linux_like/mod.rs | 2 + src/unix/mod.rs | 2 + 26 files changed, 83 insertions(+), 402 deletions(-) create mode 100644 src/new/glibc/sys/statvfs.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index c96aec8df79d6..3697b7a07496f 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -24,6 +24,14 @@ mod posix { #[cfg(target_os = "linux")] pub(crate) mod signal; +/// Source directory: `io/sys/` +/// +/// +pub(crate) mod sys { + #[cfg(target_os = "linux")] + pub(crate) mod statvfs; +} + /// Source directory: `sysdeps/` /// /// diff --git a/src/new/glibc/sys/statvfs.rs b/src/new/glibc/sys/statvfs.rs new file mode 100644 index 0000000000000..e1d7cf08e85d0 --- /dev/null +++ b/src/new/glibc/sys/statvfs.rs @@ -0,0 +1,15 @@ +//! Header: `io/sys/statvfs.h` + +pub use super::super::sysdeps::unix::linux::bits::statvfs::*; +use crate::prelude::*; + +extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] + pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] + pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; + // FIXME(1.0,deprecate): lfs binding to be removed + pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs new file mode 100644 index 0000000000000..4de8adcb70867 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs @@ -0,0 +1,53 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/statvfs.h` + +use crate::prelude::*; + +s! { + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + // Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because its + // `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets `__WORDSIZE` to 64. + #[cfg(all( + target_pointer_width = "32", + not(any(target_arch = "x86_64", target_arch = "aarch64")) + ))] + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + // FIXME(riscv32): glibc declares this field on riscv32 too, but we have never + // declared it here. + #[cfg(all( + target_pointer_width = "32", + not(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv32" + )) + ))] + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index 9a50741ff00a0..c4220ae87a885 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -33,6 +33,7 @@ pub(crate) mod bits { path = "../sparc/bits/signum_arch.rs" )] pub(crate) mod signum_arch; + pub(crate) mod statvfs; } /// Directory: `net/` diff --git a/src/new/mod.rs b/src/new/mod.rs index 0ef6b0b53f7c7..d910dccbfdb89 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -201,6 +201,8 @@ cfg_if! { pub use net::route::*; #[cfg(target_env = "gnu")] pub use signal::*; + #[cfg(target_env = "gnu")] + pub use sys::statvfs::*; } else if #[cfg(target_vendor = "apple")] { #[cfg(target_os = "macos")] pub use net::bpf::*; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 5b5cfeca22271..48aa35322e4d9 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -103,22 +103,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index b0afd57333998..aad04df4f820e 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -90,22 +90,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index f3940f4be51c4..5620e49798531 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -90,22 +90,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsblkcnt64_t, - pub f_ffree: crate::fsblkcnt64_t, - pub f_favail: crate::fsblkcnt64_t, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index b05ae5c2ebbf3..87308df6267c0 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -150,22 +150,6 @@ s! { pub f_spare: [c_long; 5], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 2b2efb1e18131..e86b0c469475c 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -125,22 +125,6 @@ cfg_if! { } s! { - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [u32; 9], } diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index b63be98ecaeb2..1cfd9c98187f9 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -132,22 +132,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, #[cfg(gnu_time_bits64)] diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 8a9c597ea0606..f93d92b492be7 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -75,21 +75,6 @@ s! { pub f_spare: [c_long; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], - } - pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index f29605ba51e2b..e9a20895cd788 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -118,22 +118,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 1bed38e18fcfd..c59489c03ffb0 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -177,22 +177,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - __f_unused: Padding, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index f863aa4357685..d4fd8530999d6 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -103,36 +103,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [usize; 8], } diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index add1256ac6d2e..18feea6acaad3 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -101,36 +101,6 @@ s! { pub l_pid: crate::pid_t, } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [c_ulong; 7], } diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index df2b8f9745a74..a383609b8dd12 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -103,36 +103,6 @@ s! { pub f_spare: [c_long; 5], } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [c_ulong; 7], } diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 0f7e065c8532c..b598f885da22a 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -103,36 +103,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [u64; 7], } diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index f473f8c7338c9..1e3cb3e1dda66 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -93,36 +93,6 @@ s! { pub f_spare: [c_long; 4], } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt64_t, - pub f_bfree: crate::fsblkcnt64_t, - pub f_bavail: crate::fsblkcnt64_t, - pub f_files: crate::fsfilcnt64_t, - pub f_ffree: crate::fsfilcnt64_t, - pub f_favail: crate::fsfilcnt64_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - pub __f_spare: [c_int; 6], - } - pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index d94fa32579b3c..0a552868cd0f0 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -130,21 +130,6 @@ s! { __unused5: Padding, } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct __psw_t { pub mask: u64, pub addr: u64, @@ -185,21 +170,6 @@ s! { pub f_flags: c_uint, pub f_spare: [c_uint; 4], } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } } s_no_extra_traits! { diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index dcfc7c442fa0e..48760cb0b6398 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -125,36 +125,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { __size: [u64; 7], } 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 98506315c3712..87350c11f9eaf 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 @@ -123,21 +123,6 @@ s! { pub f_spare: [crate::__fsword_t; 4], } - pub struct statvfs64 { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: u64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: u64, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } - pub struct pthread_attr_t { #[cfg(target_pointer_width = "32")] __size: [u32; 8], diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs index 4c179540436b6..f95bb8729d01b 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -1,22 +1,5 @@ use crate::prelude::*; -s! { - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } -} - pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs index 183eccc43f5e0..41b77f64c1dfc 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -1,22 +1,5 @@ use crate::prelude::*; -s! { - pub struct statvfs { - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, - pub f_flag: c_ulong, - pub f_namemax: c_ulong, - __f_spare: [c_int; 6], - } -} - pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 2274e595149c1..64fea11708e70 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -2113,8 +2113,10 @@ cfg_if! { // FIXME(1.0,deprecate): lfs binding to be removed pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index bf2cd72ea6f61..d0bf81b624671 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1640,8 +1640,10 @@ extern "C" { pub fn sem_wait(sem: *mut sem_t) -> c_int; pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int; + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] // defined in new/glibc #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int; From a07caed7484676ba6082ec979c06b4baff609fc8 Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Sun, 30 Aug 2026 13:50:15 +0300 Subject: [PATCH 63/88] glibc: Add f_type to `statvfs` and `statvfs64` glibc 2.39 allocated one of the six spares to `f_type` of type unsigned int. Links: * https://github.com/sailfishos-mirror/glibc/blob/ef321e23c20eebc6d6fb4044425c00e6df27b05f/sysdeps/unix/sysv/linux/bits/statvfs.h#L75-L76 * https://github.com/sailfishos-mirror/glibc/blob/ef321e23c20eebc6d6fb4044425c00e6df27b05f/sysdeps/unix/sysv/linux/bits/statvfs.h#L54-L55 (backport ) (cherry picked from commit b382bc17a67fa0690e432c8dcfc140b9e3e0b27b) --- libc-test/build/main.rs | 9 ++++++--- src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 7a9db954db47a..4556825e13a67 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -5360,9 +5360,12 @@ fn test_linux(t: &Target) { } // invalid application of 'sizeof' to incomplete type 'long unsigned int[]' ("mcontext_t", "__extcontext") if musl && loongarch64 => true, - // FIXME(#4121): a new field was added from `f_spare` - ("statvfs", "__f_spare") => true, - ("statvfs64", "__f_spare") => true, + // glibc 2.39 took one of the six spares for `f_type` + ("statvfs" | "statvfs64", "f_type" | "__f_spare") + if gnu && versions.glibc.unwrap() < (2, 39) => + { + true + } // the `xsk_tx_metadata_union` field is an anonymous union ("xsk_tx_metadata", "xsk_tx_metadata_union") => true, // After musl 1.2.0, the type becomes `int` instead of `long`. diff --git a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs index 4de8adcb70867..e28684bd1ea2e 100644 --- a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs +++ b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs @@ -22,7 +22,8 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + pub f_type: c_uint, + __f_spare: [c_int; 5], } pub struct statvfs64 { @@ -48,6 +49,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + pub f_type: c_uint, + __f_spare: [c_int; 5], } } From 6c429b0b99fa18d46ff75f8e940caf9ae61d7ae6 Mon Sep 17 00:00:00 2001 From: Ossi Herrala Date: Thu, 4 Dec 2025 13:32:16 +0200 Subject: [PATCH 64/88] bsd: Add missing minherit system call (backport ) (cherry picked from commit 1e49de2fde9419dda53bb01af6892a6b2643e755) --- libc-test/semver/apple.txt | 4 ++++ libc-test/semver/dragonfly.txt | 4 ++++ libc-test/semver/freebsd.txt | 4 ++++ libc-test/semver/netbsd.txt | 5 +++++ libc-test/semver/openbsd.txt | 4 ++++ src/unix/bsd/apple/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/mod.rs | 6 ++++++ src/unix/bsd/mod.rs | 1 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 7 +++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 6 ++++++ 10 files changed, 45 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index e88c7a301a645..e5ee820cc001c 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1558,6 +1558,10 @@ VM_FLAGS_SUPERPAGE_SIZE_ANY VM_FLAGS_USER_ALLOCATE VM_FLAGS_USER_MAP VM_FLAGS_USER_REMAP +VM_INHERIT_COPY +VM_INHERIT_DONATE_COPY +VM_INHERIT_NONE +VM_INHERIT_SHARE VM_LOADAVG VM_MACHFACTOR VM_MAKE_TAG diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 45e67dc8541e1..cef23201ff9c3 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -382,6 +382,10 @@ IFF_SMART IFF_STATICARP IFF_UP IMAXBEL +INHERIT_COPY +INHERIT_NONE +INHERIT_SHARE +INHERIT_ZERO INIT_PROCESS IOV_MAX IPC_CREAT diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index bfed64661a7c2..dd380534a4d35 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -546,6 +546,10 @@ IN6_IFF_NODAD IN6_IFF_PREFER_SOURCE IN6_IFF_TEMPORARY IN6_IFF_TENTATIVE +INHERIT_COPY +INHERIT_NONE +INHERIT_SHARE +INHERIT_ZERO INIT_PROCESS IOV_MAX IPC_CREAT diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index c70af78952e06..44d9380d1260d 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -650,6 +650,11 @@ MAP_ALIGNMENT_MASK MAP_ALIGNMENT_SHIFT MAP_FILE MAP_HASSEMAPHORE +MAP_INHERIT_COPY +MAP_INHERIT_DONATE_COPY +MAP_INHERIT_NONE +MAP_INHERIT_SHARE +MAP_INHERIT_ZERO MAP_NORESERVE MAP_REMAPDUP MAP_RENAME diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index b4d9da0f6f3e9..8e2ca1d9f00b5 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -541,6 +541,10 @@ MAP_CONCEAL MAP_COPY MAP_FILE MAP_HASSEMAPHORE +MAP_INHERIT_COPY +MAP_INHERIT_NONE +MAP_INHERIT_SHARE +MAP_INHERIT_ZERO MAP_NOEXTEND MAP_NORESERVE MAP_RENAME diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 2e1069b12f063..e0d388dc057cd 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3610,6 +3610,10 @@ pub const VM_PROT_NONE: crate::vm_prot_t = 0x00; pub const VM_PROT_READ: crate::vm_prot_t = 0x01; pub const VM_PROT_WRITE: crate::vm_prot_t = 0x02; pub const VM_PROT_EXECUTE: crate::vm_prot_t = 0x04; +pub const VM_INHERIT_SHARE: c_int = 0; +pub const VM_INHERIT_COPY: c_int = 1; +pub const VM_INHERIT_NONE: c_int = 2; +pub const VM_INHERIT_DONATE_COPY: c_int = 3; pub const MEMORY_OBJECT_NULL: crate::memory_object_t = 0; pub const HW_MACHINE: c_int = 1; pub const HW_MODEL: c_int = 2; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4e3b5372cd34c..f1aeb6c5a60f3 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -579,6 +579,12 @@ pub const MAP_ANONYMOUS: c_int = MAP_ANON; pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; +// minherit syscall inherit values +pub const INHERIT_SHARE: c_int = 0; +pub const INHERIT_COPY: c_int = 1; +pub const INHERIT_NONE: c_int = 2; +pub const INHERIT_ZERO: c_int = 3; + pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 426d8df45e7f9..1d408b0a339ed 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -627,6 +627,7 @@ extern "C" { )] pub fn telldir(dirp: *mut crate::DIR) -> c_long; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn minherit(addr: *mut c_void, len: size_t, inherit: c_int) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 2d5b6ee04a451..e4678c1a97810 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1112,6 +1112,13 @@ pub const MAP_ALIGNMENT_64PB: c_int = 56 << MAP_ALIGNMENT_SHIFT; // mremap flag pub const MAP_REMAPDUP: c_int = 0x004; +// minherit syscall inherit values +pub const MAP_INHERIT_SHARE: c_int = 0; +pub const MAP_INHERIT_COPY: c_int = 1; +pub const MAP_INHERIT_NONE: c_int = 2; +pub const MAP_INHERIT_DONATE_COPY: c_int = 3; +pub const MAP_INHERIT_ZERO: c_int = 4; + pub const DCCP_TYPE_REQUEST: c_int = 0; pub const DCCP_TYPE_RESPONSE: c_int = 1; pub const DCCP_TYPE_DATA: c_int = 2; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 7f47da25eaac0..cd6f9854cfb20 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1102,6 +1102,12 @@ pub const MAP_NORESERVE: c_int = 0x0000; pub const MAP_HASSEMAPHORE: c_int = 0x0000; pub const MAP_TRYFIXED: c_int = 0; +// minherit syscall inherit values +pub const MAP_INHERIT_SHARE: c_int = 0; +pub const MAP_INHERIT_COPY: c_int = 1; +pub const MAP_INHERIT_NONE: c_int = 2; +pub const MAP_INHERIT_ZERO: c_int = 3; + pub const EIPSEC: c_int = 82; pub const ENOMEDIUM: c_int = 85; pub const EMEDIUMTYPE: c_int = 86; From 2e788b9ab98c553be4d3cbc03eefb108acfbb651 Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 18 Aug 2026 11:08:03 -0400 Subject: [PATCH 65/88] uclibc: move to configurable external prebuilt toolchain The previous CI script used a prebuilt toolchain from bootlin, but this was based on kernel 5.15, which did not contain many of the kernel constants being tested. (backport ) (cherry picked from commit 131001daac1cb9f81d52d95fd8e52a5326d494b3) --- .../Dockerfile | 23 +++++++++++-------- ci/install-uclibc.sh | 22 ++++++++---------- ci/run-docker.sh | 14 +++++++++-- ci/run.sh | 5 ++++ 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile index a5e685318ad0a..87400a8c0d266 100644 --- a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -1,22 +1,27 @@ -FROM ubuntu:23.10 +FROM ubuntu:26.04 -# FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time -RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ - /etc/apt/sources.list && \ - apt-get update && apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ curl \ - file \ gcc \ libc6-dev \ - patch \ qemu-system-arm \ qemu-user \ + bzip2 \ + gzip \ + cpio \ + unzip \ + rsync \ + bc \ xz-utils -ARG TEST_UCLIBC_TIME64 +# The toolchain URL should point to a compressed buildroot SDK. +# See https://buildroot.org/downloads/manual/manual.html#build-toolchain-with-buildroot +# for how to build one, or see https://github.com/rust-lang/libc/pull/5261 +# for an example toolchain. +ARG UCLIBC_TOOLCHAIN_URL COPY install-uclibc.sh / -RUN /install-uclibc.sh "$TEST_UCLIBC_TIME64" +RUN /install-uclibc.sh "$UCLIBC_TOOLCHAIN_URL" ENV PATH=$PATH:/rust/bin:/toolchain/bin \ STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \ diff --git a/ci/install-uclibc.sh b/ci/install-uclibc.sh index 131f78f2065d0..261b3b2db47e5 100755 --- a/ci/install-uclibc.sh +++ b/ci/install-uclibc.sh @@ -1,20 +1,18 @@ #!/bin/bash # -# Installs the appropriate uclibc toolchain into /toolchain +# Builds a buildroot uclibc toolchain into /buildroot/output/host/ +# +# usage: install-uclibc.sh BUILDROOT_TOOLCHAIN_URL set -eux -time64="$1" - -if [ "${time64:-0}" != "0" ]; then - version='bleeding-edge-2025.08-1' -else - version='bleeding-edge-2024.02-1' # last version with 32-bit time_t -fi +toolchain_url="$1" mkdir /toolchain - -curl --retry 5 -L "https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--${version}.tar.bz2" | -tar xjf - -C /toolchain --strip-components=1 - +curl --retry 5 -L "$toolchain_url" | tar xzf - -C /toolchain --strip-components=1 +if ! [ -f /toolchain/relocate-sdk.sh ]; then + echo "ERROR: toolchain does not contain relocate-sdk.sh, expecting a buildroot SDK." + exit 1 +fi /toolchain/relocate-sdk.sh + diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 288dc2f4c548c..9597ff1f3ca5a 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -27,6 +27,7 @@ if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ]; then fi run() { + export RUSTFLAGS="${RUSTFLAGS:-}" run_target="$1" echo "Building docker container for target $run_target" @@ -41,7 +42,7 @@ run() { # rather than needing two separate jobs. if [[ "$run_target" = *"musl"* ]]; then if [ -n "${TEST_MUSL_V1_2:-}" ]; then - export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2" + RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_musl_v1_2" build_args+=("--build-arg=MUSL_VERSION=new") else build_args+=("--build-arg=MUSL_VERSION=old") @@ -50,8 +51,17 @@ run() { if [ -n "${TEST_UCLIBC_TIME64:-}" ]; then build_args+=("--build-arg=TEST_UCLIBC_TIME64=1") - export RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64" + RUSTFLAGS="$RUSTFLAGS --cfg=libc_unstable_uclibc_time64" fi + if [[ "$run_target" = *-linux-uclibc* ]]; then + if [ "${UCLIBC_TOOLCHAIN_URL:-}" ]; then + build_args+=("--build-arg=UCLIBC_TOOLCHAIN_URL=$UCLIBC_TOOLCHAIN_URL") + else + echo "Expected a URL to a UCLIBC toolchain in \$UCLIBC_TOOLCHAIN_URL" + exit 1 + fi + fi + # use -f so we can use ci/ as build context docker build "${build_args[@]}" diff --git a/ci/run.sh b/ci/run.sh index 61b7e30fd2e9b..9c9775f498326 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -33,6 +33,11 @@ case "$target" in *) cmd="$cmd --workspace" ;; esac +if [ "${LIBC_CI_ZBUILD_STD:-}" ]; then + # ctest test infrastructure has no support for -Zbuild-std + cmd="$cmd --exclude ctest --exclude ctest-test" +fi + env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')" bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')" From d71532f71415b33903921663a4596d8008f7f97e Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 18 Aug 2026 11:08:03 -0400 Subject: [PATCH 66/88] uclibc: time64 support in shmid_ds (backport ) (cherry picked from commit 0f441d28267b0f5c306a9253a085110f0550c085) --- src/unix/linux_like/linux/uclibc/arm/mod.rs | 3 +++ src/unix/linux_like/linux/uclibc/mod.rs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 9d255b7388fcd..f8870d3267294 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -227,10 +227,13 @@ s! { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, pub shm_atime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused1: Padding, pub shm_dtime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused2: Padding, pub shm_ctime: crate::time_t, + #[cfg(not(linux_time_bits64))] __unused3: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index dd54a15e25fb0..4bc4848b429fe 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -133,6 +133,17 @@ s! { pub tcpi_rcv_space: u32, pub tcpi_total_retrans: u32, } + + pub struct mbstate_t { + __mask: crate::wchar_t, + __wc: crate::wchar_t, + } + + pub struct fpos64_t { + __pos: off64_t, + __mbstate: crate::mbstate_t, + __mblen_pending: c_int, + } } impl siginfo_t { From 09ad6e0e7ee6d1c2367aca06f4eb69aacaee1509 Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 18 Aug 2026 11:08:03 -0400 Subject: [PATCH 67/88] uclibc: un-suppress tests for kernel constants from 5.16+ (backport ) (cherry picked from commit 0245f577a6920dfb028e37de60584350082a1641) --- libc-test/build/main.rs | 117 ---------------------------------------- 1 file changed, 117 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 4556825e13a67..556fbd9d43d77 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4733,123 +4733,6 @@ fn test_linux(t: &Target) { if uclibc { match name { - // The canonical uClibc toolchain, bootlin bleeding-edge-2024.02-1, - // uses linux 5.15, so several constants are not available. - - // requires linux 5.16 - "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" - | "PR_SCHED_CORE_SCOPE_THREAD" - | "NF_NETDEV_EGRESS" - | "SO_RESERVE_MEM" => return true, - - // TLS_CIPHER_SM4_[GC]CM requires linux 5.16 - "TLS_CIPHER_SM4_CCM_IV_SIZE" - | "TLS_CIPHER_SM4_CCM_KEY_SIZE" - | "TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE" - | "TLS_CIPHER_SM4_CCM_SALT_SIZE" - | "TLS_CIPHER_SM4_CCM_TAG_SIZE" - | "TLS_CIPHER_SM4_CCM" - | "TLS_CIPHER_SM4_GCM_IV_SIZE" - | "TLS_CIPHER_SM4_GCM_KEY_SIZE" - | "TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE" - | "TLS_CIPHER_SM4_GCM_SALT_SIZE" - | "TLS_CIPHER_SM4_GCM_TAG_SIZE" - | "TLS_CIPHER_SM4_GCM" => return true, - - // requires linux 5.17 - "PR_SET_VMA_ANON_NAME" - | "PR_SET_VMA" - | "RTNLGRP_MCTP_IFADDR" => return true, - - // requires linux 5.18 - "RTNLGRP_STATS" - | "RTNLGRP_TUNNEL" - | "TLS_TX_ZEROCOPY_RO" - | "MADV_DONTNEED_LOCKED" - | "NFQA_PRIORITY" - | "SO_TXREHASH" => return true, - - // requires linux 5.19 - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" - | "NLM_F_BULK" - | "SO_RCVMARK" - | "TLS_INFO_ZC_RO_TX" => return true, - - // CAN_* consts requiring linux 6.0 - "CAN_BUS_OFF_THRESHOLD" - | "CAN_CTRLMODE_TDC_AUTO" - | "CAN_CTRLMODE_TDC_MANUAL" - | "CAN_ERR_CNT" - | "CAN_ERROR_PASSIVE_THRESHOLD" - | "CAN_ERROR_WARNING_THRESHOLD" => return true, - - // requires linux 6.0 - "IFF_NO_CARRIER" - | "TLS_INFO_RX_NO_PAD" - | "TLS_RX_EXPECT_NO_PAD" => return true, - - // CAN_* consts requiring linux 6.1 - "CAN_RAW_XL_FRAMES" - | "CANXL_HDR_SIZE" - | "CANXL_MAX_DLC_MASK" - | "CANXL_MAX_DLC" - | "CANXL_MAX_DLEN" - | "CANXL_MAX_MTU" - | "CANXL_MIN_DLC" - | "CANXL_MIN_DLEN" - | "CANXL_MIN_MTU" - | "CANXL_MTU" - | "CANXL_PRIO_BITS" - | "CANXL_PRIO_MASK" - | "CANXL_SEC" - | "CANXL_XLF" => return true, - - // TLS_CIPHER_ARIA_GCM_* requires linux 6.1 - "TLS_CIPHER_ARIA_GCM_128_IV_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_KEY_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_SALT_SIZE" - | "TLS_CIPHER_ARIA_GCM_128_TAG_SIZE" - | "TLS_CIPHER_ARIA_GCM_128" - | "TLS_CIPHER_ARIA_GCM_256_IV_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_KEY_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_SALT_SIZE" - | "TLS_CIPHER_ARIA_GCM_256_TAG_SIZE" - | "TLS_CIPHER_ARIA_GCM_256" => return true, - - // requires linux 6.2 - "ALG_SET_KEY_BY_KEY_SERIAL" - | "PACKET_FANOUT_FLAG_IGNORE_OUTGOING" - | "SOF_TIMESTAMPING_OPT_ID_TCP" - | "TUN_F_USO4" - | "TUN_F_USO6" => return true, - - // FAN_* consts require kernel 6.3 - "FAN_INFO" - | "FAN_RESPONSE_INFO_AUDIT_RULE" - | "FAN_RESPONSE_INFO_NONE" => return true, - - // requires linux 6.3 - "MFD_EXEC" - | "MFD_NOEXEC_SEAL" - | "PR_GET_MDWE" - | "PR_SET_MDWE" => return true, - - // requires linux 6.4 - "PACKET_VNET_HDR_SZ" => return true, - "PR_GET_MEMORY_MERGE" => return true, - "PR_SET_MEMORY_MERGE" => return true, - - // requires linux 6.5 - "SO_PASSPIDFD" - | "SO_PEERPIDFD" => return true, - - // requires linux 6.6 - "PR_MDWE_NO_INHERIT" - | "PR_MDWE_REFUSE_EXEC_GAIN" => return true, - // defined as a synonym for EM_ARC_COMPACT in gnu but not uclibc "EM_ARC_A5" => return true, From 2f4570d89efd8f18b5a22c15ba16f9140ed12313 Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Tue, 18 Aug 2026 11:08:03 -0400 Subject: [PATCH 68/88] uclibc: fix build failures accumulated via recent commits. (backport ) (cherry picked from commit 65c8d2c132071bd7eaf76af812f660338f1319c6) --- src/unix/linux_like/linux/mod.rs | 2 +- src/unix/linux_like/linux_l4re_shared.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 2dbcb069c8abd..031da59951c08 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1011,7 +1011,7 @@ s! { } cfg_if! { - if #[cfg(not(target_env = "gnu"))] { + if #[cfg(not(any(target_env = "gnu", target_env = "uclibc")))] { extern_ty! { // FIXME(1.0,deprecate): lfs binding to be removed pub type fpos64_t; // FIXME(linux): fill this out with a struct diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 1f4a760ebab6c..f8a0b45e610cd 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -795,7 +795,6 @@ pub const EM_M32R: u16 = 88; pub const EM_MN10300: u16 = 89; pub const EM_MN10200: u16 = 90; pub const EM_PJ: u16 = 91; -#[cfg(not(target_env = "uclibc"))] pub const EM_OPENRISC: u16 = 92; #[cfg(target_env = "uclibc")] pub const EM_OR1K: u16 = 92; @@ -876,7 +875,6 @@ pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value // wherever it is defined. pub const AT_SYSINFO_EHDR: c_ulong = 33; -#[cfg(not(target_env = "uclibc"))] pub const AT_MINSIGSTKSZ: c_ulong = 51; pub const GLOB_ERR: c_int = 1 << 0; From 468606eb6662fbbc4bc34652c875eac6bfb6bd83 Mon Sep 17 00:00:00 2001 From: Jonah Petri Date: Wed, 19 Aug 2026 10:49:05 -0400 Subject: [PATCH 69/88] uclibc: inhibit test of IPPROTO_MAX for now (backport ) (cherry picked from commit 6ac03f4ea4661dc274d495def3afe348ce741156) --- libc-test/build/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 556fbd9d43d77..3700be8fef6bd 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -4776,6 +4776,10 @@ fn test_linux(t: &Target) { | "UDP_GRO" | "UDP_SEGMENT" => return true, + // FIXME: once uclibc catches up with the kernel headers, remove. + // See https://github.com/rust-lang/libc/issues/1896 + "IPPROTO_MAX" => return true, + _ => (), } } From a3b9e4abdbc5bf7e82d35f20f367e8b8bedad551 Mon Sep 17 00:00:00 2001 From: Sang Woo Kim Date: Wed, 22 Jul 2026 05:02:00 +0000 Subject: [PATCH 70/88] newlib: fix RTEMS socket address definitions and constants RTEMS was using the generic ARM socket address layout, which does not match its FreeBSD-derived socket API. As a result, std could not parse addresses returned by local_addr, accept, and recv_from. Use the correct RTEMS socket address definitions and update 27 constants to their FreeBSD values. Header sources (newlib as built by the RTEMS 6 RSB, gitlab.rtems.org/contrib/newlib-cygwin @ 1b3dcfdc6f1f): https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/socket.h#L322 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/netinet/in.h#L98 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/netinet6/in6.h#L121 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/un.h#L58 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/_sockaddr_storage.h#L41-53 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/socket.h#L246 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/netinet/in.h#L424 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/netinet/tcp.h#L168 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/poll.h#L65 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/filio.h#L50 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/sys/_termios.h#L78 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/sys/rtems/include/netdb.h#L156 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/include/sys/_default_fcntl.h#L63 https://gitlab.rtems.org/contrib/newlib-cygwin/-/blob/1b3dcfdc6f1fd2bd3e1ef2f8b7df736c076c6042/newlib/libc/include/sys/select.h#L34 (backport ) (cherry picked from commit b6d27323f0750d396d4cbfd77f80439b88b8874e) --- src/unix/newlib/arm/mod.rs | 52 ------------------------------- src/unix/newlib/mod.rs | 58 ++++++++++++++++++++++++----------- src/unix/newlib/rtems/mod.rs | 59 ++++++++++++++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 73 deletions(-) delete mode 100644 src/unix/newlib/arm/mod.rs diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs deleted file mode 100644 index a559cf4da59fd..0000000000000 --- a/src/unix/newlib/arm/mod.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::prelude::*; - -pub type clock_t = c_long; -pub type wchar_t = u32; - -s! { - pub struct sockaddr { - pub sa_family: crate::sa_family_t, - pub sa_data: [c_char; 14], - } - - pub struct sockaddr_in6 { - pub sin6_family: crate::sa_family_t, - pub sin6_port: crate::in_port_t, - pub sin6_flowinfo: u32, - pub sin6_addr: crate::in6_addr, - pub sin6_scope_id: u32, - } - - pub struct sockaddr_in { - pub sin_family: crate::sa_family_t, - pub sin_port: crate::in_port_t, - pub sin_addr: crate::in_addr, - pub sin_zero: [u8; 8], - } - - pub struct sockaddr_storage { - pub ss_family: crate::sa_family_t, - __ss_padding: Padding<[u8; 26]>, - } -} - -pub const AF_INET6: c_int = 23; - -pub const FIONBIO: c_ulong = 1; - -pub const POLLIN: c_short = 0x1; -pub const POLLPRI: c_short = 0x2; -pub const POLLHUP: c_short = 0x4; -pub const POLLERR: c_short = 0x8; -pub const POLLOUT: c_short = 0x10; -pub const POLLNVAL: c_short = 0x20; - -pub const SOL_SOCKET: c_int = 65535; - -pub const MSG_OOB: c_int = 1; -pub const MSG_PEEK: c_int = 2; -pub const MSG_DONTWAIT: c_int = 4; -pub const MSG_DONTROUTE: c_int = 0; -pub const MSG_WAITALL: c_int = 0; -pub const MSG_MORE: c_int = 0; -pub const MSG_NOSIGNAL: c_int = 0; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ab12da1d6fe08..27df1ada596d1 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -369,6 +369,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { cfg_if! { if #[cfg(target_os = "espidf")] { pub const NCCS: usize = 11; + } else if #[cfg(target_os = "rtems")] { + pub const NCCS: usize = 20; } else { pub const NCCS: usize = 32; } @@ -428,7 +430,7 @@ pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; cfg_if! { if #[cfg(any(target_os = "horizon", target_os = "espidf"))] { pub const FD_SETSIZE: usize = 64; - } else if #[cfg(target_os = "vita")] { + } else if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const FD_SETSIZE: usize = 256; } else { pub const FD_SETSIZE: usize = 1024; @@ -560,7 +562,7 @@ pub const O_NONBLOCK: c_int = 16384; pub const O_ACCMODE: c_int = 3; cfg_if! { - if #[cfg(target_os = "espidf")] { + if #[cfg(any(target_os = "espidf", target_os = "rtems"))] { pub const O_CLOEXEC: c_int = 0x40000; } else { pub const O_CLOEXEC: c_int = 0x80000; @@ -606,6 +608,8 @@ pub const PF_INET: c_int = 2; cfg_if! { if #[cfg(target_os = "espidf")] { pub const PF_INET6: c_int = 10; + } else if #[cfg(target_os = "rtems")] { + pub const PF_INET6: c_int = 28; } else { pub const PF_INET6: c_int = 23; } @@ -667,7 +671,13 @@ cfg_if! { } pub const SO_TYPE: c_int = 0x1008; -pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub const SOCK_CLOEXEC: c_int = 0x10000000; + } else { + pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + } +} pub const INET_ADDRSTRLEN: c_int = 16; @@ -691,7 +701,7 @@ pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const TCP_NODELAY: c_int = 1; pub const TCP_MAXSEG: c_int = 2; } else if #[cfg(target_os = "espidf")] { @@ -727,7 +737,7 @@ cfg_if! { } } cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const IP_TTL: c_int = 4; } else if #[cfg(target_os = "espidf")] { pub const IP_TTL: c_int = 2; @@ -749,7 +759,7 @@ cfg_if! { } cfg_if! { - if #[cfg(target_os = "vita")] { + if #[cfg(any(target_os = "vita", target_os = "rtems"))] { pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; } else if #[cfg(target_os = "espidf")] { @@ -784,6 +794,11 @@ cfg_if! { pub const NO_DATA: c_int = 211; pub const NO_RECOVERY: c_int = 212; pub const TRY_AGAIN: c_int = 213; + } else if #[cfg(target_os = "rtems")] { + pub const HOST_NOT_FOUND: c_int = 1; + pub const TRY_AGAIN: c_int = 2; + pub const NO_RECOVERY: c_int = 3; + pub const NO_DATA: c_int = 4; } else { pub const HOST_NOT_FOUND: c_int = 1; pub const NO_DATA: c_int = 2; @@ -791,7 +806,13 @@ cfg_if! { pub const TRY_AGAIN: c_int = 4; } } -pub const NO_ADDRESS: c_int = 2; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub const NO_ADDRESS: c_int = NO_DATA; + } else { + pub const NO_ADDRESS: c_int = 2; + } +} pub const AI_PASSIVE: c_int = 1; pub const AI_CANONNAME: c_int = 2; @@ -800,6 +821,9 @@ cfg_if! { if #[cfg(target_os = "espidf")] { pub const AI_NUMERICSERV: c_int = 8; pub const AI_ADDRCONFIG: c_int = 64; + } else if #[cfg(target_os = "rtems")] { + pub const AI_NUMERICSERV: c_int = 0x00000008; + pub const AI_ADDRCONFIG: c_int = 0x00000400; } else { pub const AI_NUMERICSERV: c_int = 0; pub const AI_ADDRCONFIG: c_int = 0; @@ -812,7 +836,7 @@ pub const NI_NOFQDN: c_int = 1; pub const NI_NUMERICHOST: c_int = 2; pub const NI_NAMEREQD: c_int = 4; cfg_if! { - if #[cfg(target_os = "espidf")] { + if #[cfg(any(target_os = "espidf", target_os = "rtems"))] { pub const NI_NUMERICSERV: c_int = 8; pub const NI_DGRAM: c_int = 16; } else { @@ -828,6 +852,11 @@ cfg_if! { pub const EAI_MEMORY: c_int = 203; pub const EAI_NONAME: c_int = 200; pub const EAI_SOCKTYPE: c_int = 10; + } else if #[cfg(target_os = "rtems")] { + pub const EAI_FAMILY: c_int = 5; + pub const EAI_MEMORY: c_int = 6; + pub const EAI_NONAME: c_int = 8; + 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; @@ -978,17 +1007,10 @@ cfg_if! { } else if #[cfg(target_os = "vita")] { mod vita; pub use self::vita::*; - } else if #[cfg(target_arch = "arm")] { - mod arm; - pub use self::arm::*; - } else { - core::compile_error!("unsupported target"); - } -} - -cfg_if! { - if #[cfg(target_os = "rtems")] { + } else if #[cfg(target_os = "rtems")] { mod rtems; pub use self::rtems::*; + } else { + core::compile_error!("unsupported target"); } } diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index 9ed423096e8db..ee98e91fdbe50 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -1,15 +1,68 @@ -// defined in architecture specific module - use crate::prelude::*; +pub type clock_t = c_long; +pub type wchar_t = u32; + s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + pub struct sockaddr_un { + pub sun_len: u8, pub sun_family: crate::sa_family_t, - pub sun_path: [c_char; 108usize], + pub sun_path: [c_char; 104usize], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 112]>, } } pub const AF_UNIX: c_int = 1; +pub const AF_INET6: c_int = 28; + +pub const FIONBIO: c_ulong = 0x8004667e; + +pub const POLLIN: c_short = 0x0001; +pub const POLLPRI: c_short = 0x0002; +pub const POLLOUT: c_short = 0x0004; +pub const POLLERR: c_short = 0x0008; +pub const POLLHUP: c_short = 0x0010; +pub const POLLNVAL: c_short = 0x0020; + +pub const SOL_SOCKET: c_int = 0xffff; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_NOSIGNAL: c_int = 0x20000; +pub const MSG_MORE: c_int = 0; pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; From ade37a1da8066b6f0fda54f13baa54d39d97e742 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 31 Aug 2026 03:50:45 -0500 Subject: [PATCH 71/88] ci: Don't have renovate pin Docker digests Avoid PRs such as [1] changing numbered tags to a codename and date. [1]: https://github.com/rust-lang/libc/pull/5428 (backport ) (cherry picked from commit 8bb320dac5ce760978bc48d3d1829bd128339bd6) --- .github/renovate.json5 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 7d18fd573d6d8..6ce8de556d5b4 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -24,6 +24,11 @@ // Every month schedule: "* 0 1 * *", groupName: "Github Actions", + }, + { + // Don't updates such as 23.10 -> mantic-20240530 + "matchDatasources": ["docker"], + "pinDigests": false } ], // Receive any update that fixes security vulnerabilities. From be46134359d8df815058915d0a456cfd233ed409 Mon Sep 17 00:00:00 2001 From: Sang Woo Kim Date: Mon, 31 Aug 2026 15:44:45 +0900 Subject: [PATCH 72/88] newlib: correct RTEMS scalar type widths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RTEMS's newlib defines these in : __dev_t, __ino_t and _CLOCK_T_ as __uint64_t, __rlim_t as __int64_t, _CLOCKID_T_ as int — where this tree has them 32-bit, and clockid_t unsigned. Verified with _Static_assert under both arm-rtems6-gcc and arm-rtems7-gcc. Source: https://github.com/RTEMS/sourceware-mirror-newlib-cygwin/blob/7d4336cf6e519c2a4c9baac10da7a785d88d30c5/newlib/libc/sys/rtems/include/machine/_types.h#L12-L39 (backport ) (cherry picked from commit 7c1cc59f2fec89c87c1a5908b5435effc8fbeb77) --- src/unix/newlib/mod.rs | 20 ++++++++++++++++++-- src/unix/newlib/rtems/mod.rs | 4 +++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 27df1ada596d1..933bc2eb8f6f3 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -3,13 +3,23 @@ use crate::prelude::*; pub type blkcnt_t = i32; pub type blksize_t = i32; -pub type clockid_t = c_ulong; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub type clockid_t = c_int; + } else { + pub type clockid_t = c_ulong; + } +} cfg_if! { if #[cfg(any(target_os = "espidf", target_os = "vita"))] { pub type dev_t = c_short; pub type ino_t = c_ushort; pub type off_t = c_long; + } else if #[cfg(target_os = "rtems")] { + pub type dev_t = u64; + pub type ino_t = u64; + pub type off_t = i64; } else if #[cfg(any(target_arch = "arm", target_arch = "powerpc"))] { pub type dev_t = u32; pub type ino_t = u32; @@ -29,7 +39,13 @@ pub type nfds_t = u32; pub type nlink_t = c_ushort; pub type pthread_t = c_ulong; pub type pthread_key_t = c_uint; -pub type rlim_t = u32; +cfg_if! { + if #[cfg(target_os = "rtems")] { + pub type rlim_t = i64; + } else { + pub type rlim_t = u32; + } +} cfg_if! { if #[cfg(target_os = "horizon")] { diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index ee98e91fdbe50..71405e2c3a942 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -1,6 +1,8 @@ use crate::prelude::*; -pub type clock_t = c_long; +// RTEMS defines `clock_t` as `__uint64_t` (`` via +// ``), not `long` as plain newlib arm targets did. +pub type clock_t = u64; pub type wchar_t = u32; s! { From cdac462086f44e538be0aa96c7569e6d71bbecdd Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Wed, 26 Aug 2026 14:22:12 +0200 Subject: [PATCH 73/88] Fix unspecified transmute between slice types The layout of slices is currently not specified in Rust. This PR replaces a `transmute` between slices of different types with the equivalent pointer cast to keep all involved behaviour specified. (backport ) (cherry picked from commit 86216b9d968c92a78edf2161c84a70b40347326a) --- src/types.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 7be6e78bce3fe..02bb2d33ce890 100644 --- a/src/types.rs +++ b/src/types.rs @@ -117,8 +117,10 @@ pub(crate) const fn u32_cast_ioctl(x: u32) -> crate::Ioctl { #[allow(unused)] pub(crate) const fn u8_slice_cast_char_slice(x: &[u8]) -> &[c_char] { assert!(size_of::() == size_of::()); + let len = x.len(); + let ptr = x.as_ptr(); // SAFETY: same repr, possibly just a sign cast - unsafe { mem::transmute::<&[u8], &[c_char]>(x) } + unsafe { core::slice::from_raw_parts(ptr.cast::(), len) } } /// Replace bytes in an array with those from a slice. This is a polyfill for `[T]::copy_from_slice` From 35071c9488fdfc0fd950904276e97acce0d0b6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Mon, 31 Aug 2026 12:21:08 +0200 Subject: [PATCH 74/88] musl: Add `*_SUPER_MAGIC` constants IIUC, they were not added as part of https://github.com/rust-lang/libc/pull/2639 because Musl kernel headers were too old. (backport ) (cherry picked from commit 4db6d7303a7bd3a2436851b6a5d7782446329942) --- src/unix/linux_like/linux/gnu/mod.rs | 13 ------------- src/unix/linux_like/linux/mod.rs | 14 ++++++++++++++ src/unix/linux_like/linux/uclibc/mod.rs | 6 ------ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index f36ec9ad51eda..53fb72eb5632f 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -766,19 +766,6 @@ pub const O_ACCMODE: c_int = 3; pub const ST_RELATIME: c_ulong = 4096; pub const NI_MAXHOST: crate::socklen_t = 1025; -// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the -// following are only available on newer Linux versions than the versions -// currently used in CI in some configurations, so we define them here. -cfg_if! { - if #[cfg(not(target_arch = "s390x"))] { - pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; - pub const XFS_SUPER_MAGIC: c_long = 0x58465342; - } else if #[cfg(target_arch = "s390x")] { - pub const BINDERFS_SUPER_MAGIC: c_uint = 0x6c6f6f70; - pub const XFS_SUPER_MAGIC: c_uint = 0x58465342; - } -} - pub const CPU_SETSIZE: c_int = 0x400; pub const PTRACE_TRACEME: c_uint = 0; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 031da59951c08..e6f05ce4d5752 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2557,6 +2557,20 @@ pub const IN_ONLYDIR: u32 = 0x0100_0000; pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; +// uapi/linux/magic.h +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. +cfg_if! { + if #[cfg(not(target_arch = "s390x"))] { + pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; + pub const XFS_SUPER_MAGIC: c_long = 0x58465342; + } else if #[cfg(target_arch = "s390x")] { + pub const BINDERFS_SUPER_MAGIC: c_uint = 0x6c6f6f70; + pub const XFS_SUPER_MAGIC: c_uint = 0x58465342; + } +} + // uapi/linux/securebits.h const SECURE_NOROOT: c_int = 0; const SECURE_NOROOT_LOCKED: c_int = 1; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 4bc4848b429fe..d7a904979511a 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -229,12 +229,6 @@ pub const MCL_ONFAULT: c_int = 0x0004; pub const AF_VSOCK: c_int = 40; -// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the -// following are only available on newer Linux versions than the versions -// currently used in CI in some configurations, so we define them here. -pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; -pub const XFS_SUPER_MAGIC: c_long = 0x58465342; - pub const PTRACE_TRACEME: c_int = 0; pub const PTRACE_PEEKTEXT: c_int = 1; pub const PTRACE_PEEKDATA: c_int = 2; From 90c8443a550d20c68e283ad7dc7eca0eddb879e1 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Fri, 28 Aug 2026 16:28:36 +0200 Subject: [PATCH 75/88] crate: use `Padding` in private padding fields Replace the types of private padding fields with our custom `Padding` type. This has been in use for some time, but there are still remnants left from before the `Padding` type was a thing. (backport ) (cherry picked from commit 7aa1dbc47110c8b97ac892b7d0841d125356204e) --- src/fuchsia/mod.rs | 6 ++-- src/new/apple/xnu/mach/i386/_structs.rs | 2 +- .../glibc/sysdeps/unix/linux/bits/statvfs.rs | 13 ++++---- .../sysdeps/unix/linux/mips/bits/sigaction.rs | 2 +- src/new/linux_uapi/linux/can.rs | 6 ++-- src/new/netbsd/sys/statvfs.rs | 2 +- src/unix/bsd/apple/mod.rs | 2 +- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 10 +++--- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 4 +-- .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 4 +-- .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 4 +-- .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 4 +-- .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 4 +-- src/unix/bsd/freebsdlike/freebsd/mod.rs | 32 +++++++++---------- src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 2 +- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 ++-- src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 2 +- src/unix/linux_like/android/b64/mod.rs | 2 +- src/unix/linux_like/emscripten/mod.rs | 2 +- src/unix/linux_like/l4re/uclibc/mod.rs | 8 ++--- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 2 +- .../linux_like/linux/gnu/b32/sparc/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 2 +- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 2 +- .../linux_like/linux/gnu/b64/mips64/mod.rs | 2 +- .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 2 +- src/unix/linux_like/linux/gnu/b64/s390x.rs | 2 +- .../linux_like/linux/gnu/b64/sparc64/mod.rs | 2 +- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 2 +- src/unix/linux_like/linux/mod.rs | 2 +- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 2 +- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 2 +- src/unix/linux_like/linux/musl/mod.rs | 2 +- src/unix/linux_like/linux/uclibc/arm/mod.rs | 2 +- .../linux/uclibc/mips/mips32/mod.rs | 2 +- .../linux/uclibc/mips/mips64/mod.rs | 2 +- src/unix/linux_like/linux/uclibc/mod.rs | 2 +- .../linux_like/linux/uclibc/x86_64/mod.rs | 8 ++--- src/unix/nto/mod.rs | 2 +- src/unix/nto/neutrino.rs | 4 +-- src/unix/solarish/solaris.rs | 2 +- 45 files changed, 88 insertions(+), 87 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index b4765b7057f21..57ee24142aadc 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -319,9 +319,9 @@ s! { __next: *mut c_void, __prev: *mut c_void, #[cfg(target_pointer_width = "32")] - __dummy4: [c_char; 24], + __dummy4: Padding<[c_char; 24]>, #[cfg(target_pointer_width = "64")] - __dummy4: [c_char; 16], + __dummy4: Padding<[c_char; 16]>, } // FIXME(1.0): This should not implement `PartialEq` @@ -786,7 +786,7 @@ s! { pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct stack_t { diff --git a/src/new/apple/xnu/mach/i386/_structs.rs b/src/new/apple/xnu/mach/i386/_structs.rs index 15822f7710de8..2c4fecf178e72 100644 --- a/src/new/apple/xnu/mach/i386/_structs.rs +++ b/src/new/apple/xnu/mach/i386/_structs.rs @@ -86,7 +86,7 @@ s! { pub __fpu_xmm15: __darwin_xmm_reg, // FIXME(apple): this field is actually [u8; 96], but defining it with a bigger type allows // us to auto-implement traits for it since the length of the array is less than 32 - __fpu_rsrv4: [u32; 24], + __fpu_rsrv4: Padding<[u32; 24]>, pub __fpu_reserved1: c_int, } } diff --git a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs index e28684bd1ea2e..03fc1ac847278 100644 --- a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs +++ b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs @@ -13,8 +13,9 @@ s! { pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, pub f_fsid: c_ulong, - // Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because its - // `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets `__WORDSIZE` to 64. + // Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because + // its `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets + // `__WORDSIZE` to 64. #[cfg(all( target_pointer_width = "32", not(any(target_arch = "x86_64", target_arch = "aarch64")) @@ -23,7 +24,7 @@ s! { pub f_flag: c_ulong, pub f_namemax: c_ulong, pub f_type: c_uint, - __f_spare: [c_int; 5], + __f_spare: Padding<[c_int; 5]>, } pub struct statvfs64 { @@ -36,8 +37,8 @@ s! { pub f_ffree: u64, pub f_favail: u64, pub f_fsid: c_ulong, - // FIXME(riscv32): glibc declares this field on riscv32 too, but we have never - // declared it here. + // FIXME(riscv32): glibc declares this field on riscv32 too, but we have + // never declared it here. #[cfg(all( target_pointer_width = "32", not(any( @@ -50,6 +51,6 @@ s! { pub f_flag: c_ulong, pub f_namemax: c_ulong, pub f_type: c_uint, - __f_spare: [c_int; 5], + __f_spare: Padding<[c_int; 5]>, } } diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs index 408da96204e41..344b386acf4b5 100644 --- a/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/sigaction.rs @@ -12,7 +12,7 @@ s! { pub sa_mask: crate::sigset_t, pub sa_restorer: Option, #[cfg(target_pointer_width = "32")] - _resv: [c_int; 1], + _resv: Padding<[c_int; 1]>, } } diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index d50523c12e82d..989e854c45270 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -44,7 +44,7 @@ s_with_default! { // FIXME(1.0): this field was renamed to `len` in Linux 5.11 pub can_dlc: u8, __pad: Padding, - __res0: u8, + __res0: Padding, pub len8_dlc: u8, pub data: [u8; CAN_MAX_DLEN], } @@ -60,8 +60,8 @@ s_with_default! { pub can_id: canid_t, pub len: u8, pub flags: u8, - __res0: u8, - __res1: u8, + __res0: Padding, + __res1: Padding, #[custom_default([0; CANFD_MAX_DLEN])] pub data: [u8; CANFD_MAX_DLEN], } diff --git a/src/new/netbsd/sys/statvfs.rs b/src/new/netbsd/sys/statvfs.rs index eee3766300ce6..2e8fe5e202164 100644 --- a/src/new/netbsd/sys/statvfs.rs +++ b/src/new/netbsd/sys/statvfs.rs @@ -36,7 +36,7 @@ s! { pub f_owner: crate::uid_t, // This type is updated in a future version - f_spare: [u32; 4], + f_spare: Padding<[u32; 4]>, pub f_fstypename: [c_char; _VFS_NAMELEN], pub f_mntonname: [c_char; _VFS_MNAMELEN], diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index e0d388dc057cd..c8bd71179efeb 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -661,7 +661,7 @@ s! { /// Current SVGID on process. pub pbsi_svgid: crate::gid_t, /// Reserved for future use. - pbsi_rfu: u32, + pbsi_rfu: Padding, } #[cfg(target_os = "macos")] diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index cbe02efd58ae9..95f7e305e4577 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -339,7 +339,7 @@ s! { pub kp_auxflags: c_int, pub kp_lwp: crate::kinfo_lwp, pub kp_ktaddr: crate::uintptr_t, - kp_spare: [c_int; 2], + kp_spare: Padding<[c_int; 2]>, } pub struct cpuctl_msr_args_t { @@ -397,7 +397,7 @@ s! { } pub struct statfs { - __spare2: c_long, + __spare2: Padding, pub f_bsize: c_long, pub f_iosize: c_long, pub f_blocks: c_long, @@ -415,10 +415,10 @@ s! { pub f_mntonname: [c_char; 80], pub f_syncreads: c_long, pub f_asyncreads: c_long, - __spares1: c_short, + __spares1: Padding, pub f_mntfromname: [c_char; 80], - __spares2: c_short, - __spare: [c_long; 2], + __spares2: Padding, + __spare: Padding<[c_long; 2]>, } pub struct sigevent { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 91fb88d1b0605..4b6e184dd4c4c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -234,11 +234,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], // Array length changed from 88 to 1024 in FreeBSD 12: pub f_mntfromname: [c_char; 88], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index eebf3cba8bde5..36244d162b2dc 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -281,11 +281,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 39c01538701b6..e9be37bec742e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -294,11 +294,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index a84c185488ca3..29c7a86b098dd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -296,11 +296,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 08f9e5e43e6b5..026abe1d50f94 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -298,11 +298,11 @@ s! { pub f_asyncwrites: u64, pub f_syncreads: u64, pub f_asyncreads: u64, - f_spare: [u64; 10], + f_spare: Padding<[u64; 10]>, pub f_namemax: u32, pub f_owner: crate::uid_t, pub f_fsid: crate::fsid_t, - f_charspare: [c_char; 80], + f_charspare: Padding<[c_char; 80]>, pub f_fstypename: [c_char; 16], pub f_mntfromname: [c_char; 1024], pub f_mntonname: [c_char; 1024], diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3321a64e8844f..4a72335df97c2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -258,14 +258,14 @@ s! { pub aio_offset: off_t, pub aio_buf: *mut c_void, pub aio_nbytes: size_t, - __unused1: [c_int; 2], - __unused2: *mut c_void, + __unused1: Padding<[c_int; 2]>, + __unused2: Padding<*mut c_void>, pub aio_lio_opcode: c_int, pub aio_reqprio: c_int, // unused 3 through 5 are the __aiocb_private structure - __unused3: c_long, - __unused4: c_long, - __unused5: *mut c_void, + __unused3: Padding, + __unused4: Padding, + __unused5: Padding<*mut c_void>, pub aio_sigevent: sigevent, } @@ -438,14 +438,14 @@ s! { m_rb_link: crate::uintptr_t, #[cfg(target_pointer_width = "32")] m_pad: Padding, - m_spare: [u32; 2], + m_spare: Padding<[u32; 2]>, } pub struct ucond { c_has_waiters: u32, c_flags: u32, c_clockid: u32, - c_spare: [u32; 1], + c_spare: Padding<[u32; 1]>, } pub struct uuid { @@ -505,9 +505,9 @@ s! { #[cfg(not(freebsd11))] pub kve_vn_rdev: u64, #[cfg(not(freebsd11))] - _kve_is_spare: [c_int; 8], + _kve_is_spare: Padding<[c_int; 8]>, #[cfg(freebsd11)] - _kve_is_spare: [c_int; 12], + _kve_is_spare: Padding<[c_int; 12]>, pub kve_path: [[c_char; 32]; 32], } @@ -1665,9 +1665,9 @@ s! { _priv: [u8; 304], // FIXME(freebsd): this is really a giant union pub kf_status: u16, _kf_pad1: Padding, - _kf_ispare0: c_int, + _kf_ispare0: Padding, pub kf_cap_rights: crate::cap_rights_t, - _kf_cap_spare: u64, + _kf_cap_spare: Padding, pub kf_path: [c_char; crate::PATH_MAX as usize], } } @@ -1733,17 +1733,17 @@ s_no_extra_traits! { pub uc_link: *mut crate::ucontext_t, pub uc_stack: crate::stack_t, pub uc_flags: c_int, - __spare__: [c_int; 4], + __spare__: Padding<[c_int; 4]>, } #[repr(align(8))] pub struct xinpgen { pub xig_len: ksize_t, pub xig_count: u32, - _xig_spare32: u32, + _xig_spare32: Padding, pub xig_gen: inp_gen_t, pub xig_sogen: so_gen_t, - _xig_spare64: [u64; 4], + _xig_spare64: Padding<[u64; 4]>, } pub struct in_addr_4in6 { @@ -1775,8 +1775,8 @@ s_no_extra_traits! { // Note: this field is called `gen` in upstream FreeBSD, but `gen` is // reserved keyword in Rust since the 2024 Edition, hence `gennum`. pub gennum: u64, - _rsrv1: [u64; 8], - _rsrv2: [u32; 8], + _rsrv1: Padding<[u64; 8]>, + _rsrv2: Padding<[u32; 8]>, pub iv: [u8; 32], pub cipher_algorithm: i32, pub auth_algorithm: i32, diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index e0206af04f8f1..c429dd78c0f1f 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -14,7 +14,7 @@ s! { pub struct mcontext_t { pub __gregs: [crate::greg_t; 32], pub __fregs: __fregset, - __spare: [crate::greg_t; 8], + __spare: Padding<[crate::greg_t; 8]>, } pub struct ucontext_t { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index e4678c1a97810..6d17b6cda50bc 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -263,7 +263,7 @@ s! { ptm_owner: crate::pthread_t, ptm_waiters: *mut u8, ptm_recursed: c_uint, - ptm_spare2: *mut c_void, + ptm_spare2: Padding<*mut c_void>, } pub struct pthread_mutexattr_t { @@ -1341,7 +1341,7 @@ cfg_if! { ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: ptr::null_mut(), + ptm_spare2: Padding::new(ptr::null_mut()), }; } else { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { @@ -1351,7 +1351,7 @@ cfg_if! { ptm_waiters: ptr::null_mut(), ptm_owner: 0, ptm_recursed: 0, - ptm_spare2: ptr::null_mut(), + ptm_spare2: Padding::new(ptr::null_mut()), }; } } diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 05c0cd55cb80d..d4832b0883484 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -17,7 +17,7 @@ s! { pub struct mcontext_t { pub __gregs: __gregset_t, pub __fregs: __fregset_t, - __spare: [crate::__greg_t; 7], + __spare: Padding<[crate::__greg_t; 7]>, } } diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index c8df732d5a2b6..e3c14ee1d08ef 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -109,7 +109,7 @@ s! { pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct pthread_barrier_t { diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 3a2fddcf03b4a..6d1d9f27d1da2 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -112,7 +112,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct signalfd_siginfo { diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index 5d819e0212a68..cced9a7be4408 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -237,7 +237,7 @@ s! { pub struct pthread_cond_t { __c_lock: _pthread_fastlock, __c_waiting: _pthread_descr, - __padding: [u8; PTHREAD_COND_PADDING_SIZE], + __padding: Padding<[u8; PTHREAD_COND_PADDING_SIZE]>, __align: __pthread_cond_align_t, } @@ -246,7 +246,7 @@ s! { } pub struct pthread_mutex_t { - __m_reserved: c_int, + __m_reserved: Padding, __m_count: c_int, __m_owner: _pthread_descr, __m_kind: c_int, @@ -484,7 +484,7 @@ pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { }; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - __m_reserved: 0, + __m_reserved: Padding::new(0), __m_count: 0, __m_owner: ptr::null_mut(), __m_kind: PTHREAD_MUTEX_TIMED_NP, @@ -499,7 +499,7 @@ const PTHREAD_COND_PADDING_SIZE: usize = 48 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __c_lock: __LOCK_INITIALIZER, __c_waiting: ptr::null_mut(), - __padding: [0; PTHREAD_COND_PADDING_SIZE], + __padding: Padding::new([0; PTHREAD_COND_PADDING_SIZE]), __align: 0, }; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 48aa35322e4d9..00b987be56a95 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -21,7 +21,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index aad04df4f820e..5c289e0c43846 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -20,7 +20,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index 5620e49798531..b7b439d58fbfc 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -21,7 +21,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 87308df6267c0..546b60a994d74 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -132,7 +132,7 @@ s! { pub f_namelen: c_long, pub f_flags: c_long, - f_spare: [c_long; 5], + f_spare: Padding<[c_long; 5]>, } pub struct statfs64 { diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 1cfd9c98187f9..1707229fc82b6 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -21,7 +21,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index e9a20895cd788..3ee2562dbbda4 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -23,7 +23,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct siginfo_t { diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index c59489c03ffb0..f634a99d3f1b7 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -22,7 +22,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, pub f_flags: crate::__fsword_t, - f_spare: [crate::__fsword_t; 4], + f_spare: Padding<[crate::__fsword_t; 4]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index d4fd8530999d6..46f693693a82e 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -25,7 +25,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index a383609b8dd12..05ffdbb72dddd 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -46,7 +46,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: c_long, - f_spare: [c_long; 6], + f_spare: Padding<[c_long; 6]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index b598f885da22a..cb32e71fca762 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -27,7 +27,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 0a552868cd0f0..b31d6dee2aace 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -25,7 +25,7 @@ s! { pub f_namelen: c_uint, pub f_frsize: c_uint, pub f_flags: c_uint, - f_spare: [c_uint; 4], + f_spare: Padding<[c_uint; 4]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 48760cb0b6398..ae3845a4df52f 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -25,7 +25,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct siginfo_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 87350c11f9eaf..9b8b99af12b5e 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 @@ -26,7 +26,7 @@ s! { pub f_namelen: crate::__fsword_t, pub f_frsize: crate::__fsword_t, - f_spare: [crate::__fsword_t; 5], + f_spare: Padding<[crate::__fsword_t; 5]>, } pub struct flock { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e6f05ce4d5752..0ad7c2417e55e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -387,7 +387,7 @@ s! { pub t: ptp_clock_time, index: c_uint, flags: c_uint, - rsv: [c_uint; 2], + rsv: Padding<[c_uint; 2]>, } // linux/wireless.h diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index c91b83d1fbc61..bed83460fbc21 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -119,7 +119,7 @@ s! { __pad2: Padding, #[cfg(musl32_time64)] - __pad3: c_ulong, + __pad3: Padding, #[cfg(musl32_time64)] shm_atime: crate::time_t, #[cfg(musl32_time64)] diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 26f0bd3d32ceb..430b5186b9ca8 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -117,7 +117,7 @@ s! { __pad2: Padding, #[cfg(musl32_time64)] - __pad3: c_ulong, + __pad3: Padding, #[cfg(musl32_time64)] shm_atime: crate::time_t, #[cfg(musl32_time64)] diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index a41d62ca7a35c..4e15bdc1b78cd 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -149,7 +149,7 @@ s! { pub aio_offset: off_t, __next: *mut c_void, __prev: *mut c_void, - __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], + __dummy4: Padding<[c_char; 32 - 2 * size_of::<*const ()>()]>, } #[repr(align(8))] diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index f8870d3267294..c133e22f9fb60 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -152,7 +152,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct sigset_t { diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 2c253f0164f11..d623328d60d62 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -181,7 +181,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: c_long, - f_spare: [c_long; 6], + f_spare: Padding<[c_long; 6]>, } pub struct statfs64 { diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index a6a63a33a93b3..b4f101de4206e 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -139,7 +139,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: c_long, - f_spare: [c_long; 6], + f_spare: Padding<[c_long; 6]>, } pub struct msghdr { diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index d7a904979511a..29d5392810b31 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -52,7 +52,7 @@ s! { pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct regex_t { diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index cd9f45699d590..5be0291897876 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -82,8 +82,8 @@ s! { pub msg_qbytes: crate::msglen_t, pub msg_lspid: crate::pid_t, pub msg_lrpid: crate::pid_t, - __ignored1: c_ulong, - __ignored2: c_ulong, + __ignored1: Padding, + __ignored2: Padding, } pub struct sockaddr { @@ -168,7 +168,7 @@ s! { pub f_fsid: crate::fsid_t, pub f_namelen: fsword_t, pub f_frsize: fsword_t, - f_spare: [fsword_t; 5], + f_spare: Padding<[fsword_t; 5]>, } pub struct statfs64 { @@ -199,7 +199,7 @@ s! { __f_unused: Padding, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct msghdr { diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 61069196dad80..faec373cbec92 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -511,7 +511,7 @@ s! { pub f_basetype: [c_char; 16], pub f_flag: c_ulong, pub f_namemax: c_ulong, - f_filler: [c_uint; 21], + f_filler: Padding<[c_uint; 21]>, } pub struct aiocb { diff --git a/src/unix/nto/neutrino.rs b/src/unix/nto/neutrino.rs index 00793f0b8c9d7..b2603f8b1a1fc 100644 --- a/src/unix/nto/neutrino.rs +++ b/src/unix/nto/neutrino.rs @@ -191,7 +191,7 @@ s! { pub nsec_stable: u64, // volatile pub timer_load_max: u64, pub timer_prog_time: u32, - spare: [u32; 7], + spare: Padding<[u32; 7]>, } #[cfg(target_os = "qnx")] @@ -261,7 +261,7 @@ s_no_extra_traits! { pub smp: syspage_entry_info, pub pminfo: syspage_entry_info, pub old_mdriver: syspage_entry_info, - spare0: [u32; 1], + spare0: Padding<[u32; 1]>, __reserved: Padding<[u64; 20]>, // anonymous union with architecture dependent structs pub new_asinfo: syspage_array_info, pub new_cpuinfo: syspage_array_info, diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index b336c316ba2a4..86f2d7ebee975 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -87,7 +87,7 @@ s_no_extra_traits! { pub union door_desc_t__d_data { pub d_desc: door_desc_t__d_data__d_desc, - d_resv: [c_int; 5], /* Check out /usr/include/sys/door.h */ + d_resv: Padding<[c_int; 5]>, /* Check out /usr/include/sys/door.h */ } pub struct door_desc_t { From 6ba7448cd5f190e4b89ef1a0c9fef43a8aeb66f7 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Fri, 28 Aug 2026 18:26:04 +0200 Subject: [PATCH 76/88] crate: use `Padding` for deprecated padding fields Replace types of padding fields that were deprecated for the `Padding` type. The deprecation warnings have been there for more than 6 years, so it's fine to act on them now. Make afore-mentioned padding fields private. (backport ) (cherry picked from commit 31e8e55023b6f047a48151d0f8af56a85a8d5517) --- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 9 +-------- src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs | 9 +-------- src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 9 +-------- src/unix/linux_like/linux/musl/mod.rs | 8 +------- 12 files changed, 12 insertions(+), 95 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 00b987be56a95..41099ef56a77d 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -146,14 +146,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 5c289e0c43846..66d192eb3c874 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -127,14 +127,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 1707229fc82b6..9f0eeaa8b672a 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -180,14 +180,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index f93d92b492be7..5b97eafe540e1 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -79,14 +79,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [u64; 0], } diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index f634a99d3f1b7..30d1d52ef7f76 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -220,14 +220,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 46f693693a82e..2852c265f9632 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -144,14 +144,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index 18feea6acaad3..dc01776efe127 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -115,14 +115,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [u64; 0], } diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index cb32e71fca762..b88e865cab9cd 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -137,14 +137,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 1e3cb3e1dda66..ac3918be4dec8 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -97,14 +97,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [u64; 0], } diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index ae3845a4df52f..7a00da9f9ecf3 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -32,14 +32,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } 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 9b8b99af12b5e..4da4a17a6d008 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 @@ -49,14 +49,7 @@ s! { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on \ - https://github.com/rust-lang/libc/pull/1316 if you're using \ - this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [u64; 0], } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4e15bdc1b78cd..9c03c3cc5091b 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -183,13 +183,7 @@ s! { pub si_code: c_int, #[cfg(any(target_arch = "mips", target_arch = "mips64"))] pub si_errno: c_int, - #[doc(hidden)] - #[deprecated( - since = "0.2.54", - note = "Please leave a comment on https://github.com/rust-lang/libc/pull/1316 \ - if you're using this field" - )] - pub _pad: [c_int; 29], + _pad: Padding<[c_int; 29]>, _align: [usize; 0], } From 18cff988d4e287273d397c13368101f9d5d5aa90 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 31 Aug 2026 11:08:18 +0100 Subject: [PATCH 77/88] correct siginfo_t and other signal related items for redox Corrected `siginfo_t` to match relibc: - [siginfo struct](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/mod.rs#L152) (siginfo_t struct in libc) - [siginfo_t pub type pointing to siginfo](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/mod.rs#L185) Added the following items: - [sigaltstack struct](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/mod.rs#L99) (stack_t struct in libc) - [stack_t pub type pointing to sigaltstack struct](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/mod.rs#L188) - [sigaltstack function](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/mod.rs#L346) - [SS_ONSTACK constant](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/constants.rs#L131) - [SS_DISABLE constant](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/signal/constants.rs#L133) - [pid_t type](https://gitlab.redox-os.org/redox-os/relibc/-/blob/f1772c4bb829e02742275e655d349dda02b27cec/src/header/bits_pid-t/mod.rs#L5) These changes, when released in a stable 0.2.x release, will allow us to use upstream libc for compiling wasmtime natively on Redox. Edited to add the following: - [ucontext struct](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L48) - [ucontext_t pub type pointing to ucontext](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L42) - [mcontext struct x86_64](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L82) - [mcontext struct x86](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L74) - [mcontext struct aarch64](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L107) - [mcontext struct riscv64](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L113) - [mcontext_t pub type pointing to mcontext struct](https://gitlab.redox-os.org/redox-os/relibc/-/blob/e596d08aeaf43f90b18b961c1155d1c1e3eea416/src/header/signal/redox.rs#L44) (backport ) (cherry picked from commit a5b9638057f50661e81a1f9940cad242b246f45d) --- src/unix/redox/mod.rs | 116 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 113 insertions(+), 3 deletions(-) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index bb73e71ddf2b5..8d5642fc5081a 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -28,8 +28,19 @@ pub type suseconds_t = c_int; pub type tcflag_t = u32; pub type time_t = c_longlong; pub type id_t = c_uint; +pub type pid_t = c_int; pub type uid_t = c_int; pub type gid_t = c_int; +pub type ucontext_t = ucontext; +pub type stack_t = sigaltstack; +pub type siginfo_t = siginfo; +#[cfg(any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64" +))] +pub type mcontext_t = mcontext; extern_ty! { pub type timezone; @@ -157,12 +168,21 @@ s! { pub sa_mask: crate::sigset_t, } - pub struct siginfo_t { + pub struct siginfo { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], + pub si_pid: pid_t, + pub si_uid: uid_t, + pub si_addr: *mut c_void, + pub si_status: c_int, + pub si_value: crate::sigval, + } + + pub struct sigaltstack { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, } pub struct sockaddr { @@ -295,7 +315,93 @@ s! { pub struct pthread_spinlock_t { bytes: [u8; _PTHREAD_SPINLOCK_SIZE], } + + pub struct ucontext { + #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64" + ))] + _pad: [c_ulong; 1], // pad from 7*8 to 64 + + #[cfg(target_arch = "x86")] + _pad: [c_ulong; 3], // pad from 9*4 to 12*4 + + pub uc_link: *mut ucontext_t, + pub uc_stack: stack_t, + pub uc_sigmask: sigset_t, + _sival: c_ulong, + _sigcode: c_uint, + _signum: c_uint, + pub uc_mcontext: mcontext_t, + } + #[cfg(target_arch = "x86")] + pub struct mcontext { + _opaque: [c_uchar; 512], + } + #[cfg(target_arch = "x86_64")] + pub struct mcontext { + pub ymm_upper: [[c_ulong; 2]; 16], + pub fxsave: [[c_ulong; 2]; 29], + pub r15: c_ulong, // fxsave "available" +0 + pub r14: c_ulong, // available +8 + pub r13: c_ulong, // available +16 + pub r12: c_ulong, // available +24 + pub rbp: c_ulong, // available +32 + pub rbx: c_ulong, // available +40 + pub r11: c_ulong, // outside fxsave, and so on + pub r10: c_ulong, + pub r9: c_ulong, + pub r8: c_ulong, + pub rax: c_ulong, + pub rcx: c_ulong, + pub rdx: c_ulong, + pub rsi: c_ulong, + pub rdi: c_ulong, + pub rflags: c_ulong, + pub rip: c_ulong, + pub rsp: c_ulong, + } + #[cfg(target_arch = "aarch64")] + pub struct mcontext { + _opaque: [c_uchar; 272], + } + #[cfg(target_arch = "riscv64")] + pub struct mcontext { + _opaque: [c_uchar; 520], + } } + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_code(&self) -> c_int { + self.si_code + } + + pub unsafe fn si_errno(&self) -> c_int { + self.si_errno + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> uid_t { + self.si_uid + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + const _PTHREAD_ATTR_SIZE: usize = 32; const _PTHREAD_RWLOCKATTR_SIZE: usize = 1; const _PTHREAD_RWLOCK_SIZE: usize = 4; @@ -673,6 +779,9 @@ pub const SA_NODEFER: c_int = 0x1000_0000; pub const SA_RESETHAND: c_int = 0x2000_0000; pub const SA_NOCLDSTOP: c_int = 0x4000_0000; +pub const SS_ONSTACK: c_int = 0x00000001; +pub const SS_DISABLE: c_int = 0x00000002; + // sys/file.h pub const LOCK_SH: c_int = 1; pub const LOCK_EX: c_int = 2; @@ -1334,6 +1443,7 @@ extern "C" { timeout: *const crate::timespec, ) -> c_int; pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; // stdlib.h pub fn getsubopt( From 8f68a05be39ccf74bae3db4e5926d1422d4e130b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 31 Aug 2026 20:06:54 +0000 Subject: [PATCH 78/88] fmt: Add spacing between structs (backport ) (cherry picked from commit 96b78673b6e396ee68c5161798faf0df11623290) --- src/unix/redox/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 8d5642fc5081a..4e21f57b3e187 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -275,42 +275,52 @@ s! { pub struct pthread_attr_t { bytes: [u8; _PTHREAD_ATTR_SIZE], } + #[repr(align(4))] pub struct pthread_barrier_t { bytes: [u8; _PTHREAD_BARRIER_SIZE], } + #[repr(align(4))] pub struct pthread_barrierattr_t { bytes: [u8; _PTHREAD_BARRIERATTR_SIZE], } + #[repr(align(4))] pub struct pthread_mutex_t { bytes: [u8; _PTHREAD_MUTEX_SIZE], } + #[repr(align(4))] pub struct pthread_rwlock_t { bytes: [u8; _PTHREAD_RWLOCK_SIZE], } + #[repr(align(4))] pub struct pthread_mutexattr_t { bytes: [u8; _PTHREAD_MUTEXATTR_SIZE], } + #[repr(align(1))] pub struct pthread_rwlockattr_t { bytes: [u8; _PTHREAD_RWLOCKATTR_SIZE], } + #[repr(align(4))] pub struct pthread_cond_t { bytes: [u8; _PTHREAD_COND_SIZE], } + #[repr(align(4))] pub struct pthread_condattr_t { bytes: [u8; _PTHREAD_CONDATTR_SIZE], } + #[repr(align(4))] pub struct pthread_once_t { bytes: [u8; _PTHREAD_ONCE_SIZE], } + #[repr(align(4))] pub struct pthread_spinlock_t { bytes: [u8; _PTHREAD_SPINLOCK_SIZE], @@ -335,10 +345,12 @@ s! { _signum: c_uint, pub uc_mcontext: mcontext_t, } + #[cfg(target_arch = "x86")] pub struct mcontext { _opaque: [c_uchar; 512], } + #[cfg(target_arch = "x86_64")] pub struct mcontext { pub ymm_upper: [[c_ulong; 2]; 16], @@ -362,10 +374,12 @@ s! { pub rip: c_ulong, pub rsp: c_ulong, } + #[cfg(target_arch = "aarch64")] pub struct mcontext { _opaque: [c_uchar; 272], } + #[cfg(target_arch = "riscv64")] pub struct mcontext { _opaque: [c_uchar; 520], From d5bf6035d1b8de99c31187a12ef7579f74a530c4 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Thu, 3 Sep 2026 17:05:06 +0100 Subject: [PATCH 79/88] hermit: make iovec fields public (backport ) (cherry picked from commit 04131430b399735d35e86b8d8d9da4b06d9d28c0) --- src/hermit.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hermit.rs b/src/hermit.rs index 04699b1ecbb3d..ae39e73eed35b 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -51,8 +51,8 @@ s! { } pub struct iovec { - iov_base: *mut c_void, - iov_len: usize, + pub iov_base: *mut c_void, + pub iov_len: usize, } pub struct pollfd { From da6d8dd814166cd13419db58b053cdb3eb5ed1da Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:39 +0200 Subject: [PATCH 80/88] linux: ensure `siginfo_t` uses `mod new` bindings Replace references to `siginfo_t` in the regular repository layout with a crate-relative path that uses the reexport from the `new` module. This allows the next few patches to all work as individual revisions. (backport ) (cherry picked from commit aa478e61d3a07bef15c1cf962cb315e5160bf4bd) --- src/unix/linux_like/linux/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 0ad7c2417e55e..7ed918f41eff7 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3582,10 +3582,10 @@ extern "C" { #[cfg_attr(musl_redir_time64, link_name = "__sigtimedwait_time64")] pub fn sigtimedwait( set: *const sigset_t, - info: *mut siginfo_t, + info: *mut crate::siginfo_t, timeout: *const crate::timespec, ) -> c_int; - pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut crate::siginfo_t) -> c_int; pub fn accept4(fd: c_int, addr: *mut crate::sockaddr, len: *mut socklen_t, flg: c_int) -> c_int; pub fn reboot(how_to: c_int) -> c_int; From 08d5b593e4d4bddd6548b0fbff6d63acccb214d9 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:42 +0200 Subject: [PATCH 81/88] linux(gnu): complete `siginfo_t` definition Replace alignment/padding fields with a one-to-one definition as that used upstream. These have been incorporated as definitions in the `new` module to avoid huge repetition across target triples without overrides. The glibc definitions are mostly the same across target architectures except for MIPS, SPARC and x86. x86 is confusing because there's only an override when running under x86_64 and compiling for x32. I'm not sure how Rust handles this, so the `#[path]`-redirected files for that architecture are the same as the generic ones. See [^1] for the generic file and the following list for the architecture-specific overrides. - `mips`: - `sparc`: - `x86`: [^1]: (backport ) (cherry picked from commit 4b355bdaad73a4706d4d83daf71cec1f3565f0e2) [ Needed to adjust the body of si_int for the cherry pick since on libc-0.2, sigval is still a struct - Trevor ] --- .../sysdeps/unix/linux/bits/types/mod.rs | 5 + .../unix/linux/bits/types/siginfo_t.rs | 267 ++++++++++++++++++ src/new/glibc/sysdeps/unix/linux/mod.rs | 4 + 3 files changed, 276 insertions(+) create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs create mode 100644 src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs diff --git a/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs b/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs new file mode 100644 index 0000000000000..834a5cfede828 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs @@ -0,0 +1,5 @@ +//! Source directory: `sysdeps/unix/sysv/linux/bits/types` +//! +//! + +pub(crate) mod siginfo_t; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs b/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs new file mode 100644 index 0000000000000..bd112f102e2ae --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs @@ -0,0 +1,267 @@ +//! Source header: `sysdeps/unix/sysv/linux/bits/types/siginfo_t.h` +//! +//! Note this module corresponds with multiple header files upstream. The above +//! header file contains the generic definition, while other +//! architecture-specific definitions live upstream at +//! `sysdeps/unix/sysv/linux//bits/siginfo-arch.h`. Currently, the +//! following set of header files are contained in this one Rust module: +//! +//! - `sysdeps/unix/sysv/linux/bits/types/siginfo_t.h` +//! - `sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h` +//! - `sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h` +//! - `sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h` +//! +//! + +use crate::prelude::*; + +const __SI_MAX_SIZE: usize = 128; +const __SI_PAD_SIZE: usize = if cfg!(target_pointer_width = "64") { + __SI_MAX_SIZE / size_of::() - 4 +} else { + __SI_MAX_SIZE / size_of::() - 3 +}; + +cfg_if! { + if #[cfg(target_arch = "sparc64")] { + type __SI_BAND_TYPE = c_int; + } else { + type __SI_BAND_TYPE = c_long; + } +} + +#[repr(C)] +#[cfg_attr( + all(target_arch = "x86_64", target_pointer_width = "32"), + repr(align(4)) +)] +#[derive(Clone, Copy, Debug)] +struct __SI_CLOCK_T(crate::clock_t); + +s_no_extra_traits! { + #[cfg_attr( + all(target_arch = "x86_64", target_pointer_width = "32"), + repr(align(8)) + )] + pub struct siginfo_t { + pub si_signo: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + ))] + pub si_code: c_int, + + pub si_errno: c_int, + + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + )))] + pub si_code: c_int, + + #[cfg(target_pointer_width = "64")] + __pad0: Padding, + _sifields: __c_anonymous_siginfo_t__si_fields, + } + + union __c_anonymous_siginfo_t__si_fields { + _pad: [c_int; __SI_PAD_SIZE], + _kill: __c_anonymous__si_fields__kill, + _timer: __c_anonymous__si_fields__timer, + _rt: __c_anonymous__si_fields__rt, + _sigchld: __c_anonymous__si_fields__sigchld, + _sigfault: __c_anonymous__si_fields__sigfault, + _sigpoll: __c_anonymous__si_fields__sigpoll, + _sigsys: __c_anonymous__si_fields__sigsys, + } + + struct __c_anonymous__si_fields__kill { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + } + + struct __c_anonymous__si_fields__timer { + si_tid: c_int, + si_overrun: c_int, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__rt { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: __SI_CLOCK_T, + si_stime: __SI_CLOCK_T, + } + + struct __c_anonymous__si_fields__sigfault { + si_addr: *mut c_void, + #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] + _si_trapno: c_int, + si_addr_lsb: c_short, + _bounds: __c_anonymous__sigfault__bounds, + } + + struct __c_anonymous__si_fields__sigpoll { + si_band: __SI_BAND_TYPE, + si_fd: c_int, + } + + struct __c_anonymous__si_fields__sigsys { + _call_addr: *mut c_void, + _syscall: c_int, + _arch: c_uint, + } + + union __c_anonymous__sigfault__bounds { + _addr_bnd: __c_anonymous__bounds__addr_bnd, + _pkey: u32, + } + + struct __c_anonymous__bounds__addr_bnd { + _lower: *mut c_void, + _upper: *mut c_void, + } +} + +impl siginfo_t { + #[inline] + pub const unsafe fn si_pid(&self) -> crate::pid_t { + unsafe { self._sifields._kill.si_pid } + } + + #[inline] + pub const unsafe fn si_uid(&self) -> crate::uid_t { + unsafe { self._sifields._kill.si_uid } + } + + #[inline] + pub const unsafe fn si_timerid(&self) -> c_int { + unsafe { self._sifields._timer.si_tid } + } + + #[inline] + pub const unsafe fn si_overrun(&self) -> c_int { + unsafe { self._sifields._timer.si_overrun } + } + + #[inline] + pub const unsafe fn si_status(&self) -> c_int { + unsafe { self._sifields._sigchld.si_status } + } + + #[inline] + pub const unsafe fn si_utime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_utime.0 } + } + + #[inline] + pub const unsafe fn si_stime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_stime.0 } + } + + #[inline] + pub const unsafe fn si_value(&self) -> crate::sigval { + unsafe { self._sifields._rt.si_sigval } + } + + #[inline] + pub unsafe fn si_int(&self) -> c_int { + // DIFF(main): sigval is a union on `main`, struct on `libc-0.2`. The cast means + // this can't be const at the MSRV. + unsafe { self._sifields._rt.si_sigval.sival_ptr as usize as c_int } + } + + #[inline] + pub const unsafe fn si_ptr(&self) -> *mut c_void { + unsafe { self._sifields._rt.si_sigval.sival_ptr } + } + + #[inline] + pub const unsafe fn si_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigfault.si_addr } + } + + #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] + #[inline] + pub const unsafe fn si_trapno(&self) -> c_int { + unsafe { self._sifields._sigfault._si_trapno } + } + + #[inline] + pub const unsafe fn si_addr_lsb(&self) -> c_short { + unsafe { self._sifields._sigfault.si_addr_lsb } + } + + #[inline] + pub const unsafe fn si_lower(&self) -> *mut c_void { + unsafe { self._sifields._sigfault._bounds._addr_bnd._lower } + } + + #[inline] + pub const unsafe fn si_upper(&self) -> *mut c_void { + unsafe { self._sifields._sigfault._bounds._addr_bnd._upper } + } + + #[inline] + pub const unsafe fn si_pkey(&self) -> u32 { + unsafe { self._sifields._sigfault._bounds._pkey } + } + + #[inline] + pub const unsafe fn si_band(&self) -> __SI_BAND_TYPE { + unsafe { self._sifields._sigpoll.si_band } + } + + #[inline] + pub const unsafe fn si_fd(&self) -> c_int { + unsafe { self._sifields._sigpoll.si_fd } + } + + #[inline] + pub const unsafe fn si_call_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigsys._call_addr } + } + + #[inline] + pub const unsafe fn si_syscall(&self) -> c_int { + unsafe { self._sifields._sigsys._syscall } + } + + #[inline] + pub const unsafe fn si_arch(&self) -> c_uint { + unsafe { self._sifields._sigsys._arch } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for siginfo_t { + fn eq(&self, other: &Self) -> bool { + (self.si_signo, self.si_errno, self.si_code) + == (other.si_signo, other.si_errno, other.si_code) + } + } + + impl Eq for siginfo_t {} + + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + } + } + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index c4220ae87a885..f3d704d63e55d 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -19,6 +19,7 @@ pub(crate) mod bits { path = "../sparc/bits/sigaction.rs" )] pub(crate) mod sigaction; + #[cfg_attr( any( target_arch = "mips", @@ -33,7 +34,10 @@ pub(crate) mod bits { path = "../sparc/bits/signum_arch.rs" )] pub(crate) mod signum_arch; + pub(crate) mod statvfs; + + pub(crate) mod types; } /// Directory: `net/` From 03854428a81b8eaed627e53dac2a1a63ed1cb51b Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:44 +0200 Subject: [PATCH 82/88] linux(gnu): replace older `siginfo_t` bindings Remove older bindings to `siginfo_t` using dummy fields instead of the upstream `union`. This follows from the patch providing a full definition for glibc bindings. Add reexports for `siginfo_t` under the `new` module. This has required renaming the reexport for the `nptl` module as it also contains a `bits` module of the same name as the `bits::types::siginfo_t` module path under `sysdeps`. (backport ) (cherry picked from commit 404da0eae421fd85b2b16330ca670505bdafdb23) --- src/new/glibc/mod.rs | 5 +- src/new/glibc/signal.rs | 1 + src/new/mod.rs | 11 +-- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 8 -- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 8 -- src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 8 -- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 7 -- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 8 -- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 8 -- .../linux_like/linux/gnu/b32/sparc/mod.rs | 8 -- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 8 -- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 8 -- .../linux/gnu/b64/loongarch64/mod.rs | 8 -- .../linux_like/linux/gnu/b64/mips64/mod.rs | 8 -- .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 8 -- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 8 -- src/unix/linux_like/linux/gnu/b64/s390x.rs | 8 -- .../linux_like/linux/gnu/b64/sparc64/mod.rs | 8 -- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 8 -- src/unix/linux_like/linux/gnu/mod.rs | 75 ------------------- 20 files changed, 10 insertions(+), 209 deletions(-) diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 3697b7a07496f..15441a20852e7 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -48,6 +48,7 @@ mod sysdeps { pub(crate) use posix::*; // FIXME(pthread): eventually all platforms should use this module #[cfg(target_os = "linux")] -pub(crate) use sysdeps::nptl::*; +#[allow(unused)] +pub(crate) use sysdeps::nptl::pthread; #[cfg(target_os = "linux")] -pub(crate) use sysdeps::unix::linux::*; +pub(crate) use sysdeps::unix::linux::net; diff --git a/src/new/glibc/signal.rs b/src/new/glibc/signal.rs index 023b49ed0c91a..f91997f45acbd 100644 --- a/src/new/glibc/signal.rs +++ b/src/new/glibc/signal.rs @@ -2,6 +2,7 @@ pub use super::bits::signum_generic::*; pub use super::sysdeps::unix::linux::bits::sigaction::*; +pub use super::sysdeps::unix::linux::bits::types::siginfo_t::*; use crate::prelude::*; extern "C" { diff --git a/src/new/mod.rs b/src/new/mod.rs index d910dccbfdb89..90fd79fde3db6 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -197,12 +197,13 @@ cfg_if! { pub use linux::sctp::*; pub use linux::tls::*; pub use linux::types::*; + #[cfg(target_env = "gnu")] - pub use net::route::*; - #[cfg(target_env = "gnu")] - pub use signal::*; - #[cfg(target_env = "gnu")] - pub use sys::statvfs::*; + pub use self::{ + net::route::*, + signal::*, + sys::statvfs::*, + }; } else if #[cfg(target_vendor = "apple")] { #[cfg(target_os = "macos")] pub use net::bpf::*; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 41099ef56a77d..bec3d1083093e 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -142,14 +142,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 66d192eb3c874..c754ec000ea4c 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -123,14 +123,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index b7b439d58fbfc..ec5a057cddf55 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -123,14 +123,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 546b60a994d74..a4cc330710db7 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -156,13 +156,6 @@ s! { pub ss_flags: c_int, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - pub _pad: [c_int; 29], - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 9f0eeaa8b672a..30f85c9fb6885 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -176,14 +176,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 5b97eafe540e1..610fa4065ba6e 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -75,14 +75,6 @@ s! { pub f_spare: [c_long; 4], } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 3ee2562dbbda4..95ad74af2e4c4 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -26,14 +26,6 @@ s! { f_spare: Padding<[crate::__fsword_t; 4]>, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct flock { pub l_type: c_short, pub l_whence: c_short, diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 30d1d52ef7f76..cbfae20a68a97 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -216,14 +216,6 @@ s! { __glibc_reserved5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 2852c265f9632..714e609b88b6d 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -140,14 +140,6 @@ s! { __unused5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index dc01776efe127..7cea157c63d16 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -111,14 +111,6 @@ s! { pub ss_size: size_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [u64; 0], - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 05ffdbb72dddd..07fe19471b76d 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -113,14 +113,6 @@ s! { pub ss_flags: c_int, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - _pad: Padding, - _pad2: Padding<[c_long; 14]>, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index b88e865cab9cd..ecccfdb48cd44 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -133,14 +133,6 @@ s! { __unused5: Padding, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index ac3918be4dec8..d58948c951df9 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -93,14 +93,6 @@ s! { pub f_spare: [c_long; 4], } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index b31d6dee2aace..1dcc87aa8d0ae 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -44,14 +44,6 @@ s! { pub l_pid: crate::pid_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding, - _pad2: Padding<[c_long; 14]>, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 7a00da9f9ecf3..80c5528892b3c 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -28,14 +28,6 @@ s! { f_spare: Padding<[crate::__fsword_t; 5]>, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - pub struct flock { pub l_type: c_short, pub l_whence: c_short, 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 4da4a17a6d008..1f3209f529f5f 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 @@ -45,14 +45,6 @@ s! { pub l_pid: crate::pid_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - _pad: Padding<[c_int; 29]>, - _align: [u64; 0], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 53fb72eb5632f..297ec8e959bb5 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -430,32 +430,6 @@ s! { } } -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - #[repr(C)] - struct siginfo_sigfault { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - si_addr: *mut c_void, - } - (*(self as *const siginfo_t).cast::()).si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - _si_tid: c_int, - _si_overrun: c_int, - si_sigval: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).si_sigval - } -} - s_no_extra_traits! { // linux/if_ether.h @@ -465,55 +439,6 @@ s_no_extra_traits! { pub h_source: [c_uchar; crate::ETH_ALEN as usize], pub h_proto: crate::__be16, } - - // Internal, for casts to access union fields - struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, - } - - // Internal, for casts to access union fields - union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, - } - - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, - } -} - -impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t).cast::()).sifields - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.sifields().sigchld.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.sifields().sigchld.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.sifields().sigchld.si_status - } - - pub unsafe fn si_utime(&self) -> c_long { - self.sifields().sigchld.si_utime - } - - pub unsafe fn si_stime(&self) -> c_long { - self.sifields().sigchld.si_stime - } } s_no_extra_traits! { From 46945a3c53cd1c465ef8e4c63adcb9b3209fde38 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:45 +0200 Subject: [PATCH 83/88] linux(musl): complete `siginfo_t` definition Replace alignment/padding fields with a mirrored definition of the upstream `union`. See [^1] for details. [^1]: (backport ) (cherry picked from commit 5bea5fb3f12fa5dfad7908820fa64687bfbe55fd) [ Needed to adjust the body of si_int for the cherry pick since on libc-0.2, sigval is still a struct - Trevor ] --- src/new/musl/mod.rs | 1 + src/new/musl/signal.rs | 226 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 src/new/musl/signal.rs diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index 9edb38255422b..e85523b3f88ef 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -31,4 +31,5 @@ pub(crate) mod sys { } pub(crate) mod sched; +pub(crate) mod signal; pub(crate) mod unistd; diff --git a/src/new/musl/signal.rs b/src/new/musl/signal.rs new file mode 100644 index 0000000000000..3fa4fab66eb11 --- /dev/null +++ b/src/new/musl/signal.rs @@ -0,0 +1,226 @@ +//! Header source: `include/signal.h` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +use crate::prelude::*; + +s_no_extra_traits! { + // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this + // struct is target-agnostic (see + // ) + pub struct siginfo_t { + pub si_signo: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + ))] + pub si_code: c_int, + + pub si_errno: c_int, + + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6" + )))] + pub si_code: c_int, + + __si_fields: __c_anonymous_siginfo_t___si_fields, + } + + union __c_anonymous_siginfo_t___si_fields { + __pad: [c_char; 128 - 2 * size_of::() - size_of::()], + __si_common: __c_anonymous___si_fields___si_common, + __sigfault: __c_anonymous___si_fields___sigfault, + __sigpoll: __c_anonymous___si_fields___sigpoll, + __sigsys: __c_anonymous___si_fields___sigsys, + } + + struct __c_anonymous___si_fields___si_common { + __first: __c_anonymous___si_common___first, + __second: __c_anonymous___si_common___second, + } + + struct __c_anonymous___si_fields___sigfault { + si_addr: *mut c_void, + si_addr_lsb: c_short, + __first: __c_anonymous___sigfault___first, + } + + struct __c_anonymous___si_fields___sigpoll { + si_band: c_long, + si_fd: c_int, + } + + struct __c_anonymous___si_fields___sigsys { + si_call_addr: *mut c_void, + si_syscall: c_int, + si_arch: c_uint, + } + + struct __c_anonymous___si_common___first { + __piduid: __c_anonymous___first___piduid, + __timer: __c_anonymous___first___timer, + } + + struct __c_anonymous___si_common___second { + si_value: crate::sigval, + __sigchld: __c_anonymous___second___sigchld, + } + + struct __c_anonymous___sigfault___first { + __addr_band: __c_anonymous___first___addr_band, + si_pkey: c_uint, + } + + struct __c_anonymous___first___piduid { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + } + + struct __c_anonymous___first___timer { + si_timerid: c_int, + si_overrun: c_int, + } + + struct __c_anonymous___second___sigchld { + si_status: c_int, + si_utime: crate::clock_t, + si_stime: crate::clock_t, + } + + struct __c_anonymous___first___addr_band { + si_lower: *mut c_void, + si_upper: *mut c_void, + } +} + +impl siginfo_t { + #[inline] + pub const unsafe fn si_pid(&self) -> crate::pid_t { + unsafe { self.__si_fields.__si_common.__first.__piduid.si_pid } + } + + #[inline] + pub const unsafe fn si_uid(&self) -> crate::uid_t { + unsafe { self.__si_fields.__si_common.__first.__piduid.si_uid } + } + + #[inline] + pub const unsafe fn si_status(&self) -> c_int { + unsafe { self.__si_fields.__si_common.__second.__sigchld.si_status } + } + + #[inline] + pub const unsafe fn si_utime(&self) -> crate::clock_t { + unsafe { self.__si_fields.__si_common.__second.__sigchld.si_utime } + } + + #[inline] + pub const unsafe fn si_stime(&self) -> crate::clock_t { + unsafe { self.__si_fields.__si_common.__second.__sigchld.si_stime } + } + + #[inline] + pub const unsafe fn si_value(&self) -> crate::sigval { + unsafe { self.__si_fields.__si_common.__second.si_value } + } + + #[inline] + pub const unsafe fn si_addr(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigfault.si_addr } + } + + #[inline] + pub const unsafe fn si_addr_lsb(&self) -> c_short { + unsafe { self.__si_fields.__sigfault.si_addr_lsb } + } + + #[inline] + pub const unsafe fn si_lower(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigfault.__first.__addr_band.si_lower } + } + + #[inline] + pub const unsafe fn si_upper(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigfault.__first.__addr_band.si_upper } + } + + #[inline] + pub const unsafe fn si_pkey(&self) -> c_uint { + unsafe { self.__si_fields.__sigfault.__first.si_pkey } + } + + #[inline] + pub const unsafe fn si_band(&self) -> c_long { + unsafe { self.__si_fields.__sigpoll.si_band } + } + + #[inline] + pub const unsafe fn si_fd(&self) -> c_int { + unsafe { self.__si_fields.__sigpoll.si_fd } + } + + #[inline] + pub const unsafe fn si_timerid(&self) -> c_int { + unsafe { self.__si_fields.__si_common.__first.__timer.si_timerid } + } + + #[inline] + pub const unsafe fn si_overrun(&self) -> c_int { + unsafe { self.__si_fields.__si_common.__first.__timer.si_overrun } + } + + #[inline] + pub const unsafe fn si_ptr(&self) -> *mut c_void { + unsafe { self.__si_fields.__si_common.__second.si_value.sival_ptr } + } + + #[inline] + pub unsafe fn si_int(&self) -> c_int { + // DIFF(main): sigval is a union on `main`, struct on `libc-0.2`. The cast means + // this can't be const at the MSRV. + unsafe { self.__si_fields.__si_common.__second.si_value.sival_ptr as usize as c_int } + } + + #[inline] + pub const unsafe fn si_call_addr(&self) -> *mut c_void { + unsafe { self.__si_fields.__sigsys.si_call_addr } + } + + #[inline] + pub const unsafe fn si_syscall(&self) -> c_int { + unsafe { self.__si_fields.__sigsys.si_syscall } + } + + #[inline] + pub const unsafe fn si_arch(&self) -> c_uint { + unsafe { self.__si_fields.__sigsys.si_arch } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for siginfo_t { + fn eq(&self, other: &Self) -> bool { + (self.si_signo, self.si_errno, self.si_code) + == (other.si_signo, other.si_errno, other.si_code) + } + } + + impl Eq for siginfo_t {} + + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + } + } + } +} From 775c19d1b20e871d8c821c4a6da014db0d7f08c9 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:46 +0200 Subject: [PATCH 84/88] linux(musl): replace older `siginfo_t` bindings Remove older bindings to `siginfo_t` using dummy fields instead of the upstream `union`. This follows from the patch providing a full definition for musl bindings. Add modified bindings under `new`. (backport ) (cherry picked from commit 539ecdd0e49c8ae0422a46c4dfd12a79fb277cfb) --- src/new/mod.rs | 1 + src/unix/linux_like/linux/musl/mod.rs | 92 --------------------------- 2 files changed, 1 insertion(+), 92 deletions(-) diff --git a/src/new/mod.rs b/src/new/mod.rs index 90fd79fde3db6..d1369742dd1c9 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -262,6 +262,7 @@ cfg_if! { // Per-env headers we export cfg_if! { if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub use signal::*; pub use sys::socket::*; } } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 9c03c3cc5091b..3641134f1f31c 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -57,83 +57,6 @@ cfg_if! { } } -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - #[repr(C)] - struct siginfo_sigfault { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - si_addr: *mut c_void, - } - (*(self as *const siginfo_t).cast::()).si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_si_value { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - _si_timerid: c_int, - _si_overrun: c_int, - si_value: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).si_value - } -} - -s_no_extra_traits! { - // Internal, for casts to access union fields - struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, - } - - // Internal, for casts to access union fields - union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, - } - - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, - } -} - -impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t).cast::()).sifields - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.sifields().sigchld.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.sifields().sigchld.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.sifields().sigchld.si_status - } - - pub unsafe fn si_utime(&self) -> c_long { - self.sifields().sigchld.si_utime - } - - pub unsafe fn si_stime(&self) -> c_long { - self.sifields().sigchld.si_stime - } -} - s! { pub struct aiocb { pub aio_fildes: c_int, @@ -172,21 +95,6 @@ s! { pub sa_restorer: Option, } - // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is - // target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2) - // - // FIXME(union): C implementation uses unions - pub struct siginfo_t { - pub si_signo: c_int, - #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] - pub si_errno: c_int, - pub si_code: c_int, - #[cfg(any(target_arch = "mips", target_arch = "mips64"))] - pub si_errno: c_int, - _pad: Padding<[c_int; 29]>, - _align: [usize; 0], - } - // musl's uint64_t is an unsigned long instead of an unsigned long long on // 64-bit targets, so it's not a __u64 (which is c_ulonglong), but rather a // real u64. This is also how we handle musl's uint64_t elsewhere. From 4869ff8ada70236a1335da9c4d23b9dd3fa7afaa Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:47 +0200 Subject: [PATCH 85/88] linux(uclibc): complete `siginfo_t` definition Replace alignment/padding dummy fields with a mirrored definition fitting that of upstream's `union`. uClibc supports targets for which we have no support in Rust. No architecture-specific definition has been provided for those. See [^1] for details on the generic definition and [^2] for details on the MIPS definition. [^1]: [^2]: (backport ) (cherry picked from commit 11a1a6407de254f2f61eed76ee9913ad483d7665) [ Needed to adjust the body of si_int for the cherry pick since on libc-0.2, sigval is still a struct - Trevor ] --- src/new/uclibc/mod.rs | 10 + .../uclibc/sysdeps/linux/common/bits/mod.rs | 6 + .../sysdeps/linux/common/bits/siginfo.rs | 229 ++++++++++++++++++ src/new/uclibc/sysdeps/linux/mod.rs | 12 + 4 files changed, 257 insertions(+) create mode 100644 src/new/uclibc/sysdeps/linux/common/bits/mod.rs create mode 100644 src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs create mode 100644 src/new/uclibc/sysdeps/linux/mod.rs diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs index 6bf83ef2e1d38..6f99b4e95c0cb 100644 --- a/src/new/uclibc/mod.rs +++ b/src/new/uclibc/mod.rs @@ -4,4 +4,14 @@ //! * Headers: (mirror) pub(crate) mod pthread; + +/// Directory source: `libc/sysdeps` +/// +/// * Headers: (official) +/// * Headers: (mirror) +pub(crate) mod sysdeps { + #[cfg(target_os = "linux")] + pub(crate) mod linux; +} + pub(crate) mod unistd; diff --git a/src/new/uclibc/sysdeps/linux/common/bits/mod.rs b/src/new/uclibc/sysdeps/linux/common/bits/mod.rs new file mode 100644 index 0000000000000..bdb8c91ddc9c2 --- /dev/null +++ b/src/new/uclibc/sysdeps/linux/common/bits/mod.rs @@ -0,0 +1,6 @@ +//! Directory source: `libc/sysdeps/linux/common/bits` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +pub(crate) mod siginfo; diff --git a/src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs b/src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs new file mode 100644 index 0000000000000..68102af02ad9d --- /dev/null +++ b/src/new/uclibc/sysdeps/linux/common/bits/siginfo.rs @@ -0,0 +1,229 @@ +//! Header source: `libc/sysdeps/linux/common/bits/siginfo.h` +//! +//! Note this header file unifies all header files in upstream uClibc-ng for +//! both the generic definition and the architecture-specific definitions. +//! Currently, this Rust module has the definitions for the following set of +//! header files: +//! +//! - `libc/sysdeps/linux/common/bits/siginfo.h` +//! - `libc/sysdeps/linux/mips/bits/siginfo.h` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +use crate::prelude::*; + +const __SI_MAX_SIZE: usize = 128; +const __SI_PAD_SIZE: usize = if cfg!(target_pointer_width = "64") { + __SI_MAX_SIZE / size_of::() - 4 +} else { + __SI_MAX_SIZE / size_of::() - 3 +}; + +s_no_extra_traits! { + pub struct siginfo_t { + pub si_signo: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + pub si_code: c_int, + + pub si_errno: c_int, + + #[cfg(not(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + )))] + pub si_code: c_int, + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + __pad0: Padding<[c_int; __SI_MAX_SIZE / size_of::() - __SI_PAD_SIZE - 3]>, + + _sifields: __c_anonymous_siginfo_t__si_fields, + } + + union __c_anonymous_siginfo_t__si_fields { + _pad: Padding<[c_int; __SI_PAD_SIZE]>, + _kill: __c_anonymous__si_fields__kill, + _timer: __c_anonymous__si_fields__timer, + _rt: __c_anonymous__si_fields__rt, + _sigchld: __c_anonymous__si_fields__sigchld, + _sigfault: __c_anonymous__si_fields__sigfault, + _sigpoll: __c_anonymous__si_fields__sigpoll, + _sigsys: __c_anonymous__si_fields__sigsys, + } + + struct __c_anonymous__si_fields__kill { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + } + + struct __c_anonymous__si_fields__timer { + si_tid: c_int, + si_overrun: c_int, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__rt { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_sigval: crate::sigval, + } + + struct __c_anonymous__si_fields__sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: crate::clock_t, + si_stime: crate::clock_t, + } + + struct __c_anonymous__si_fields__sigfault { + si_addr: *mut c_void, + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + si_addr_lsb: c_short, + } + + struct __c_anonymous__si_fields__sigpoll { + si_band: c_long, + si_fd: c_int, + } + + struct __c_anonymous__si_fields__sigsys { + _call_addr: *mut c_void, + _syscall: c_int, + _arch: c_uint, + } +} + +impl siginfo_t { + #[inline] + pub const unsafe fn si_pid(&self) -> crate::pid_t { + unsafe { self._sifields._kill.si_pid } + } + + #[inline] + pub const unsafe fn si_uid(&self) -> crate::uid_t { + unsafe { self._sifields._kill.si_uid } + } + + #[inline] + pub const unsafe fn si_timerid(&self) -> c_int { + unsafe { self._sifields._timer.si_tid } + } + + #[inline] + pub const unsafe fn si_overrun(&self) -> c_int { + unsafe { self._sifields._timer.si_overrun } + } + + #[inline] + pub const unsafe fn si_status(&self) -> c_int { + unsafe { self._sifields._sigchld.si_status } + } + + #[inline] + pub const unsafe fn si_utime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_utime } + } + + #[inline] + pub const unsafe fn si_stime(&self) -> crate::clock_t { + unsafe { self._sifields._sigchld.si_stime } + } + + #[inline] + pub const unsafe fn si_value(&self) -> crate::sigval { + unsafe { self._sifields._rt.si_sigval } + } + + #[inline] + pub unsafe fn si_int(&self) -> c_int { + // DIFF(main): sigval is a union on `main`, struct on `libc-0.2`. The cast means + // this can't be const at the MSRV. + unsafe { self._sifields._rt.si_sigval.sival_ptr as usize as c_int } + } + + #[inline] + pub const unsafe fn si_ptr(&self) -> *mut c_void { + unsafe { self._sifields._rt.si_sigval.sival_ptr } + } + + #[inline] + pub const unsafe fn si_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigfault.si_addr } + } + + #[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "mips32r6", + target_arch = "mips64r6", + ))] + #[inline] + pub const unsafe fn si_addr_lsb(&self) -> c_short { + unsafe { self._sifields._sigfault.si_addr_lsb } + } + + #[inline] + pub const unsafe fn si_band(&self) -> c_long { + unsafe { self._sifields._sigpoll.si_band } + } + + #[inline] + pub const unsafe fn si_fd(&self) -> c_int { + unsafe { self._sifields._sigpoll.si_fd } + } + + #[inline] + pub const unsafe fn si_call_addr(&self) -> *mut c_void { + unsafe { self._sifields._sigsys._call_addr } + } + + #[inline] + pub const unsafe fn si_syscall(&self) -> c_int { + unsafe { self._sifields._sigsys._syscall } + } + + #[inline] + pub const unsafe fn si_arch(&self) -> c_uint { + unsafe { self._sifields._sigsys._arch } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for siginfo_t { + fn eq(&self, other: &Self) -> bool { + (self.si_signo, self.si_code, self.si_errno) + == (other.si_signo, other.si_code, other.si_errno) + } + } + + impl Eq for siginfo_t {} + + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_code.hash(state); + self.si_errno.hash(state); + } + } + } +} diff --git a/src/new/uclibc/sysdeps/linux/mod.rs b/src/new/uclibc/sysdeps/linux/mod.rs new file mode 100644 index 0000000000000..130b2f927d254 --- /dev/null +++ b/src/new/uclibc/sysdeps/linux/mod.rs @@ -0,0 +1,12 @@ +//! Directory source: `libc/sysdeps/linux` +//! +//! * Headers: (official) +//! * Headers: (mirror) + +/// Directory source: `libc/sysdeps/linux/common` +/// +/// * Headers: (official) +/// * Headers: (mirror) +pub(crate) mod common { + pub(crate) mod bits; +} From bd5ef955a455177fba791b9f787ac14c62d92f8c Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Wed, 5 Aug 2026 18:37:48 +0200 Subject: [PATCH 86/88] linux(uclibc): replace older `siginfo_t` bindings Remove older bindings to `siginfo_t` using dummy fields instead of the upstream `union`. This follows from the patch providing a full definition for uClibc bindings. Add modified bindings to `new` module. (backport ) (cherry picked from commit ae20d4359da1ad9911e7e43d3a69021b4b10304b) --- src/new/mod.rs | 2 + src/unix/linux_like/linux/uclibc/arm/mod.rs | 7 -- .../linux/uclibc/mips/mips32/mod.rs | 7 -- .../linux/uclibc/mips/mips64/mod.rs | 8 -- src/unix/linux_like/linux/uclibc/mod.rs | 77 ------------------- .../linux_like/linux/uclibc/x86_64/mod.rs | 8 -- 6 files changed, 2 insertions(+), 107 deletions(-) diff --git a/src/new/mod.rs b/src/new/mod.rs index d1369742dd1c9..8f12b20afa993 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -197,6 +197,8 @@ cfg_if! { pub use linux::sctp::*; pub use linux::tls::*; pub use linux::types::*; + #[cfg(target_env = "uclibc")] + pub use sysdeps::linux::common::bits::siginfo::*; #[cfg(target_env = "gnu")] pub use self::{ diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index c133e22f9fb60..493acf40da090 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -179,13 +179,6 @@ s! { pub c_ospeed: crate::speed_t, } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_errno: c_int, - pub si_code: c_int, - pub _pad: [c_int; 29], - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index d623328d60d62..cc85abc132385 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -97,13 +97,6 @@ s! { __val: [c_ulong; 4], } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - pub _pad: [c_int; 29], - } - pub struct glob64_t { pub gl_pathc: size_t, pub gl_pathv: *mut *mut c_char, diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index b4f101de4206e..4a80ff1cc9267 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -79,14 +79,6 @@ s! { __size: [c_ulong; 16], } - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - _pad: Padding, - _pad2: Padding<[c_long; 14]>, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 29d5392810b31..0075bddee94ec 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -146,83 +146,6 @@ s! { } } -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_void { - #[repr(C)] - struct siginfo_sigfault { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - si_addr: *mut c_void, - } - (*(self as *const siginfo_t).cast::()).si_addr - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_si_value { - _si_signo: c_int, - _si_errno: c_int, - _si_code: c_int, - _si_timerid: c_int, - _si_overrun: c_int, - si_value: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).si_value - } -} - -s_no_extra_traits! { - // Internal, for casts to access union fields - struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, - } - - // Internal, for casts to access union fields - union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, - } - - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, - } -} - -impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t).cast::()).sifields - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - self.sifields().sigchld.si_pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - self.sifields().sigchld.si_uid - } - - pub unsafe fn si_status(&self) -> c_int { - self.sifields().sigchld.si_status - } - - pub unsafe fn si_utime(&self) -> c_long { - self.sifields().sigchld.si_utime - } - - pub unsafe fn si_stime(&self) -> c_long { - self.sifields().sigchld.si_stime - } -} - pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 5be0291897876..60e5cfe72500d 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -51,14 +51,6 @@ s! { __sched_priority: c_int, } - pub struct siginfo_t { - si_signo: c_int, // signal number - si_errno: c_int, // if not zero: error value of signal, see errno.h - si_code: c_int, // signal code - pub _pad: [c_int; 28], // unported union - _align: [usize; 0], - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, // segment size in bytes From aa4360857ffed7c75198aed2eefbb6e2910fda2c Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 1 Sep 2026 21:33:50 +0200 Subject: [PATCH 87/88] Fix WIFSTOPPED on NetBSD If we expand the definitions from https://github.com/NetBSD/src/blob/d04b0c735abc997743bb3faa74464524cbe7becd/sys/sys/wait.h#L61 we get #define WIFCONTINUED(x) (x == 0xffff) #define WIFSTOPPED(x) ((x & 0177) == 0177 && !WIFCONTINUED(x)) Our definition of WIFSTOPPED forgot the !WIFCONTINUED(x) condition. Siince the wait(3p) status for "continued" is 0xffff, this causes WIFSTOPPED to return true for continued child processes. Fix this. Originally reported at https://github.com/fish-shell/fish-shell/issues/12929 (backport ) (cherry picked from commit a7f62d0fb8759048bb0e83233c6af086c54d6d2c) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 6d17b6cda50bc..134a4e5fdebbd 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1876,7 +1876,7 @@ f! { } pub const safe fn WIFSTOPPED(status: c_int) -> bool { - (status & 0o177) == 0o177 + (status & 0o177) == 0o177 && !WIFCONTINUED(status) } pub const safe fn WIFCONTINUED(status: c_int) -> bool { From 7512ef462545f26fddf0c9978e75a02370cc7d64 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 4 Sep 2026 06:04:43 +0000 Subject: [PATCH 88/88] apple: Disable most `mach` API on Apple mobile OSs Backporting the apple-*OS CI fixes around c859fcc87e9a ("Use cargo-apple-runner for testing iOS and tvOS") fails on this branch with errors like: cargo:warning=/Applications/Xcode_26.6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator26.5.sdk/usr/include/mach/mach_vm.h:1:2: error: mach_vm.h unsupported. cargo:warning= 1 | #error mach_vm.h unsupported. cargo:warning= | ^ cargo:warning=/Users/runner/work/libc/libc/target/aarch64-apple-ios-sim/debug/build/libc-test/334ed535de220e54/out/ctest_output.c:37154:29: error: use of undeclared identifier 'mach_vm_map' cargo:warning= 37154 | return (ctest_void_func)mach_vm_map; cargo:warning= | ^~~~~~~~~~~ cargo:warning=2 errors generated. The mach API has long been deprecated anyway, so disable remove it on iOS, watchOS, visionOS, and tvOS. --- libc-test/build/main.rs | 8 ++++---- libc-test/semver/apple.txt | 13 ------------- libc-test/semver/macos.txt | 13 +++++++++++++ src/unix/bsd/apple/mod.rs | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 3700be8fef6bd..f2d787fdc1f72 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -172,11 +172,11 @@ fn test_apple(t: &Target) { "limits.h", "locale.h", "mach-o/dyld.h", - "mach/mach_init.h", + (macos, "mach/mach_init.h"), "mach/mach.h", - "mach/mach_time.h", - "mach/mach_types.h", - "mach/mach_vm.h", + (macos, "mach/mach_time.h"), + (macos, "mach/mach_types.h"), + (macos, "mach/mach_vm.h"), "mach/thread_act.h", "mach/thread_policy.h", "malloc/malloc.h", diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index e5ee820cc001c..3ab27db12416f 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1873,10 +1873,6 @@ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ __darwin_mcontext64 __error -_dyld_get_image_header -_dyld_get_image_name -_dyld_get_image_vmaddr_slide -_dyld_image_count abs acct aio_cancel @@ -2043,18 +2039,9 @@ lockf log2phys login_tty lutimes -mach_absolute_time mach_error_string mach_error_t -mach_header -mach_header_64 -mach_host_self -mach_port_t -mach_thread_self -mach_timebase_info -mach_timebase_info_data_t mach_vm_address_t -mach_vm_map mach_vm_offset_t mach_vm_size_t madvise diff --git a/libc-test/semver/macos.txt b/libc-test/semver/macos.txt index 306366e964c96..ceba7a449d8be 100644 --- a/libc-test/semver/macos.txt +++ b/libc-test/semver/macos.txt @@ -166,6 +166,10 @@ SYSPROTO_EVENT UTUN_OPT_FLAGS UTUN_OPT_IFNAME __c_anonymous_bfl_u +_dyld_get_image_header +_dyld_get_image_name +_dyld_get_image_vmaddr_slide +_dyld_image_count arphdr bpf_dltlist bpf_hdr @@ -188,6 +192,15 @@ icmp6_ifstat in6_addrlifetime in6_ifreq in6_ifstat +mach_absolute_time +mach_header +mach_header_64 +mach_host_self +mach_port_t +mach_thread_self +mach_timebase_info +mach_timebase_info_data_t +mach_vm_map memmem proc_bsdinfo proc_bsdshortinfo diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c8bd71179efeb..2a953eda0b07d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -176,6 +176,7 @@ pub type copyfile_callback_t = Option< pub type attrgroup_t = u32; pub type vol_capabilities_set_t = [u32; 4]; +#[cfg(target_os = "macos")] deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } @@ -304,6 +305,7 @@ s! { pub ai_next: *mut addrinfo, } + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub struct mach_timebase_info { pub numer: u32, @@ -685,6 +687,7 @@ s! { pub cr_groups: [crate::gid_t; 16], } + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub struct mach_header { pub magic: u32, @@ -696,6 +699,7 @@ s! { pub flags: u32, } + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub struct mach_header_64 { pub magic: u32, @@ -4577,13 +4581,17 @@ extern "C" { newp: *mut c_void, newlen: size_t, ) -> c_int; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_absolute_time() -> u64; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn mach_timebase_info(info: *mut crate::mach_timebase_info) -> c_int; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_host_self() -> mach_port_t; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_thread_self() -> mach_port_t; pub fn pthread_cond_timedwait_relative_np( @@ -4868,13 +4876,17 @@ extern "C" { #[cfg(not(any(target_os = "tvos", target_os = "watchos")))] pub fn sbrk(increment: c_int) -> *mut c_void; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_image_count() -> u32; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> intptr_t; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_name(image_index: u32) -> *const c_char; @@ -5085,6 +5097,7 @@ extern "C" { pub fn _NSGetEnviron() -> *mut *mut *mut c_char; pub fn _NSGetProgname() -> *mut *mut c_char; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_vm_map( target_task: crate::vm_map_t, @@ -5127,6 +5140,7 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> crate::kern_return_t; + #[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub static mut mach_task_self_: crate::mach_port_t; pub fn task_for_pid( @@ -5252,6 +5266,7 @@ extern "C" { } #[allow(deprecated)] +#[cfg(target_os = "macos")] #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub unsafe fn mach_task_self() -> crate::mach_port_t { mach_task_self_