From 8f9ea89c2ac97685db84f5e9b496b52f61e6ed3f Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 6 Apr 2024 15:01:49 +0200 Subject: [PATCH 01/58] Avoid usage of thread_local on DragonFlyBSD __error() has been deprecated and return the same value as __errno_location(). Removing the __error() function eliminates the sole use of thread_local in this crate. (backport ) (cherry picked from commit de76fee6985da570d52bbc3a803967516f51e229) [ resolved conflicts in all files and removed the now-unused `rustc_dep_of_std` - Trevor ] --- build.rs | 7 ------- libc-test/build.rs | 4 ---- src/lib.rs | 1 - src/unix/bsd/freebsdlike/dragonfly/errno.rs | 17 ----------------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 8 -------- 5 files changed, 37 deletions(-) delete mode 100644 src/unix/bsd/freebsdlike/dragonfly/errno.rs diff --git a/build.rs b/build.rs index 802ea7a37def0..2941fdf55a0f9 100644 --- a/build.rs +++ b/build.rs @@ -18,7 +18,6 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `_TIME_BITS=64` in glibc "gnu_time_bits64", "libc_deny_warnings", - "libc_thread_local", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", @@ -47,7 +46,6 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); - let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); @@ -143,11 +141,6 @@ fn main() { set_cfg("libc_deny_warnings"); } - // #[thread_local] is currently unstable - if rustc_dep_of_std { - set_cfg("libc_thread_local"); - } - // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to // avoid warnings. if rustc_minor_ver >= 80 { diff --git a/libc-test/build.rs b/libc-test/build.rs index 184b5c60443fb..de7292423190c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -72,10 +72,6 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); cfg.skip_private(true); - let libc_cfgs = ["libc_thread_local"]; - for f in &libc_cfgs { - cfg.cfg(f, None); - } cfg } diff --git a/src/lib.rs b/src/lib.rs index aa919b5ca038e..846c2189b79ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,6 @@ #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] -#![cfg_attr(libc_thread_local, feature(thread_local))] #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] diff --git a/src/unix/bsd/freebsdlike/dragonfly/errno.rs b/src/unix/bsd/freebsdlike/dragonfly/errno.rs deleted file mode 100644 index 874c1da84d3a5..0000000000000 --- a/src/unix/bsd/freebsdlike/dragonfly/errno.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::prelude::*; - -/* DIFF(main): module removed in de76fee6 */ - -// DragonFlyBSD's __error function is declared with "static inline", so it must -// be implemented in the libc crate, as a pointer to a static thread_local. -f! { - #[deprecated(since = "0.2.77", note = "Use `__errno_location()` instead")] - pub fn __error() -> *mut c_int { - &mut errno - } -} - -extern "C" { - #[thread_local] - pub static mut errno: c_int; -} diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 8720bf7fb3649..582e812796cf2 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1625,11 +1625,3 @@ extern "C" { entry: vm_map_entry_t, ) -> vm_map_entry_t; } - -// DIFF(main): module removed in de76fee6 -cfg_if! { - if #[cfg(libc_thread_local)] { - mod errno; - pub use self::errno::*; - } -} From af9f9bce5febe6ff8218f1886bec7f5c199e09eb Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 26 Sep 2025 17:19:02 +0200 Subject: [PATCH 02/58] Simplify rustc-check-cfg emission in build.rs (backport ) (cherry picked from commit f093797507209552c90b1d7fca6de402f0506348) --- build.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index 2941fdf55a0f9..0d1cef6440570 100644 --- a/build.rs +++ b/build.rs @@ -145,19 +145,11 @@ fn main() { // avoid warnings. if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({cfg})"); - } else { - println!("cargo:rustc-check-cfg=values({cfg})"); - } + println!("cargo:rustc-check-cfg=cfg({cfg})"); } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); - } else { - println!("cargo:rustc-check-cfg=values({name},\"{values}\")"); - } + println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } } } From 9121031973d75e8157668325c88b718bab6fcb7d Mon Sep 17 00:00:00 2001 From: Henry Chen Date: Wed, 8 Oct 2025 11:38:42 +0800 Subject: [PATCH 03/58] libc-test: add mips to the sys_memfd_secret skip list (backport ) (cherry picked from commit 6f15928d59a4dd6f787cbfd60b1e22102a6e2e09) --- libc-test/build.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index de7292423190c..7ba1ef3ab3936 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3738,6 +3738,7 @@ fn test_linux(target: &str) { let loongarch64 = target.contains("loongarch64"); let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); + let mips = target.contains("mips"); let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); let old_musl = musl && !musl_v1_2_3; @@ -4434,8 +4435,8 @@ fn test_linux(target: &str) { // FIXME(linux): Not yet implemented on sparc64 "SYS_clone3" if sparc64 => true, - // FIXME(linux): Not defined on ARM, gnueabihf, musl, PowerPC, riscv64, s390x, and sparc64. - "SYS_memfd_secret" if arm | gnueabihf | musl | ppc | riscv64 | s390x | sparc64 => true, + // 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 => true, // FIXME(linux): Added in Linux 5.16 // https://github.com/torvalds/linux/commit/039c0ec9bb77446d7ada7f55f90af9299b28ca49 From a36153ba6341e65eb8ff8569c6f607da6aa13ac6 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 10 Oct 2025 20:53:13 +0100 Subject: [PATCH 04/58] addinh issetugid() to *BSD based systems. close #4722 (backport ) (cherry picked from commit 01cb1e3633611e08ab30870f7ed8064ccb352785) --- libc-test/semver/apple.txt | 1 + libc-test/semver/dragonfly.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + src/unix/bsd/mod.rs | 2 ++ 6 files changed, 7 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 1d340bd54929d..e9fb9cb31fb12 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2033,6 +2033,7 @@ initgroups integer_t ip_mreqn ipc_perm +issetugid kern_return_t kevent kevent64 diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 6c2a3a0d2e4e0..6d41c8c6cabd9 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1403,6 +1403,7 @@ if_nameindex ifaddrs in6_pktinfo initgroups +issetugid jrand48 kevent killpg diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index cebe46464eebf..e027d25d2b222 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2052,6 +2052,7 @@ input_absinfo input_event ip_mreqn ipc_perm +issetugid jail jail_attach jail_get diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 5821466cc8ddf..bcd25eca15b93 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1402,6 +1402,7 @@ in6_pktinfo in_pktinfo initgroups ipc_perm +issetugid itimerspec jrand48 kevent diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index cfb234fdfa3d1..412ba5a4bd481 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1173,6 +1173,7 @@ initgroups ip_mreqn ipc_perm iso_args +issetugid jrand48 kevent key_t diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 24531db853145..dd1c59907e881 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -945,6 +945,8 @@ extern "C" { ) -> size_t; pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; + + pub fn issetugid() -> c_int; } cfg_if! { From 6d21ccaff4fb6a1d2c4e50274518344245ff51b2 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Tue, 30 Sep 2025 22:24:40 -0400 Subject: [PATCH 05/58] add HWCAP consts (backport ) (cherry picked from commit e5b77756f0a66d784144ebf8ff6f41c619fd19cc) --- libc-test/build.rs | 9 +++++++++ libc-test/semver/android.txt | 2 ++ libc-test/semver/freebsd.txt | 2 ++ libc-test/semver/linux.txt | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ src/unix/linux_like/android/mod.rs | 2 ++ src/unix/linux_like/linux/mod.rs | 2 ++ 7 files changed, 21 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7ba1ef3ab3936..bebc0432a77c0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2233,6 +2233,9 @@ fn test_android(target: &str) { // FIXME(android): Requires >= 6.12 kernel headers. "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + // FIXME(android): Requires >= 6.9 kernel headers. + "AT_HWCAP3" | "AT_HWCAP4" => true, + _ => false, } }); @@ -2829,6 +2832,9 @@ fn test_freebsd(target: &str) { // FIXME(deprecated): deprecated in 0.2, removed in main "TIOCMGDTRWAIT" | "TIOCMSDTRWAIT" => true, + // Added in FreeBSD 15 + "AT_HWCAP3" | "AT_HWCAP4" if Some(15) > freebsd_ver => true, + _ => false, } }); @@ -4733,6 +4739,9 @@ fn test_linux(target: &str) { // FIXME(linux): Value changed in 6.14 "SECURE_ALL_BITS" | "SECURE_ALL_LOCKS" => true, + // FIXME(linux): Requires >= 6.9 kernel headers. + "AT_HWCAP3" | "AT_HWCAP4" => true, + _ => false, } }); diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 53ab742cf2a6a..644aeaa6667b9 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -150,6 +150,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_IGNORE AT_MINSIGSTKSZ AT_NOTELF diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index e027d25d2b222..baf07600f5b12 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -96,6 +96,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_NCPUS AT_NOTELF AT_NULL diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 318cca51b482e..7b002718e123d 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -168,6 +168,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_IGNORE AT_MINSIGSTKSZ AT_NOTELF diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a5166d4e15c75..2b601bd203808 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3807,6 +3807,8 @@ pub const AT_HWCAP: c_int = 25; pub const AT_HWCAP2: c_int = 26; pub const AT_USRSTACKBASE: c_int = 35; pub const AT_USRSTACKLIM: c_int = 36; +pub const AT_HWCAP3: c_int = 38; +pub const AT_HWCAP4: c_int = 39; pub const TABDLY: crate::tcflag_t = 0x00000004; pub const TAB0: crate::tcflag_t = 0x00000000; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fbd8ac2f87cfc..fa2fd4e63dc55 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3508,6 +3508,8 @@ pub const AT_RANDOM: c_ulong = 25; pub const AT_HWCAP2: c_ulong = 26; pub const AT_RSEQ_FEATURE_SIZE: c_ulong = 27; pub const AT_RSEQ_ALIGN: c_ulong = 28; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; pub const AT_EXECFN: c_ulong = 31; pub const AT_MINSIGSTKSZ: c_ulong = 51; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 14401077479ed..8b8711d8ae960 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2544,6 +2544,8 @@ pub const AT_BASE_PLATFORM: c_ulong = 24; pub const AT_RANDOM: c_ulong = 25; pub const AT_HWCAP2: c_ulong = 26; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value From 1635ee1b0b6a70a195f1e2446acdbf45b61d9953 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 14 Oct 2025 20:44:03 +0900 Subject: [PATCH 06/58] Ignore false-positive warning (backport ) (cherry picked from commit 615224fb019c6ba3cfa79d19ad7b115063c25bb6) --- libc-test/tests/cmsg.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index bb832f1ba3d54..893dd56dba266 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -29,6 +29,7 @@ mod t { } #[test] + #[allow(unused_assignments)] // false-positive: https://github.com/rust-lang/rust/issues/147648 fn test_cmsg_firsthdr() { let mut buf = [0u8; 256]; let mut mhdr: msghdr = unsafe { mem::zeroed() }; From 411ba5ac41d6a598af4ded71d38454b4919264d1 Mon Sep 17 00:00:00 2001 From: mounten Date: Sat, 20 Sep 2025 14:21:45 +0200 Subject: [PATCH 07/58] added cfmakeraw definition for target_os = nto (backport ) (cherry picked from commit 8423131190d02ba25e7d2336178f71ca1eabbd1a) --- src/unix/mod.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6ba5d87de7ca0..c734838f88a47 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1825,16 +1825,12 @@ cfg_if! { } cfg_if! { - if #[cfg(target_os = "aix")] { + if #[cfg(any(target_os = "aix", target_os = "nto"))] { extern "C" { pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; } - } else if #[cfg(not(any( - target_os = "solaris", - target_os = "illumos", - target_os = "nto", - )))] { + } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] { extern "C" { pub fn cfmakeraw(termios: *mut crate::termios); pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; From 4a43b7b5e3ed623afb492fabed0bff99be15dac4 Mon Sep 17 00:00:00 2001 From: mounten Date: Mon, 22 Sep 2025 19:55:47 +0200 Subject: [PATCH 08/58] added cfsetspeed definition for target_os = nto and target_env = nto80 (backport ) (cherry picked from commit 6e1b073e3e4032d4bf7ade404a347cf9f82e08cb) --- src/unix/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c734838f88a47..2473a8ff7462d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1828,11 +1828,28 @@ cfg_if! { if #[cfg(any(target_os = "aix", target_os = "nto"))] { extern "C" { pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; - pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; } } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] { extern "C" { pub fn cfmakeraw(termios: *mut crate::termios); + } + } +} + +cfg_if! { + if #[cfg(any( + target_os = "aix", + all(target_os = "nto", target_env = "nto80") + ))] { + extern "C" { + pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + } + } else if #[cfg(not(any( + target_os = "solaris", + target_os = "illumos", + target_os = "nto" + )))] { + extern "C" { pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; } } From 149e37ba9e3562aee984068443e9c9fb6b7a7c2b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 14 Oct 2025 07:23:08 -0700 Subject: [PATCH 09/58] Add more wasi definitions for libstd This commit fills out definitions in libc for rust-lang/rust#147572 notably filling out some fs-related functions as well as many pthread-related functions. The pthread-related functions were not available originally with wasi-libc but nowadays are stubs for single-threaded behavior. The goal is to make wasi targets more "unix like" in libstd and have less WASI-specific code. (backport ) (cherry picked from commit 702efb9616289032ceed5a481a03709506591112) --- libc-test/build.rs | 1 + src/wasi/mod.rs | 116 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index bebc0432a77c0..6adc1dcff0a87 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1769,6 +1769,7 @@ fn test_wasi(target: &str) { [p2]: "netinet/in.h", [p2]: "netinet/tcp.h", "poll.h", + "pthread.h", "sched.h", "stdbool.h", "stddef.h", diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index bb3b729548780..f6253283e53c3 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -33,6 +33,10 @@ pub type wchar_t = i32; pub type nl_item = c_int; pub type __wasi_rights_t = u64; pub type locale_t = *mut __locale_struct; +pub type pthread_t = *mut c_void; +pub type pthread_once_t = c_int; +pub type pthread_key_t = c_uint; +pub type pthread_spinlock_t = c_int; s_no_extra_traits! { #[repr(align(16))] @@ -170,6 +174,47 @@ s! { __nfds: usize, __fds: [c_int; FD_SETSIZE as usize], } + + #[repr(align(4))] + pub struct pthread_attr_t { + size: [u8; 36], + } + + pub struct pthread_mutexattr_t { + __attr: c_uint, + } + + pub struct pthread_condattr_t { + __attr: c_uint, + } + + pub struct pthread_barrierattr_t { + __attr: c_uint, + } + + pub struct pthread_rwlockattr_t { + __attr: [c_uint; 2], + } + + #[repr(align(4))] + pub struct pthread_cond_t { + size: [u8; 48], + } + + #[repr(align(4))] + pub struct pthread_mutex_t { + size: [u8; 24], + } + + #[repr(align(4))] + pub struct pthread_rwlock_t { + size: [u8; 32], + } + + #[repr(align(4))] + pub struct pthread_barrier_t { + size: [u8; 20], + } } // Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash, @@ -262,7 +307,9 @@ pub const DT_BLK: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 3; pub const DT_REG: u8 = 4; +pub const DT_FIFO: u8 = 6; pub const DT_LNK: u8 = 7; +pub const DT_SOCK: u8 = 20; pub const FIONREAD: c_int = 1; pub const FIONBIO: c_int = 2; pub const F_OK: c_int = 0; @@ -438,6 +485,9 @@ pub const NOEXPR: crate::nl_item = 0x50001; pub const YESSTR: crate::nl_item = 0x50002; pub const NOSTR: crate::nl_item = 0x50003; +pub const PTHREAD_STACK_MIN: usize = 2048; +pub const TIMER_ABSTIME: c_int = 1; + f! { pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let set = &*set; @@ -843,6 +893,72 @@ extern "C" { pub fn arc4random_uniform(a: u32) -> u32; pub fn __errno_location() -> *mut c_int; + + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; + + pub fn pthread_self() -> pthread_t; + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int; + pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int; + pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_detach(thread: pthread_t) -> c_int; + + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; } cfg_if! { From f24ed8024e9958af9de5bdf40fe3903b06e803e4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 14 Oct 2025 07:48:25 -0700 Subject: [PATCH 10/58] Update wasi-sdk used in testing (backport ) (cherry picked from commit 3fb070e707b3f77f67270d594f0eb00e0b646712) --- ci/wasi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/wasi.sh b/ci/wasi.sh index 4928681b0a270..19aa57e608542 100755 --- a/ci/wasi.sh +++ b/ci/wasi.sh @@ -12,7 +12,7 @@ apt-get install -y --no-install-recommends \ # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. # Download appropriate versions here and configure various flags below. wasmtime=35.0.0 -wasi_sdk=25 +wasi_sdk=27 curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | tar xJf - From a8aeda6d6f0771858735e28f6926519099939eb9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 15 Oct 2025 07:46:56 -0700 Subject: [PATCH 11/58] More closely align pthread type reprs (backport ) (cherry picked from commit 06a5ca218d6fa4a69b01a27c4c96febab9c1d608) --- src/wasi/mod.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index f6253283e53c3..d6979dd857318 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -175,9 +175,8 @@ s! { __fds: [c_int; FD_SETSIZE as usize], } - #[repr(align(4))] pub struct pthread_attr_t { - size: [u8; 36], + size: [c_long; 9], } pub struct pthread_mutexattr_t { @@ -196,24 +195,20 @@ s! { __attr: [c_uint; 2], } - #[repr(align(4))] pub struct pthread_cond_t { - size: [u8; 48], + size: [*mut c_void; 12], } - #[repr(align(4))] pub struct pthread_mutex_t { - size: [u8; 24], + size: [*mut c_void; 6], } - #[repr(align(4))] pub struct pthread_rwlock_t { - size: [u8; 32], + size: [*mut c_void; 8], } - #[repr(align(4))] pub struct pthread_barrier_t { - size: [u8; 20], + size: [*mut c_void; 5], } } From d9c627ffa5ee332ff8afd6865b793a0133df3ac4 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 17 Oct 2025 15:07:05 +0200 Subject: [PATCH 12/58] Remove rogue definition of SIGSTKFLT for mips32-linux-musl Linux' arch/mips/include/uapi/asm/signal.h does not define SIGSTKFLT. For one MIPS architecture, we define it as 7 for unknown reasons, but 7 is already SIGEMT. This is confusing and probably useless. Remove it. [ squashed JohnTitor's commit deleting the changelog entry - Trevor ] (backport ) (cherry picked from commit bf0ea47dda26b3356f1c8c8716c7a70dba2a03a5) --- src/unix/linux_like/linux/musl/b32/mips/mod.rs | 1 - 1 file changed, 1 deletion(-) 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 a623ff9a9f757..7564dcf612f9c 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -363,7 +363,6 @@ 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 SIGSTKFLT: c_int = 7; pub const SIGPOLL: c_int = crate::SIGIO; pub const SIGPWR: c_int = 19; pub const SIG_SETMASK: c_int = 3; From 1f80843f8d33ae4286acad089750126778150538 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 3 Nov 2025 04:24:36 -0600 Subject: [PATCH 13/58] test: Upgrade to the latest `ctest` beta release Pick up the fixes that have been added on `main`. --- Cargo.lock | 67 +++++++++++++++++++++++++++----------------- libc-test/Cargo.toml | 2 +- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46bd7a6704f01..512d405c94c07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,10 +80,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.32" +version = "1.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" +checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" dependencies = [ + "find-msvc-tools", "shlex", ] @@ -99,9 +100,9 @@ version = "0.1.0" [[package]] name = "ctest" -version = "0.5.0-beta.0" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3dc06650f831a3845f2493213c01ebe1dc1cd7bea271d26766a38dc6e72a3f" +checksum = "dc1a85629f6b82fee991771a8e3b927a8a082e12e4bb48b64a43e55476d27b10" dependencies = [ "askama", "cc", @@ -111,6 +112,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" + [[package]] name = "glob" version = "0.3.2" @@ -137,7 +144,7 @@ dependencies = [ "annotate-snippets", "cc", "cfg-if", - "ctest 0.5.0-beta.0", + "ctest 0.5.0-beta.1", "glob", "libc", "proc-macro2", @@ -147,9 +154,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "percent-encoding" @@ -159,18 +166,18 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -224,18 +231,27 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -244,14 +260,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -262,9 +279,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" dependencies = [ "proc-macro2", "quote", @@ -273,18 +290,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -293,9 +310,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-width" diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 4ae4a3cd2056f..9ebac5ba11808 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -21,7 +21,7 @@ annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] cc = "1.2.29" # Use the in-tree `ctest` from the `main` branch via crates.io -ctest = "0.5.0-beta.0" +ctest = "0.5.0-beta.1" regex = "1.11.1" [features] From 9044bfcff242703e3252543831ddc9a1a6ba1dfb Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Mon, 15 Sep 2025 16:58:44 -0400 Subject: [PATCH 14/58] Add 'ucontext_t' and related structures and functions. (backport ) (cherry picked from commit 5ab43ebf0fc1c2b13d594e51d084b08e7760cd7a) --- libc-test/semver/linux-gnu-powerpc64.txt | 15 ++++ .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 84 +++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/libc-test/semver/linux-gnu-powerpc64.txt b/libc-test/semver/linux-gnu-powerpc64.txt index 148688c5ff20d..46aa2db2cfdd3 100644 --- a/libc-test/semver/linux-gnu-powerpc64.txt +++ b/libc-test/semver/linux-gnu-powerpc64.txt @@ -10,5 +10,20 @@ KEYCTL_CAPS0_RESTRICT_KEYRING KEYCTL_CAPS1_NS_KEYRING_NAME KEYCTL_CAPS1_NS_KEY_TAG KEYCTL_MOVE +__NFPREG +__NGREG +__NVRREG +clone_args +fpregset_t +getcontext +gregset_t +makecontext max_align_t +mcontext_t +pt_regs +setcontext +swapcontext sysctl +ucontext_t +vrregset_t +vscr_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 047efe55b1a38..00e47647a44d8 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -9,6 +9,8 @@ pub type blksize_t = i64; pub type suseconds_t = i64; pub type __u64 = c_ulong; pub type __s64 = c_long; +pub type gregset_t = [c_ulong; __NGREG]; +pub type fpregset_t = [c_ulong; __NFPREG]; s! { // FIXME(1.0): This should not implement `PartialEq` @@ -191,6 +193,21 @@ s! { pub ss_flags: c_int, pub ss_size: size_t, } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } } s_no_extra_traits! { @@ -198,6 +215,64 @@ s_no_extra_traits! { pub struct max_align_t { priv_: [i64; 4], } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + pub struct pt_regs { + pub gpr: [c_ulong; 32], + pub nip: c_ulong, + pub msr: c_ulong, + pub orig_gpr3: c_ulong, + pub ctr: c_ulong, + pub link: c_ulong, + pub xer: c_ulong, + pub ccr: c_ulong, + pub softe: c_ulong, + pub trap: c_ulong, + pub dar: c_ulong, + pub dsisr: c_ulong, + pub result: c_ulong, + } + + pub struct mcontext_t { + __glibc_reserved: [c_ulong; 4], + pub signal: c_int, + __pad0: c_int, + pub handler: c_ulong, + pub oldmask: c_ulong, + pub regs: *mut pt_regs, + pub gp_regs: crate::gregset_t, + pub fp_regs: crate::fpregset_t, + pub v_regs: *mut vrregset_t, + pub vmx_reserve: [c_long; __NVRREG + __NVRREG + 1], + } + + #[repr(align(16))] + pub struct vrregset_t { + pub vrregs: [[c_uint; 4]; 32], + pub vscr: vscr_t, + pub vrsave: c_uint, + __pad: [c_uint; 3], + } + + #[repr(align(4))] + pub struct vscr_t { + #[cfg(target_endian = "big")] + __pad: [c_uint; 3], + #[cfg(target_endian = "big")] + pub vscr_word: c_uint, + + #[cfg(target_endian = "little")] + pub vscr_word: c_uint, + #[cfg(target_endian = "little")] + __pad: [c_uint; 3], + } } pub const POSIX_FADV_DONTNEED: c_int = 4; @@ -210,6 +285,10 @@ pub const VEOF: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __NGREG: usize = 48; +pub const __NFPREG: usize = 33; +pub const __NVRREG: usize = 34; + pub const O_APPEND: c_int = 1024; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; @@ -971,4 +1050,9 @@ extern "C" { newp: *mut c_void, newlen: size_t, ) -> c_int; + + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn swapcontext(oucp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); } From 0b83b6758bf491af2b64366d9f08386cde0d3ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 2 Jul 2025 17:21:51 +0000 Subject: [PATCH 15/58] Move keyctl to new/linux_uapi These constants are entirely defined in the Linux UAPI. https://elixir.bootlin.com/linux/v6.16.9/source/include/uapi/linux/keyctl.h (backport ) (cherry picked from commit 2bf1f66ea4a4c0061bed58efe6fc6d5891a8cb0a) --- src/new/linux_uapi/linux/keyctl.rs | 70 ++++++++++++++++++++++++++++ src/new/linux_uapi/linux/mod.rs | 2 + src/unix/linux_like/linux/gnu/mod.rs | 36 -------------- src/unix/linux_like/linux/mod.rs | 44 ----------------- 4 files changed, 72 insertions(+), 80 deletions(-) create mode 100644 src/new/linux_uapi/linux/keyctl.rs diff --git a/src/new/linux_uapi/linux/keyctl.rs b/src/new/linux_uapi/linux/keyctl.rs new file mode 100644 index 0000000000000..2c86df39e190b --- /dev/null +++ b/src/new/linux_uapi/linux/keyctl.rs @@ -0,0 +1,70 @@ +//! Header: `uapi/linux/keyctl.h` + +// linux/keyctl.h +pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; +pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; +pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; +pub const KEY_SPEC_USER_KEYRING: i32 = -4; +pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; +pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; +pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; +pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; + +pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; +pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; +pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; +pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; +pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; +pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; +pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; +pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; +pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; + +pub const KEYCTL_GET_KEYRING_ID: u32 = 0; +pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; +pub const KEYCTL_UPDATE: u32 = 2; +pub const KEYCTL_REVOKE: u32 = 3; +pub const KEYCTL_CHOWN: u32 = 4; +pub const KEYCTL_SETPERM: u32 = 5; +pub const KEYCTL_DESCRIBE: u32 = 6; +pub const KEYCTL_CLEAR: u32 = 7; +pub const KEYCTL_LINK: u32 = 8; +pub const KEYCTL_UNLINK: u32 = 9; +pub const KEYCTL_SEARCH: u32 = 10; +pub const KEYCTL_READ: u32 = 11; +pub const KEYCTL_INSTANTIATE: u32 = 12; +pub const KEYCTL_NEGATE: u32 = 13; +pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; +pub const KEYCTL_SET_TIMEOUT: u32 = 15; +pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; +pub const KEYCTL_GET_SECURITY: u32 = 17; +pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; +pub const KEYCTL_REJECT: u32 = 19; +pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; +pub const KEYCTL_INVALIDATE: u32 = 21; +pub const KEYCTL_GET_PERSISTENT: u32 = 22; +pub const KEYCTL_DH_COMPUTE: u32 = 23; +pub const KEYCTL_PKEY_QUERY: u32 = 24; +pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; +pub const KEYCTL_PKEY_DECRYPT: u32 = 26; +pub const KEYCTL_PKEY_SIGN: u32 = 27; +pub const KEYCTL_PKEY_VERIFY: u32 = 28; +pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; +pub const KEYCTL_MOVE: u32 = 30; +pub const KEYCTL_CAPABILITIES: u32 = 31; + +pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; +pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; +pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; +pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; + +pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; +pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; +pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; +pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; +pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; +pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; +pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; +pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; +pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; +pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index 4a9c04d6396b1..e264892063807 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -2,3 +2,5 @@ pub(crate) mod can; pub use can::*; +pub(crate) mod keyctl; +pub use keyctl::*; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 17d11d27a4dea..afd9fe3396180 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -892,42 +892,6 @@ pub const CLONE_NEWTIME: c_int = 0x80; pub const CLONE_CLEAR_SIGHAND: c_int = 0x100000000; pub const CLONE_INTO_CGROUP: c_int = 0x200000000; -// linux/keyctl.h -pub const KEYCTL_DH_COMPUTE: u32 = 23; -pub const KEYCTL_PKEY_QUERY: u32 = 24; -pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; -pub const KEYCTL_PKEY_DECRYPT: u32 = 26; -pub const KEYCTL_PKEY_SIGN: u32 = 27; -pub const KEYCTL_PKEY_VERIFY: u32 = 28; -pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; - -pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; -pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; -pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; -pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; -cfg_if! { - if #[cfg(not(any( - target_arch = "mips", - target_arch = "mips32r6", - target_arch = "mips64", - target_arch = "mips64r6" - )))] { - pub const KEYCTL_MOVE: u32 = 30; - pub const KEYCTL_CAPABILITIES: u32 = 31; - - pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; - pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; - pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; - pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; - pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; - pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; - pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; - pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; - pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; - pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; - } -} - pub const M_MXFAST: c_int = 1; pub const M_NLBLKS: c_int = 2; pub const M_GRAIN: c_int = 3; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 8b8711d8ae960..a84ff4ef30f60 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4823,50 +4823,6 @@ const fn issecure_mask(x: c_int) -> c_int { 1 << x } -// linux/keyctl.h -pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; -pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; -pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; -pub const KEY_SPEC_USER_KEYRING: i32 = -4; -pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; -pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; -pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; -pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; - -pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; -pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; -pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; -pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; -pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; -pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; -pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; -pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; -pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; - -pub const KEYCTL_GET_KEYRING_ID: u32 = 0; -pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; -pub const KEYCTL_UPDATE: u32 = 2; -pub const KEYCTL_REVOKE: u32 = 3; -pub const KEYCTL_CHOWN: u32 = 4; -pub const KEYCTL_SETPERM: u32 = 5; -pub const KEYCTL_DESCRIBE: u32 = 6; -pub const KEYCTL_CLEAR: u32 = 7; -pub const KEYCTL_LINK: u32 = 8; -pub const KEYCTL_UNLINK: u32 = 9; -pub const KEYCTL_SEARCH: u32 = 10; -pub const KEYCTL_READ: u32 = 11; -pub const KEYCTL_INSTANTIATE: u32 = 12; -pub const KEYCTL_NEGATE: u32 = 13; -pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; -pub const KEYCTL_SET_TIMEOUT: u32 = 15; -pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; -pub const KEYCTL_GET_SECURITY: u32 = 17; -pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; -pub const KEYCTL_REJECT: u32 = 19; -pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; -pub const KEYCTL_INVALIDATE: u32 = 21; -pub const KEYCTL_GET_PERSISTENT: u32 = 22; - pub const IN_MASK_CREATE: u32 = 0x1000_0000; pub const IN_MASK_ADD: u32 = 0x2000_0000; pub const IN_ISDIR: u32 = 0x4000_0000; From 9b0bdf3b383147e40b76c128bab7095490bd96fc Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 21 Oct 2025 23:25:35 -0400 Subject: [PATCH 16/58] Enable range-diff with triagebot Link: https://forge.rust-lang.org/triagebot/range-diff.html (backport ) (cherry picked from commit 4f8507079f9c905c0abfb8167bc0f0b2e82b0e91) --- triagebot.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index 6a6dfccd18e21..9b27504ffc9ae 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -18,6 +18,11 @@ check-commits = false # don't forbid links to issues # Prevents mentions in commits to avoid users being spammed [no-mentions] +# Enable comments linking to triagebot range-diff when a PR is rebased +# onto a different base commit +# Documentation at: https://forge.rust-lang.org/triagebot/range-diff.html +[range-diff] + [autolabel."A-CI"] trigger_files = [ ".cirrus.yml", From 1cd874f4da5ec6cdfffae8ef7857d88ddb6602b2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 00:17:20 -0400 Subject: [PATCH 17/58] Assert the type created by `c_enum!` Currently there aren't any checks for what happens with `e`. Add one here. (backport ) (cherry picked from commit 1386b8c6470b31cdf2fb86f9244bc2760248a49b) --- src/macros.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 6906da6bd70da..f53f822503c24 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -372,6 +372,8 @@ macro_rules! deprecated_mach { #[cfg(test)] mod tests { + use core::any::TypeId; + use crate::types::CEnumRepr; #[test] @@ -385,6 +387,7 @@ mod tests { } } + assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0 as CEnumRepr); assert_eq!(VAR1, 1 as CEnumRepr); assert_eq!(VAR2, 2 as CEnumRepr); @@ -400,6 +403,7 @@ mod tests { } } + assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0_u16); } From a107ba89327032293f13a2163dfeee06d2693ef5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 00:53:05 -0400 Subject: [PATCH 18/58] Add support for anonymous enums to `c_enum!` C allows omitting the identifier of an enum definition in order to get the incrementing behavior without defining a new type. Add support for this to `c_enum!` by allowing `#anon` to be given as the identifier. The macro `@` matcher names are cleaned up here as well. Co-authored-by: Noa (backport ) (cherry picked from commit 02c4d661d222482ea18dc3baa149e0bed7210f3e) --- ci/style.sh | 7 ++++++ src/macros.rs | 64 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/ci/style.sh b/ci/style.sh index 200cc15cfa16a..c5fddbad1f8b1 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -31,6 +31,12 @@ while IFS= read -r file; do # wouldn't be correct for something like `all(any(...), ...)`). perl -pi -0777 -e 's/if #\[cfg\((.*?)\)\]/if cfg_tmp!([$1])/gms' "$file" + # The `c_enum!` macro allows anonymous enums without names, which + # isn't valid syntax. Replace it with a dummy name and an indicator + # comment on the preceding line (which is where rustfmt puts it. Also + # rust-lang/rustfmt#5464). + perl -pi -e 's/^(\s*)(.*)enum #anon\b/$1\/\* FMT-ANON-ENUM \*\/\n$1$2enum _fmt_anon/g' "$file" + # Format the file. We need to invoke `rustfmt` directly since `cargo fmt` # can't figure out the module tree with the hacks in place. failed=false @@ -39,6 +45,7 @@ while IFS= read -r file; do # Restore all changes to the files. perl -pi -e 's/fn (\w+)_fmt_tmp\(\)/$1!/g' "$file" perl -pi -0777 -e 's/cfg_tmp!\(\[(.*?)\]\)/#[cfg($1)]/gms' "$file" + perl -pi -0777 -e 's/\/\* FMT-ANON-ENUM \*\/(?:\n\s*)?(.*?)enum _fmt_anon/$1enum #anon/gms' "$file" # Defer emitting the failure until after the files get reset if [ "$failed" != "false" ]; then diff --git a/src/macros.rs b/src/macros.rs index f53f822503c24..cb00c8980f44e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -246,36 +246,50 @@ macro_rules! e { /// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main /// purpose is to calculate the correct enum values. /// +/// Use the magic name `#anon` if the C enum doesn't create a type. +/// /// See for more. macro_rules! c_enum { + // Matcher for multiple enums ($( $(#[repr($repr:ty)])? - pub enum $ty_name:ident { + pub enum $($ty_name:ident)? $(#$anon:ident)? { $($variant:ident $(= $value:expr)?,)+ } )+) => { - $(c_enum!(@expand; + $(c_enum!(@single; $(#[repr($repr)])? - pub enum $ty_name { + pub enum $($ty_name)? $(#$anon)? { $($variant $(= $value)?,)+ } );)+ }; - (@expand; + // Matcher for a single enum + (@single; $(#[repr($repr:ty)])? pub enum $ty_name:ident { $($variant:ident $(= $value:expr)?,)+ } ) => { pub type $ty_name = c_enum!(@ty $($repr)?); - c_enum!(@one; $ty_name; 0; $($variant $(= $value)?,)+); + c_enum!(@variant; $ty_name; 0; $($variant $(= $value)?,)+); + }; + + // Matcher for a single anonymous enum + (@single; + $(#[repr($repr:ty)])? + pub enum #anon { + $($variant:ident $(= $value:expr)?,)+ + } + ) => { + c_enum!(@variant; c_enum!(@ty $($repr)?); 0; $($variant $(= $value)?,)+); }; // Matcher for a single variant - (@one; $_ty_name:ident; $_idx:expr;) => {}; + (@variant; $_ty_name:ty; $_idx:expr;) => { /* end of the chain */ }; ( - @one; $ty_name:ident; $default_val:expr; + @variant; $ty_name:ty; $default_val:expr; $variant:ident $(= $value:expr)?, $($tail:tt)* ) => { @@ -288,7 +302,7 @@ macro_rules! c_enum { // The next value is always one more than the previous value, unless // set explicitly. - c_enum!(@one; $ty_name; $variant + 1; $($tail)*); + c_enum!(@variant; $ty_name; $variant + 1; $($tail)*); }; // Use a specific type if provided, otherwise default to `CEnumRepr` @@ -377,7 +391,7 @@ mod tests { use crate::types::CEnumRepr; #[test] - fn c_enumbasic() { + fn c_enum_basic() { // By default, variants get sequential values. c_enum! { pub enum e { @@ -385,30 +399,50 @@ mod tests { VAR1, VAR2, } + + // Also check enums that don't create a type. + pub enum #anon { + ANON0, + ANON1, + ANON2, + } } assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0 as CEnumRepr); assert_eq!(VAR1, 1 as CEnumRepr); assert_eq!(VAR2, 2 as CEnumRepr); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0 as CEnumRepr); + assert_eq!(ANON1, 1 as CEnumRepr); + assert_eq!(ANON2, 2 as CEnumRepr); } #[test] - fn c_enumrepr() { - // By default, variants get sequential values. + fn c_enum_repr() { + // Check specifying the integer representation c_enum! { #[repr(u16)] pub enum e { VAR0, } + + #[repr(u16)] + pub enum #anon { + ANON0, + } } assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0_u16); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0_u16); } #[test] - fn c_enumset_value() { + fn c_enum_set_value() { // Setting an explicit value resets the count. c_enum! { pub enum e { @@ -424,7 +458,7 @@ mod tests { } #[test] - fn c_enummultiple_set_value() { + fn c_enum_multiple_set_value() { // C enums always take one more than the previous value, unless set to a specific // value. Duplicates are allowed. c_enum! { @@ -447,4 +481,8 @@ mod tests { assert_eq!(VAR3_1, 3 as CEnumRepr); assert_eq!(VAR4_1, 4 as CEnumRepr); } + + fn type_id_of_val(_: &T) -> TypeId { + TypeId::of::() + } } From 721e99fbead729dca21617693369cf32aea99f0b Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 17 Oct 2025 15:44:18 +0700 Subject: [PATCH 19/58] redox: add setresgid and setresuid (backport ) (cherry picked from commit e4f9596986e954b76a077558a69a768e870238da) --- libc-test/semver/redox.txt | 2 ++ src/unix/redox/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index b7aaa5706d626..360c0fc29f21a 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -324,6 +324,8 @@ reallocarray rlim_t setgrent setpwent +setresgid +setresuid setrlimit setservent sigqueue diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 50bdaf4d4f06b..ec690cd720793 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1186,6 +1186,8 @@ extern "C" { // unistd.h pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; pub fn getdtablesize() -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; // grp.h pub fn getgrent() -> *mut crate::group; From ef6ffc3ecaea4c65a60ca821718136bca40b04e3 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Fri, 17 Oct 2025 16:10:53 +0700 Subject: [PATCH 20/58] redox: define getresgid and getresuid (backport ) (cherry picked from commit a9ddb5be4d3e286c3d74625f457c101ef8ebb5c9) --- libc-test/semver/redox.txt | 2 ++ src/unix/redox/mod.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 360c0fc29f21a..e993475f20b4b 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -302,6 +302,8 @@ getgrouplist getline getpwent getpwnam_r +getresgid +getresuid getrlimit getrusage getservbyport diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index ec690cd720793..4db2e8d91b35e 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1186,6 +1186,16 @@ extern "C" { // unistd.h pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; pub fn getdtablesize() -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; From 47ff1402c39eeb6fa8202b291c57f09117630abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Wed, 2 Jul 2025 17:44:45 +0000 Subject: [PATCH 21/58] linux-musl-s390x: Add __psw_t/fprefset_t/*context_t https://elixir.bootlin.com/musl/v1.2.5/source/arch/s390x/bits/signal.h (backport ) (cherry picked from commit c7702efc775537274f7f90578bfca92e80debb10) --- src/unix/linux_like/linux/musl/b64/s390x.rs | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 06cc61685b7ac..490d130c65bc4 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -84,6 +84,31 @@ s! { pub f_flags: c_uint, pub f_spare: [c_uint; 4], } + + pub struct __psw_t { + pub mask: c_ulong, + pub addr: c_ulong, + } + + pub struct fpregset_t { + pub fpc: c_uint, + pub fprs: [fpreg_t; 16], + } + + pub struct mcontext_t { + pub psw: __psw_t, + pub gregs: [c_ulong; 16], + pub aregs: [c_uint; 16], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + } } s_no_extra_traits! { From 8e11334e502e675078405e3afe082c25ae030c41 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 21:59:36 -0500 Subject: [PATCH 22/58] ci: Upgrade to the windows-2025 runner (backport ) (cherry picked from commit 22cef5bd0874ddf027d8ead52a6034ec97b0b07f) --- .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 5e074cbce02d9..947fe9c4756e2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: name: Clippy on ${{ matrix.os }} strategy: matrix: - os: [ubuntu-24.04, macos-15, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2025] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: @@ -52,7 +52,7 @@ jobs: strategy: matrix: toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-24.04, macos-15, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2025] include: - toolchain: beta os: ubuntu-24.04 @@ -113,19 +113,19 @@ jobs: - target: aarch64-apple-darwin os: macos-15 - target: x86_64-pc-windows-gnu - os: windows-2022 + os: windows-2025 env: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc - os: windows-2022 + os: windows-2025 # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu # env: # ARCH_BITS: 32 # ARCH: i686 - target: i686-pc-windows-msvc - os: windows-2022 + os: windows-2025 runs-on: ${{ matrix.os }} timeout-minutes: 25 env: From 03ad65ae6e7461ba9c43d493f1755c037175e845 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 22:09:53 -0500 Subject: [PATCH 23/58] MinGW: Set `L_tmpnam` and `TMP_MAX` to the UCRT value With the update to Windows-2025, MinGW is now using the UCRT values for `L_tmpnam` and `TMP_MAX`, which match the MSVC values. Since the values are now identical, consolidate the constants. Link: https://github.com/mingw-w64/mingw-w64/commit/c7c93e36a52fba279a18f508e7cb9a9b0b783e7e Link: https://github.com/mingw-w64/mingw-w64/commit/124ee27ee17871f560398b652c4000cdf8c3798f (backport ) (cherry picked from commit b54769a8454d4bcfbb5f7615bc071c41d9dd45b6) --- libc-test/build.rs | 2 -- src/windows/gnu/mod.rs | 3 --- src/windows/mod.rs | 3 +++ src/windows/msvc/mod.rs | 3 --- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 6adc1dcff0a87..c3af35ca6db78 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -924,8 +924,6 @@ fn test_windows(target: &str) { "SIG_DFL" | "SIG_IGN" | "SIG_GET" | "SIG_SGE" | "SIG_ACK" => true, // FIXME(windows): newer windows-gnu environment on CI? "_O_OBTAIN_DIR" if gnu => true, - // FIXME: These constants have been changed since windows-2022 20251014.68.1: - "L_tmpnam" | "TMP_MAX" => true, _ => false, } }); diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index aee2c1efed108..7ea6a933c8e85 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -18,9 +18,6 @@ cfg_if! { } } -pub const L_tmpnam: c_uint = 14; -pub const TMP_MAX: c_uint = 0x7fff; - // stdio file descriptor numbers pub const STDIN_FILENO: c_int = 0; pub const STDOUT_FILENO: c_int = 1; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 2f35af84c7493..969008c47c675 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -243,6 +243,9 @@ pub const SIG_GET: crate::sighandler_t = 2; pub const SIG_SGE: crate::sighandler_t = 3; pub const SIG_ACK: crate::sighandler_t = 4; +pub const L_tmpnam: c_uint = 260; +pub const TMP_MAX: c_uint = 0x7fff_ffff; + // DIFF(main): removed in 458c58f409 // FIXME(msrv): done by `std` starting in 1.79.0 // inline comment below appeases style checker diff --git a/src/windows/msvc/mod.rs b/src/windows/msvc/mod.rs index 5b620bc6c1afa..967df8c57f8bd 100644 --- a/src/windows/msvc/mod.rs +++ b/src/windows/msvc/mod.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub const L_tmpnam: c_uint = 260; -pub const TMP_MAX: c_uint = 0x7fff_ffff; - // POSIX Supplement (from errno.h) // This particular error code is only currently available in msvc toolchain pub const EOTHER: c_int = 131; From d7a83a3e34cab86ae74995091d2d6a90c8acc94b Mon Sep 17 00:00:00 2001 From: Noa Date: Fri, 29 Aug 2025 15:55:24 -0500 Subject: [PATCH 24/58] Add contents of linux/can/bcm.h (backport ) (cherry picked from commit 62a1fad1cf5cfb472f364d620076600583c97338) --- libc-test/build.rs | 8 +++-- libc-test/semver/linux.txt | 26 +++++++++++++++ src/new/linux_uapi/linux/can.rs | 2 ++ src/new/linux_uapi/linux/can/bcm.rs | 52 +++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/new/linux_uapi/linux/can/bcm.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index c3af35ca6db78..c829cedfa52da 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3882,6 +3882,7 @@ fn test_linux(target: &str) { headers! { cfg: [gnu]: "linux/aio_abi.h", "linux/can.h", + "linux/can/bcm.h", "linux/can/raw.h", "linux/can/j1939.h", "linux/cn_proc.h", @@ -4956,7 +4957,7 @@ fn test_linux(target: &str) { (musl && struct_ == "tcp_info" && field == "tcpi_delivery_fastopen_bitfields") || // either fsid_t or int[2] type (struct_ == "fanotify_event_info_fid" && field == "fsid") || - // `handle` is a VLA + // `handle` is a flexible array member (struct_ == "fanotify_event_info_fid" && field == "handle") || // `anonymous_1` is an anonymous union (struct_ == "ptp_perout_request" && field == "anonymous_1") || @@ -4974,7 +4975,9 @@ fn test_linux(target: &str) { // the `xsk_tx_metadata_union` field is an anonymous union (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || // After musl 1.2.0, the type becomes `int` instead of `long`. - (old_musl && struct_ == "utmpx" && field == "ut_session") + (old_musl && struct_ == "utmpx" && field == "ut_session") || + // `frames` is a flexible array member + (struct_ == "bcm_msg_head" && field == "frames") }); cfg.skip_roundtrip(move |s| match s { @@ -5013,6 +5016,7 @@ fn test_linux(target: &str) { "inotify_event" => true, "fanotify_event_info_fid" => true, "cmsghdr" => true, + "bcm_msg_head" => true, // FIXME(linux): the call ABI of max_align_t is incorrect on these platforms: "max_align_t" if i686 || ppc64 => true, diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 7b002718e123d..f67a02f946527 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -234,6 +234,7 @@ CAN_EFF_ID_BITS CAN_EFF_MASK CAN_ERR_FLAG CAN_ERR_MASK +CAN_FD_FRAME CAN_INV_FILTER CAN_ISOTP CAN_J1939 @@ -2711,6 +2712,17 @@ RT_TOS RUSAGE_CHILDREN RUSAGE_SELF RUSAGE_THREAD +RX_ANNOUNCE_RESUME +RX_CHANGED +RX_CHECK_DLC +RX_DELETE +RX_FILTER_ID +RX_NO_AUTOTIMER +RX_READ +RX_RTR_FRAME +RX_SETUP +RX_STATUS +RX_TIMEOUT SCHED_BATCH SCHED_FIFO SCHED_IDLE @@ -2844,6 +2856,7 @@ SEM_STAT SEM_STAT_ANY SEM_UNDO SETALL +SETTIMER SETVAL SFD_CLOEXEC SFD_NONBLOCK @@ -3088,6 +3101,7 @@ SPLICE_F_MOVE SPLICE_F_NONBLOCK SS_DISABLE SS_ONSTACK +STARTTIMER STICKY_TIMEOUTS ST_APPEND ST_IMMUTABLE @@ -3576,6 +3590,16 @@ TUN_TAP_DEV TUN_TUN_DEV TUN_TX_TIMESTAMP TUN_TYPE_MASK +TX_ANNOUNCE +TX_COUNTEVT +TX_CP_CAN_ID +TX_DELETE +TX_EXPIRED +TX_READ +TX_RESET_MULTI_IDX +TX_SEND +TX_SETUP +TX_STATUS T_FMT T_FMT_AMPM UDP_CORK @@ -3859,6 +3883,8 @@ arpd_request arphdr arpreq arpreq_old +bcm_msg_head +bcm_timeval blkcnt64_t brk bsearch diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index b9479a63bacea..ac1c459fb8a13 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -1,8 +1,10 @@ //! Header: `uapi/linux/can.h` +pub(crate) mod bcm; pub(crate) mod j1939; pub(crate) mod raw; +pub use bcm::*; pub use j1939::*; pub use raw::*; diff --git a/src/new/linux_uapi/linux/can/bcm.rs b/src/new/linux_uapi/linux/can/bcm.rs new file mode 100644 index 0000000000000..2cdeb399b31f3 --- /dev/null +++ b/src/new/linux_uapi/linux/can/bcm.rs @@ -0,0 +1,52 @@ +//! `linux/can/bcm.h` + +pub use crate::linux::can::*; + +s! { + pub struct bcm_timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + pub struct bcm_msg_head { + pub opcode: u32, + pub flags: u32, + pub count: u32, + pub ival1: bcm_timeval, + pub ival2: bcm_timeval, + pub can_id: canid_t, + pub nframes: u32, + pub frames: [can_frame; 0], + } +} + +c_enum! { + #[repr(u32)] + pub enum #anon { + TX_SETUP = 1, + TX_DELETE, + TX_READ, + TX_SEND, + RX_SETUP, + RX_DELETE, + RX_READ, + TX_STATUS, + TX_EXPIRED, + RX_STATUS, + RX_TIMEOUT, + RX_CHANGED, + } +} + +pub const SETTIMER: u32 = 0x0001; +pub const STARTTIMER: u32 = 0x0002; +pub const TX_COUNTEVT: u32 = 0x0004; +pub const TX_ANNOUNCE: u32 = 0x0008; +pub const TX_CP_CAN_ID: u32 = 0x0010; +pub const RX_FILTER_ID: u32 = 0x0020; +pub const RX_CHECK_DLC: u32 = 0x0040; +pub const RX_NO_AUTOTIMER: u32 = 0x0080; +pub const RX_ANNOUNCE_RESUME: u32 = 0x0100; +pub const TX_RESET_MULTI_IDX: u32 = 0x0200; +pub const RX_RTR_FRAME: u32 = 0x0400; +pub const CAN_FD_FRAME: u32 = 0x0800; From 18c5c49bce69951d14b0aa7ea8d5ec4c28db9160 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Fri, 17 Oct 2025 14:20:22 -0400 Subject: [PATCH 25/58] Declare field 'tv_nsec' of structure 'timespec' as 'i32' in both 32-bit and 64-bit modes for AIX. (backport ) (cherry picked from commit 96eb752b067e8acc02abebba9a3aa980e2687c0f) --- libc-test/build.rs | 6 ++++++ src/unix/aix/mod.rs | 9 +++++++++ src/unix/mod.rs | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c829cedfa52da..fc2953da91c75 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5761,6 +5761,12 @@ fn test_aix(target: &str) { // The field 'data' is actually a unnamed union in the AIX header. "pollfd_ext" if field.ident() == "data" => true, + // On AIX, declares 'tv_nsec' as 'long', but the + // underlying system calls return a 32-bit value in both 32-bit + // and 64-bit modes. In the 'libc' crate it is declared as 'i32' + // to match the system call. Skip this field. + "timespec" if field.ident() == "tv_nsec" => true, + _ => false, } }); diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b6d1af52d133c..05ff2fb082900 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -263,6 +263,15 @@ s! { pub tv_nsec: c_int, } + // On AIX, declares 'tv_nsec' as 'long', but the underlying + // system calls return a 4-byte value in both 32-bit and 64-bit modes. + // It is declared as 'c_int' here to avoid using the other undefined 4 + // bytes in the 64-bit mode. + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_int, + } + pub struct statfs64 { pub f_version: c_int, pub f_type: c_int, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 2473a8ff7462d..cb0b687a5c858 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -68,7 +68,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 - #[cfg(not(target_env = "gnu"))] + #[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))] pub struct timespec { pub tv_sec: time_t, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] From 1d370197ce449df342efab29a4b44250ccc916da Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 17:37:14 -0400 Subject: [PATCH 26/58] test: linux: Unskip `statx` and `statx_timestamp` tests The mentioned issues with `#include` no longer seem to happen, so start testing these again. (backport ) (cherry picked from commit 758dc77437ccef55a6901e12121c6b6037afdcf0) --- libc-test/build.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index fc2953da91c75..5f7bca66d3bcd 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4134,12 +4134,6 @@ fn test_linux(target: &str) { // glibcs (see https://github.com/rust-lang/libc/issues/1410) "ucontext_t" if gnu => true, - // FIXME(linux): Somehow we cannot include headers correctly in glibc 2.30. - // So let's ignore for now and re-visit later. - // Probably related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91085 - "statx" => true, - "statx_timestamp" => true, - // On Linux, the type of `ut_exit` field of struct `utmpx` // can be an anonymous struct, so an extra struct, // which is absent in musl, has to be defined. From be3e33451034483297aea99226cdaf59adb4e932 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 17:41:15 -0400 Subject: [PATCH 27/58] test: linux: Unskip `ip_mreqn` and `hwtstamp_config` The reason these failed in the first place was unclear, but they now pass. Closes: https://github.com/rust-lang/libc/issues/1558 (backport ) (cherry picked from commit d4ffc25b20eedc2727501f0a9aa1e139a31e079a) --- libc-test/build.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 5f7bca66d3bcd..934ec12c67d00 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4084,11 +4084,6 @@ fn test_linux(target: &str) { return true; } - // FIXME(#1558): passing by value corrupts the value for reasons not understood. - if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") { - return true; - } - // FIXME(rust-lang/rust#43894): pass by value for structs that are not an even 32/64 bits // on big-endian systems corrupts the value for unknown reasons. if (sparc64 || ppc || ppc64 || s390x) From 86ce777a3f9c4af79b642de5a8f2a8fd97bda54a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 17:52:27 -0400 Subject: [PATCH 28/58] linux: Update the definition for `ucontext_t` and unskip its tests The distributed versions of glibc now have the `__ssp` field, so we can add it here and start testing the type again. A field rename is needed since loongarch calls `__uc_flags` by a different name. (backport ) (cherry picked from commit f9f21cf01d47f395fbbc508be1ee34988fa1f70d) --- libc-test/build.rs | 11 ++++------- src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 6 +----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 934ec12c67d00..162bbea40806a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3991,7 +3991,7 @@ fn test_linux(target: &str) { } }); - cfg.rename_struct_field(|struct_, field| { + cfg.rename_struct_field(move |struct_, field| { let struct_ = struct_.ident(); match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part @@ -4014,6 +4014,9 @@ fn test_linux(target: &str) { Some("type".to_string()) } + // FIXME(1.0): field has a different name on loongarch + "uc_flags" if loongarch64 && struct_ == "ucontext_t" => Some("__uc_flags".to_string()), + _ => None, } }); @@ -4123,12 +4126,6 @@ fn test_linux(target: &str) { // structs. "termios2" => true, - // FIXME(linux): remove once we set minimum supported glibc version. - // ucontext_t added a new field as of glibc 2.28; our struct definition is - // conservative and omits the field, but that means the size doesn't match for newer - // glibcs (see https://github.com/rust-lang/libc/issues/1410) - "ucontext_t" if gnu => true, - // On Linux, the type of `ut_exit` field of struct `utmpx` // can be an anonymous struct, so an extra struct, // which is absent in musl, has to be defined. 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 f4555ee420230..cf871f2a7d84a 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 @@ -310,11 +310,7 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: crate::sigset_t, __private: [u8; 512], - // FIXME(glibc): the shadow stack field requires glibc >= 2.28. - // Re-add once we drop compatibility with glibc versions older than - // 2.28. - // - // __ssp: [c_ulonglong; 4], + __ssp: [c_ulonglong; 4], } #[repr(align(16))] From 2ff345c2810538f3291b6dc66cbf43ae8da54b2c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 17:56:37 -0400 Subject: [PATCH 29/58] test: linux: Unskip `clone_args` and `open_how` The concerns about changing across versions was resolved a long time ago. However, there is still a mismatch on PowerPC64, so a specific skip is added for now. (backport ) (cherry picked from commit dec14b0868843d288c195a5053d9fdf74222ce49) --- libc-test/build.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 162bbea40806a..8299c6aa7dde9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4131,11 +4131,9 @@ fn test_linux(target: &str) { // which is absent in musl, has to be defined. "__exit_status" if musl => true, - // clone_args might differ b/w libc versions - "clone_args" => true, - - // Might differ between kernel versions - "open_how" => true, + // FIXME(ppc): tests fail due to a field type mismatch (`long long unsigned` vs + // `long unsigned`). + "clone_args" if ppc64 => true, // Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15) // Might differ between kernel versions From 8a020ceca3bc8d1b4862112fb73b92fd642669bf Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 18:33:59 -0400 Subject: [PATCH 30/58] linux: Remove incorrect `repr(align(8))` for `canxl_frame` `can_frame` and `canfd_frame` need this, but `canxl_frame` does not. This was causing the struct to be incorrectly aligned. (backport ) (cherry picked from commit 488022ecde62a6b84a13ef14d753db4a885cb734) --- src/new/linux_uapi/linux/can.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index ac1c459fb8a13..51e438434b09e 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -72,7 +72,6 @@ pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; s! { - #[repr(align(8))] pub struct canxl_frame { pub prio: canid_t, pub flags: u8, From 2f7b5f078f3f709368947ff076f0352cc46f4eee Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 18:09:13 -0400 Subject: [PATCH 31/58] test: linux: Unskip some types that now pass Unskip a number of types and constants that were added in more recent kernel versions but are now available in our CI setup. (backport ) (cherry picked from commit 969d956eafee31480d1de9a66aa92ea90ca93266) --- libc-test/build.rs | 69 ++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8299c6aa7dde9..8c9a4ae2d8b12 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4142,13 +4142,6 @@ fn test_linux(target: &str) { "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, - // FIXME(linux): requires >= 6.1 kernel headers - "canxl_frame" => true, - - // FIXME(linux): The size of `iv` has been changed since Linux v6.0 - // https://github.com/torvalds/linux/commit/94dfc73e7cf4a31da66b8843f0b9283ddd6b8381 - "af_alg_iv" => true, - // FIXME(linux): Requires >= 5.1 kernel headers. // Everything that uses install-musl.sh has 4.19 kernel headers. "tls12_crypto_info_aes_gcm_256" @@ -4501,43 +4494,21 @@ fn test_linux(target: &str) { // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, - // linux 5.17 min - "PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true, - - // present in recent kernels only - "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, - - // present in recent kernels only >= 5.13 - "PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true, - // present in recent kernels only >= 5.19 - "PR_SME_SET_VL" | "PR_SME_GET_VL" | "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" => true, - - // Added in Linux 5.14 - "FUTEX_LOCK_PI2" => true, - - // Added in linux 6.1 - "STATX_DIOALIGN" - | "CAN_RAW_XL_FRAMES" - | "CANXL_HDR_SIZE" - | "CANXL_MAX_DLC" - | "CANXL_MAX_DLC_MASK" - | "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" - => true, - - // FIXME(linux): Parts of netfilter/nfnetlink*.h require more recent kernel headers: - | "RTNLGRP_MCTP_IFADDR" // linux v5.17+ - | "RTNLGRP_TUNNEL" // linux v5.18+ - | "RTNLGRP_STATS" // linux v5.18+ - => true, + // Not present on old musl + "PR_SET_VMA" + | "PR_SET_VMA_ANON_NAME" + | "PR_SCHED_CORE" + | "PR_SCHED_CORE_CREATE" + | "PR_SCHED_CORE_GET" + | "PR_SCHED_CORE_MAX" + | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" + | "PR_SCHED_CORE_SCOPE_THREAD" + | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" + | "PR_SCHED_CORE_SHARE_FROM" + | "PR_SCHED_CORE_SHARE_TO" if old_musl => true, + + // Not present in glibc + "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, // FIXME(linux): The below is no longer const in glibc 2.34: // https://github.com/bminor/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 @@ -4546,15 +4517,9 @@ fn test_linux(target: &str) { | "MINSIGSTKSZ" if gnu => true, - // FIXME(linux): Linux >= 5.16: - // https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96 - "NF_NETDEV_EGRESS" if sparc64 => true, // value changed "NF_NETDEV_NUMHOOKS" if sparc64 => true, - // FIXME(linux): requires Linux >= v5.8 - "IF_LINK_MODE_TESTING" if sparc64 => true, - // DIFF(main): fixed in 1.0 with e9abac9ac2 "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, @@ -4961,7 +4926,9 @@ fn test_linux(target: &str) { // After musl 1.2.0, the type becomes `int` instead of `long`. (old_musl && struct_ == "utmpx" && field == "ut_session") || // `frames` is a flexible array member - (struct_ == "bcm_msg_head" && field == "frames") + (struct_ == "bcm_msg_head" && field == "frames") || + // FAM + (struct_ == "af_alg_iv" && field == "iv") }); cfg.skip_roundtrip(move |s| match s { From 268a77f828fc80afdf02eff5b907a00364a90ea2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 18:09:53 -0400 Subject: [PATCH 32/58] test: linux: musl: Unskip types that needed newer kernel headers Our musl tests now use more recent headers, so we can start testing a number of types again. (backport ) (cherry picked from commit 7238ba5d071049c667498059083318e9adf555b3) --- libc-test/build.rs | 70 ---------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8c9a4ae2d8b12..47aebeeb3a0b4 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4142,30 +4142,6 @@ fn test_linux(target: &str) { "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, - // FIXME(linux): Requires >= 5.1 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "tls12_crypto_info_aes_gcm_256" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME(linux): Requires >= 5.11 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "tls12_crypto_info_chacha20_poly1305" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME(linux): Requires >= 5.3 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_options" if musl => true, - - // FIXME(linux): Requires >= 5.4 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, - // FIXME(linux): Requires >= 6.8 kernel headers. // A field was added in 6.8. // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 @@ -4173,10 +4149,6 @@ fn test_linux(target: &str) { // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f "xdp_umem_reg" => true, - // FIXME(linux): Requires >= 5.9 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_statistics" if musl => true, - // FIXME(linux): Requires >= 6.8 kernel headers. "xsk_tx_metadata" | "__c_anonymous_xsk_tx_metadata_union" @@ -4260,48 +4232,6 @@ fn test_linux(target: &str) { } } if musl { - // FIXME(linux): Requires >= 5.0 kernel headers - if name == "SECCOMP_GET_NOTIF_SIZES" - || name == "SECCOMP_FILTER_FLAG_NEW_LISTENER" - || name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH" - || name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5 - || name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9 - || name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9 - || name == "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" // requires >= 5.19 - { - return true; - } - // FIXME(linux): Requires >= 4.20 kernel headers - if name == "PTP_SYS_OFFSET_EXTENDED" { - return true; - } - // FIXME(linux): Requires >= 5.4 kernel headers - if name == "PTP_CLOCK_GETCAPS2" - || name == "PTP_ENABLE_PPS2" - || name == "PTP_EXTTS_REQUEST2" - || name == "PTP_PEROUT_REQUEST2" - || name == "PTP_PIN_GETFUNC2" - || name == "PTP_PIN_SETFUNC2" - || name == "PTP_SYS_OFFSET2" - || name == "PTP_SYS_OFFSET_PRECISE2" - || name == "PTP_SYS_OFFSET_EXTENDED2" - { - return true; - } - // FIXME(linux): Requires >= 5.4.1 kernel headers - if name.starts_with("J1939") - || name.starts_with("RTEXT_FILTER_") - || name.starts_with("SO_J1939") - || name.starts_with("SCM_J1939") - { - return true; - } - // FIXME(linux): Requires >= 5.10 kernel headers - if name.starts_with("MEMBARRIER_CMD_REGISTER") - || name.starts_with("MEMBARRIER_CMD_PRIVATE") - { - return true; - } // LFS64 types have been removed in musl 1.2.4+ if name.starts_with("RLIM64") { return true; From f67bc8646b80f63d44caeeac0ffaad6dbcf22adb Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 18:45:20 -0400 Subject: [PATCH 33/58] ci: Log the output of uname -a Indicate which kernel version we are working with. (backport ) (cherry picked from commit cc3cee4a2f5deb304ffbe769d37d24bc1d52c6c2) --- ci/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/run.sh b/ci/run.sh index 7b4525143d05a..0938b695d403d 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -9,6 +9,9 @@ target="$1" export RUST_BACKTRACE="${RUST_BACKTRACE:-1}" +# For logging +uname -a + cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}" test_flags="--skip check_style" From 818b65f7e539cab22ef83cafd5f454efca1cb2fa Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 23:42:01 -0400 Subject: [PATCH 34/58] ci: Update wasmtime to the latest release (38.0.2) (backport ) (cherry picked from commit 00360b97870b3023b6fc5e427b82d1e1b8dfd151) --- ci/wasi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/wasi.sh b/ci/wasi.sh index 19aa57e608542..f0d8a5245c99b 100755 --- a/ci/wasi.sh +++ b/ci/wasi.sh @@ -11,7 +11,7 @@ apt-get install -y --no-install-recommends \ # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. # Download appropriate versions here and configure various flags below. -wasmtime=35.0.0 +wasmtime=38.0.2 wasi_sdk=27 curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | From eadf96f6452848890e1cf69f4dbf3c04d24e87f6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 22:30:43 -0400 Subject: [PATCH 35/58] test: linux: Unskip types and constants that are now available CI runs with the 6.11 kernel, so stop skipping tests on everything that was added before then where possible. (backport ) (cherry picked from commit dd44cb603e77e5bca7d9de0af2ee5c6e189e08d8) --- libc-test/build.rs | 162 ++++++++++++--------------------------------- 1 file changed, 44 insertions(+), 118 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 47aebeeb3a0b4..c684d20346cc0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4182,9 +4182,6 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "mnt_ns_info" => true, - // FIXME(linux): Requires >= 6.4 kernel headers. - "ptrace_sud_config" => true, - // Struct has changed for new musl versions "tcp_info" if old_musl => true, @@ -4240,20 +4237,6 @@ fn test_linux(target: &str) { if name.starts_with("NI_IDN") { return true; } - // FIXME: Requires >= 6.3 kernel headers - if loongarch64 && (name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC") { - return true; - } - // FIXME: Requires >= 6.3 (6.6) kernel headers - if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" { - return true; - } - // Requires musl >= 1.2 - if old_musl && (name == "SO_PREFER_BUSY_POLL" - || name == "SO_BUSY_POLL_BUDGET") - { - return true; - } // FIXME(musl): Not in musl yet if name == "SO_NETNS_COOKIE" || name == "SO_BUF_LOCK" @@ -4274,20 +4257,45 @@ fn test_linux(target: &str) { { return true; } - // Values changed in newer musl versions on these arches - if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" { - return true; - } - // Values changed in newer musl versions - if old_musl && name == "RLIM_NLIMITS" { - return true; - } // FIXME: Does not exist on non-x86 architectures, slated for removal // in libc in 1.0 if ppc64 && name == "MAP_32BIT" { return true; } } + if old_musl { + // Constants that don't exist on the old version of musl we test with, but do exist + // on newer versions. + match name { + | "FAN_EVENT_INFO_TYPE_ERROR" + | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" + | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" + | "FAN_FS_ERROR" + | "FAN_INFO" + | "FAN_MARK_EVICTABLE" + | "FAN_MARK_IGNORE" + | "FAN_MARK_IGNORE_SURV" + | "FAN_RENAME" + | "FAN_REPORT_DFID_NAME_TARGET" + | "FAN_REPORT_TARGET_FID" + | "FAN_RESPONSE_INFO_AUDIT_RULE" + | "FAN_RESPONSE_INFO_NONE" + | "IPPROTO_ETHERNET" + | "IPPROTO_MPTCP" + | "PR_GET_MDWE" + | "PR_MDWE_NO_INHERIT" + | "PR_MDWE_REFUSE_EXEC_GAIN" + | "PR_SET_MDWE" + | "RLIM_NLIMITS" + | "SI_DETHREAD" + | "SO_BUSY_POLL_BUDGET" + | "SO_PREFER_BUSY_POLL" + => return true, + // Values changed in newer musl versions on these arches + "O_LARGEFILE" if riscv64 || x86_64 => return true, + _ => (), + } + } match name { // These constants are not available if gnu headers have been included // and can therefore not be tested here @@ -4340,10 +4348,8 @@ fn test_linux(target: &str) { // deprecated: not available from Linux kernel 5.6: "VMADDR_CID_RESERVED" => true, - // IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: - | "IPPROTO_MAX" - | "IPPROTO_ETHERNET" - | "IPPROTO_MPTCP" => true, + // FIXME(value): IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: + "IPPROTO_MAX" => true, // FIXME(linux): Not yet implemented on sparc64 "SYS_clone3" if sparc64 => true, @@ -4351,32 +4357,8 @@ fn test_linux(target: &str) { // 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 => true, - // FIXME(linux): Added in Linux 5.16 - // https://github.com/torvalds/linux/commit/039c0ec9bb77446d7ada7f55f90af9299b28ca49 - "SYS_futex_waitv" => true, - - // FIXME(linux): Added in Linux 5.17 - // https://github.com/torvalds/linux/commit/c6018b4b254971863bd0ad36bb5e7d0fa0f0ddb0 - "SYS_set_mempolicy_home_node" => true, - - // FIXME(linux): Added in Linux 5.18 - // https://github.com/torvalds/linux/commit/8b5413647262dda8d8d0e07e14ea1de9ac7cf0b2 - "NFQA_PRIORITY" => true, - - // FIXME(linux): requires more recent kernel headers on CI - | "UINPUT_VERSION" - | "SW_MAX" - | "SW_CNT" - if ppc64 || riscv64 => true, - - // FIXME(linux): requires more recent kernel headers on CI - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" if sparc64 => true, - - // FIXME(linux): Not currently available in headers on ARM and musl. - "NETLINK_GET_STRICT_CHK" if arm => true, - // Skip as this signal codes and trap reasons need newer headers - "SI_DETHREAD" | "TRAP_PERF" => true, + "TRAP_PERF" => true, // kernel constants not available in uclibc 1.0.34 | "EXTPROC" @@ -4453,12 +4435,6 @@ fn test_linux(target: &str) { // DIFF(main): fixed in 1.0 with e9abac9ac2 "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, - // kernel 6.1 minimum - "MADV_COLLAPSE" => true, - - // kernel 6.2 minimum - "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, - // kernel 6.9 minimum "RWF_NOAPPEND" => true, @@ -4468,38 +4444,6 @@ fn test_linux(target: &str) { // kernel 6.14 minimum "RWF_DONTCACHE" => true, - // FIXME(linux): Requires more recent kernel headers - | "IFLA_PARENT_DEV_NAME" // linux v5.13+ - | "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+ - | "IFLA_GRO_MAX_SIZE" // linux v5.16+ - | "IFLA_TSO_MAX_SIZE" // linux v5.18+ - | "IFLA_TSO_MAX_SEGS" // linux v5.18+ - | "IFLA_ALLMULTI" // linux v6.0+ - | "MADV_DONTNEED_LOCKED" // linux v5.18+ - => true, - "SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+ - - // kernel 6.5 minimum - "MOVE_MOUNT_BENEATH" => true, - // FIXME(linux): Requires linux 6.1 - "ALG_SET_KEY_BY_KEY_SERIAL" | "ALG_SET_DRBG_ENTROPY" => true, - - // FIXME(linux): Requires more recent kernel headers - | "FAN_FS_ERROR" // linux v5.16+ - | "FAN_RENAME" // linux v5.17+ - | "FAN_REPORT_TARGET_FID" // linux v5.17+ - | "FAN_REPORT_DFID_NAME_TARGET" // linux v5.17+ - | "FAN_MARK_EVICTABLE" // linux v5.19+ - | "FAN_MARK_IGNORE" // linux v6.0+ - | "FAN_MARK_IGNORE_SURV" // linux v6.0+ - | "FAN_EVENT_INFO_TYPE_ERROR" // linux v5.16+ - | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" // linux v5.17+ - | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" // linux v5.17+ - | "FAN_RESPONSE_INFO_NONE" // linux v5.16+ - | "FAN_RESPONSE_INFO_AUDIT_RULE" // linux v5.16+ - | "FAN_INFO" // linux v5.16+ - => true, - // musl doesn't use in "FAN_REPORT_PIDFD" | "FAN_REPORT_DIR_FID" @@ -4512,36 +4456,24 @@ fn test_linux(target: &str) { | "FAN_EPIDFD" if musl => true, - // FIXME(linux): Requires linux 6.5 + // FIXME(value): value needs update "NFT_MSG_MAX" => true, // FIXME(linux): Requires >= 6.6 kernel headers. - "XDP_USE_SG" - | "XDP_PKT_CONTD" - => - { - true - } + "XDP_USE_SG" | "XDP_PKT_CONTD" => true, - // FIXME(linux): Requires >= 6.6 kernel headers. - "PR_MDWE_NO_INHERIT" => true, + // FIXME(linux): Missing only on this platform for some reason + "PR_MDWE_NO_INHERIT" if gnueabihf => true, // FIXME(linux): Requires >= 6.8 kernel headers. "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" | "XDP_TX_METADATA" - => - { - true - } + => true, // FIXME(linux): Requires >= 6.11 kernel headers. - "XDP_UMEM_TX_METADATA_LEN" - => - { - true - } + "XDP_UMEM_TX_METADATA_LEN" => true, // FIXME(linux): Requires >= 6.11 kernel headers. "NS_GET_MNTNS_ID" | "NS_GET_PID_FROM_PIDNS" | "NS_GET_TGID_FROM_PIDNS" | "NS_GET_PID_IN_PIDNS" | "NS_GET_TGID_IN_PIDNS" => true, @@ -4584,15 +4516,11 @@ fn test_linux(target: &str) { | "PF_SUSPEND_TASK" => true, // FIXME(linux): Requires >= 6.9 kernel headers. - "EPIOCSPARAMS" - | "EPIOCGPARAMS" => true, + "EPIOCSPARAMS" | "EPIOCGPARAMS" => true, // FIXME(linux): Requires >= 6.11 kernel headers. "MAP_DROPPABLE" => true, - // FIXME(linux): Requires >= 6.2 kernel headers. - "SOF_TIMESTAMPING_OPT_ID_TCP" => true, - // FIXME(linux): Requires >= 6.12 kernel headers. "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, @@ -4602,12 +4530,10 @@ fn test_linux(target: &str) { | "SO_DEVMEM_DONTNEED" | "SCM_DEVMEM_LINEAR" | "SCM_DEVMEM_DMABUF" => true, + // FIXME(linux): Requires >= 6.4 kernel headers. "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, - // FIXME(linux): Requires >= 6.6 kernel headers. - "PROC_EVENT_NONZERO_EXIT" => true, - // FIXME(linux): Requires >= 6.14 kernel headers. "SECBIT_EXEC_DENY_INTERACTIVE" | "SECBIT_EXEC_DENY_INTERACTIVE_LOCKED" From 8d7f96027c492827511436570e386a0bb01c8a66 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 23:19:07 -0400 Subject: [PATCH 36/58] ci: Test x86_64-musl with musl 1.2.3 We already test aarch64 and a few other platforms, but x86 was missing. (backport ) (cherry picked from commit 8cac94f729a0690b6587c5c5ab13f2d2eeb333e4) --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 947fe9c4756e2..70b3fbd1e2cee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -225,6 +225,9 @@ jobs: - target: powerpc64le-unknown-linux-musl env: RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: x86_64-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu From b6d3705fb9e14403e80f473a69d5e4c88bba64d5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 22:47:35 -0400 Subject: [PATCH 37/58] linux: Correct the value of NFT_MSG_MAX This was updated in a more recent kernel version. (backport ) (cherry picked from commit e0e220e24ef7b476ac0e34073a2ed8d5b84644c6) --- libc-test/build.rs | 3 --- src/unix/linux_like/linux/mod.rs | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c684d20346cc0..c350034264ae8 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4456,9 +4456,6 @@ fn test_linux(target: &str) { | "FAN_EPIDFD" if musl => true, - // FIXME(value): value needs update - "NFT_MSG_MAX" => true, - // FIXME(linux): Requires >= 6.6 kernel headers. "XDP_USE_SG" | "XDP_PKT_CONTD" => true, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index a84ff4ef30f60..f8bbf65e63d9a 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4913,7 +4913,8 @@ cfg_if! { pub const NFT_MSG_GETOBJ_RESET: c_int = 21; } } -pub const NFT_MSG_MAX: c_int = 25; + +pub const NFT_MSG_MAX: c_int = 34; pub const NFT_SET_ANONYMOUS: c_int = 0x1; pub const NFT_SET_CONSTANT: c_int = 0x2; From f060e8f288581c0c662c3ed72d213f543e90150b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 00:01:03 -0400 Subject: [PATCH 38/58] ci: Remove the unused linux-sparc64 setup script This hasn't been doing anything since e580f566c001 ("use `qemu-sparc64` to run sparc64 tests") which switched away from using qemu-system via `test-runner-linux`. Thus, remove it here. (backport ) (cherry picked from commit 9812d5b4a186e7d40ef6daf84e0baf27e60f901c) --- .../sparc64-unknown-linux-gnu/Dockerfile | 3 --- ci/linux-sparc64.sh | 19 ------------------- 2 files changed, 22 deletions(-) delete mode 100755 ci/linux-sparc64.sh diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index a91ec3dd25f27..c55d57105a114 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -7,9 +7,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ qemu-system-sparc64 openbios-sparc seabios ipxe-qemu \ p7zip-full cpio linux-libc-dev-sparc64-cross qemu-user -COPY linux-sparc64.sh / -RUN /linux-sparc64.sh - ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-sparc64 -L /usr/sparc64-linux-gnu" \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ diff --git a/ci/linux-sparc64.sh b/ci/linux-sparc64.sh deleted file mode 100755 index b272c42edd9aa..0000000000000 --- a/ci/linux-sparc64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env sh - -set -eux - -mkdir -m 777 /qemu -cd /qemu - -curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/snapshots/2024-12-24/debian-12.0.0-sparc64-NETINST-1.iso -7z e debian-12.0.0-sparc64-NETINST-1.iso install/initrd.gz -7z e debian-12.0.0-sparc64-NETINST-1.iso install/vmlinux -mv vmlinux kernel -rm debian-12.0.0-sparc64-NETINST-1.iso - -mkdir init -cd init -gunzip -c ../initrd.gz | cpio -id -rm ../initrd.gz -cp /usr/sparc64-linux-gnu/lib/libgcc_s.so.1 usr/lib/ -chmod a+w . From 143b5cecd83f2545f4837b51e183356736d11348 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 03:20:45 -0400 Subject: [PATCH 39/58] Rename `missing!` to `extern_ty!` Really what we are indicating with this macro invocation is that we need a type that can be specified behind indirection but never used directly, which is an extern type. Using an uninhabited enum gets us most of the way there and is about the best we can do for now. (backport ) (cherry picked from commit fe5ecb8efb4df86b28e060e833754a7c2574fd9e) --- src/macros.rs | 11 ++++++++--- src/unix/aix/powerpc64.rs | 3 +-- src/unix/linux_like/linux/mod.rs | 3 +-- src/unix/linux_like/mod.rs | 3 +-- src/unix/mod.rs | 9 +++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index cb00c8980f44e..f7058a7bd9c0c 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -203,15 +203,20 @@ macro_rules! s_no_extra_traits { ); } -/// Specify that an enum should have no traits that aren't specified in the macro -/// invocation, i.e. no `Clone` or `Copy`. -macro_rules! missing { +/// Create an uninhabited type that can't be constructed. It implements `Debug` but no +/// other traits. +/// +/// Really what we want here is something that also can't be named without indirection (in +/// ADTs or function signatures), but this doesn't exist. +macro_rules! extern_ty { ($( $(#[$attr:meta])* pub enum $i:ident {} )*) => ($( $(#[$attr])* #[allow(missing_copy_implementations)] + // FIXME(1.0): the type is uninhabited so this trait is unreachable. + #[::core::prelude::v1::derive(::core::fmt::Debug)] pub enum $i { } )*); } diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index ba4ddc057c40b..1b62859ae1633 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -2,8 +2,7 @@ use crate::off_t; use crate::prelude::*; // Define lock_data_instrumented as an empty enum -missing! { - #[derive(Debug)] +extern_ty! { pub enum lock_data_instrumented {} } diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index f8bbf65e63d9a..34ee66d1b6557 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -67,8 +67,7 @@ pub type eventfd_t = u64; cfg_if! { if #[cfg(not(target_env = "gnu"))] { - missing! { - #[derive(Debug)] + extern_ty! { pub enum fpos64_t {} // FIXME(linux): fill this out with a struct } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index fd3fa996caad4..0b1f376233a62 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -8,8 +8,7 @@ pub type timer_t = *mut c_void; pub type key_t = c_int; pub type id_t = c_uint; -missing! { - #[derive(Debug)] +extern_ty! { pub enum timezone {} } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index cb0b687a5c858..e341c7d115691 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -37,8 +37,7 @@ cfg_if! { } } -missing! { - #[derive(Debug)] +extern_ty! { pub enum DIR {} } pub type locale_t = *mut c_void; @@ -567,15 +566,13 @@ cfg_if! { cfg_if! { if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { - missing! { - #[derive(Debug)] + extern_ty! { pub enum fpos_t {} // FIXME(unix): fill this out with a struct } } } -missing! { - #[derive(Debug)] +extern_ty! { pub enum FILE {} } From cbe9f021a0c7511256b541420d660b4dc74d9908 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 22 Oct 2025 04:02:16 -0400 Subject: [PATCH 40/58] Migrate manual extern types to `extern_ty!` Use the macro to replace repeated handwritten uninhabited enums. In order to keep the same traits, `extern_ty!` now implements `Clone` and `Copy` in addition to the existing `Debug`, which affects existing uses of `extern_ty!`. We don't need these traits since they can never be used on uninhabited types, but there is no harm in adding them for now and dropping later on. (backport ) (cherry picked from commit 147b462b0b0220bf004501e89273f42054c593d9) --- src/fuchsia/mod.rs | 48 ++++------------------- src/macros.rs | 15 ++++--- src/solid/mod.rs | 18 ++------- src/unix/bsd/apple/mod.rs | 9 +---- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 9 +---- src/unix/bsd/freebsdlike/mod.rs | 9 +---- src/unix/bsd/netbsdlike/mod.rs | 18 ++------- src/unix/cygwin/mod.rs | 18 ++------- src/unix/haiku/mod.rs | 9 +---- src/unix/hurd/mod.rs | 19 ++------- src/unix/linux_like/emscripten/mod.rs | 9 +---- src/unix/nto/mod.rs | 9 +---- src/unix/redox/mod.rs | 9 +---- src/unix/solarish/mod.rs | 19 ++------- src/vxworks/mod.rs | 36 ++++------------- src/windows/mod.rs | 29 ++++---------- 16 files changed, 61 insertions(+), 222 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 31f13b16832d2..5a3d0784c434c 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -78,32 +78,10 @@ pub type fsblkcnt_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; pub type rlim_t = c_ulonglong; -// FIXME(fuchsia): why are these uninhabited types? that seems... wrong? -// Presumably these should be `()` or an `extern type` (when that stabilizes). -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } -} - -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +extern_ty! { + pub enum timezone {} + pub enum DIR {} + pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct } // PUB_STRUCT @@ -3421,21 +3399,9 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { #[link(name = "fdio")] extern "C" {} -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct } extern "C" { diff --git a/src/macros.rs b/src/macros.rs index f7058a7bd9c0c..59dcbfa905c82 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -203,8 +203,9 @@ macro_rules! s_no_extra_traits { ); } -/// Create an uninhabited type that can't be constructed. It implements `Debug` but no -/// other traits. +/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, +/// and `Copy`, but these aren't meaningful for extern types so they should eventually +/// be removed. /// /// Really what we want here is something that also can't be named without indirection (in /// ADTs or function signatures), but this doesn't exist. @@ -214,9 +215,13 @@ macro_rules! extern_ty { pub enum $i:ident {} )*) => ($( $(#[$attr])* - #[allow(missing_copy_implementations)] - // FIXME(1.0): the type is uninhabited so this trait is unreachable. - #[::core::prelude::v1::derive(::core::fmt::Debug)] + // FIXME(1.0): the type is uninhabited so these traits are unreachable and could be + // removed. + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] pub enum $i { } )*); } diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 40d6a9d348586..37c7fe5f0a342 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -395,21 +395,9 @@ pub const SIGUSR1: c_int = 30; pub const SIGUSR2: c_int = 31; pub const SIGPWR: c_int = 32; -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} } extern "C" { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 857508f794ad1..a9fcf556a5381 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -179,13 +179,8 @@ deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } #[derive(Debug)] diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 582e812796cf2..4e054f9c89056 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -45,13 +45,8 @@ pub type vm_map_entry_t = *mut vm_map_entry; pub type pmap = __c_anonymous_pmap; -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum sem {} } e! { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4bf62033474f0..453d3e0734f05 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -59,13 +59,8 @@ cfg_if! { // link.h -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } impl siginfo_t { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index bc3e4cdf094ff..294d334490bc1 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -16,21 +16,9 @@ pub type id_t = u32; pub type sem_t = *mut sem; pub type key_t = c_long; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum timezone {} + pub enum sem {} } s! { diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 12e30f3f9016c..028ac80cb52d3 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -28,13 +28,8 @@ pub type nlink_t = c_ushort; pub type suseconds_t = c_long; pub type useconds_t = c_ulong; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } pub type sigset_t = c_ulong; @@ -75,13 +70,8 @@ pub type nfds_t = c_uint; pub type sem_t = *mut sem; -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum sem {} } pub type tcflag_t = c_uint; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 964598e97ca35..98764c497f0f6 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -80,13 +80,8 @@ pub type ACTION = c_int; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } impl siginfo_t { diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 24e9fe56f392d..acd0981b1a8b2 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -225,22 +225,9 @@ pub type nl_item = c_int; pub type iconv_t = *mut c_void; -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } -} - -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct + pub enum timezone {} } // structs diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 417e3e593bc5e..91e506c57cc22 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -41,13 +41,8 @@ pub type statfs64 = crate::statfs; pub type statvfs64 = crate::statvfs; pub type dirent64 = crate::dirent; -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +extern_ty! { + pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct } s! { diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 75f5b56902f7f..a81c210c80cf3 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -72,13 +72,8 @@ pub type sem_t = sync_t; pub type nl_item = c_int; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } s! { diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 4db2e8d91b35e..55a8c15a234e2 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -32,13 +32,8 @@ pub type pid_t = usize; pub type uid_t = c_int; pub type gid_t = c_int; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } s_no_extra_traits! { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index d8b32dfc0aae9..f78b09a3db63a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -55,22 +55,9 @@ pub type lgrp_view_t = c_uint; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} - -#[derive(Debug)] -pub enum ucred_t {} -impl Copy for ucred_t {} -impl Clone for ucred_t { - fn clone(&self) -> ucred_t { - *self - } +extern_ty! { + pub enum timezone {} + pub enum ucred_t {} } s! { diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 809640d112221..ce6c91678caf4 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -4,13 +4,8 @@ use core::ptr::null_mut; use crate::prelude::*; -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } +extern_ty! { + pub enum DIR {} } pub type intmax_t = i64; @@ -95,13 +90,8 @@ pub type sa_family_t = c_uchar; // mqueue.h pub type mqd_t = c_int; -#[derive(Debug)] -pub enum _Vx_semaphore {} -impl Copy for _Vx_semaphore {} -impl Clone for _Vx_semaphore { - fn clone(&self) -> _Vx_semaphore { - *self - } +extern_ty! { + pub enum _Vx_semaphore {} } impl siginfo_t { @@ -1054,21 +1044,9 @@ pub const MAP_CONTIG: c_int = 0x0020; pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct } f! { diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 969008c47c675..775be13bac91c 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -29,14 +29,11 @@ cfg_if! { pub type off_t = i32; pub type dev_t = u32; pub type ino_t = u16; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } + +extern_ty! { + pub enum timezone {} } + pub type time64_t = i64; pub type SOCKET = crate::uintptr_t; @@ -254,21 +251,9 @@ pub const TMP_MAX: c_uint = 0x7fff_ffff; #[link(name = "libcmt", cfg(target_feature = "crt-static"))] extern "C" {} -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(windows): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(windows): fill this out with a struct } // Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860 From 25b6c8c4bcb391e1c7890e861cfa6f62cf6f5337 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 02:54:08 -0400 Subject: [PATCH 41/58] test: apple: Remove unneeded test skips Quite a few skipped tests now pass, so test configuration can be simplified. (backport ) (cherry picked from commit 0209508f8dc71a6b05adb14fb18c9db420db5c19) --- libc-test/build.rs | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c350034264ae8..7a09fda3e1374 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -240,8 +240,7 @@ fn test_apple(target: &str) { "os/clock.h", "os/lock.h", "os/signpost.h", - // FIXME(macos): Requires the macOS 14.4 SDK. - //"os/os_sync_wait_on_address.h", + "os/os_sync_wait_on_address.h", "poll.h", "pthread.h", "pthread_spis.h", @@ -318,8 +317,6 @@ fn test_apple(target: &str) { // it is a moving target, changing through versions // also contains bitfields members "tcp_connection_info" => true, - // FIXME(macos): The size is changed in recent macOSes. - "malloc_introspection_t" => true, _ => false, } }); @@ -327,12 +324,8 @@ fn test_apple(target: &str) { cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); cfg.skip_alias(|ty| { match ty.ident() { - // FIXME(macos): Requires the macOS 14.4 SDK. - "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, - // FIXME(macos): "'__uint128' undeclared" in C "__uint128" => true, - _ => false, } }); @@ -341,7 +334,7 @@ fn test_apple(target: &str) { match constant.ident() { // They're declared via `deprecated_mach` and we don't support it anymore. x if x.starts_with("VM_FLAGS_") => true, - // These OSX constants are removed in Sierra. + // FIXME(deprecated): These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). @@ -350,12 +343,6 @@ fn test_apple(target: &str) { // FIXME(macos): XCode 13.1 doesn't have it. "TIOCREMOTE" => true, - // FIXME(macos): Requires the macOS 14.4 SDK. - "OS_SYNC_WAKE_BY_ADDRESS_NONE" - | "OS_SYNC_WAKE_BY_ADDRESS_SHARED" - | "OS_SYNC_WAIT_ON_ADDRESS_NONE" - | "OS_SYNC_WAIT_ON_ADDRESS_SHARED" => true, - _ => false, } }); @@ -365,41 +352,17 @@ fn test_apple(target: &str) { match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - // close calls the close_nocancel system call - "close" => true, - // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, - - // FIXME(macos): remove once the target in CI is updated - "pthread_jit_write_freeze_callbacks_np" => true, - - // FIXME(macos): ABI has been changed on recent macOSes. - "os_unfair_lock_assert_owner" | "os_unfair_lock_assert_not_owner" => true, - - // FIXME(macos): Once the SDK get updated to Ventura's level - "freadlink" | "mknodat" | "mkfifoat" => true, - - // FIXME(macos): Requires the macOS 14.4 SDK. - "os_sync_wake_by_address_any" - | "os_sync_wake_by_address_all" - | "os_sync_wake_by_address_flags_t" - | "os_sync_wait_on_address" - | "os_sync_wait_on_address_flags_t" - | "os_sync_wait_on_address_with_deadline" - | "os_sync_wait_on_address_with_timeout" => true, - _ => false, } }); cfg.skip_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { - // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]). - ("statfs", "f_reserved") => true, - ("__darwin_arm_neon_state64", "__v") => true, // MAXPATHLEN is too big for auto-derive traits on arrays. ("vnode_info_path", "vip_path") => true, + // Anonymous ADT fields ("ifreq", "ifr_ifru") => true, ("in6_ifreq", "ifr_ifru") => true, ("ifkpi", "ifk_data") => true, @@ -450,8 +413,6 @@ 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, - // Can't return an array from a C function. - "uuid_t" | "vol_capabilities_set_t" => true, _ => false, }); From cabf324f4ad3da50ec04e72711da08bf4539fc26 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 02:55:02 -0400 Subject: [PATCH 42/58] apple: Deprecate TIOCREMOTE This was removed as of MacOS 12.0.1 (Monterey). Link: https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733#diff-3c054321ffa9f7cfa71b5dfb244b27379af699ce4ead58446b3fe83f934140f3L152-R152 (backport ) (cherry picked from commit 3985d13f764b97f5949ac9e0058856fdda0c4258) --- libc-test/build.rs | 3 ++- src/unix/bsd/apple/mod.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7a09fda3e1374..2c51730fa27fb 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -340,7 +340,8 @@ fn test_apple(target: &str) { // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). "SF_SETTABLE" => true, - // FIXME(macos): XCode 13.1 doesn't have it. + // FIXME(deprecated): Removed since 12.0.1 / xnu-8019.41.5. See `ttycom.h` at + // https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733 "TIOCREMOTE" => true, _ => false, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index a9fcf556a5381..3026cd488940c 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3317,6 +3317,7 @@ pub const TIOCMSET: c_ulong = 0x8004746d; pub const TIOCMBIS: c_ulong = 0x8004746c; pub const TIOCMBIC: c_ulong = 0x8004746b; pub const TIOCMGET: c_ulong = 0x4004746a; +#[deprecated(since = "0.2.178", note = "Removed in MacOSX 12.0.1")] pub const TIOCREMOTE: c_ulong = 0x80047469; pub const TIOCGWINSZ: c_ulong = 0x40087468; pub const TIOCSWINSZ: c_ulong = 0x80087467; From 3bcd65cb23aaf5cb080494d10ee646c33f9272da Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 02:58:08 -0400 Subject: [PATCH 43/58] apple: Correct the value of `SF_SETTABLE` This was updated a long time ago in MacOS Catalina; update ours to match. Link: https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/bsd/sys/stat.h#L497 (backport ) (cherry picked from commit db33ac4f62d1e6dcdbdb5e91f480665ca35204da) --- libc-test/build.rs | 2 -- src/unix/bsd/apple/mod.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2c51730fa27fb..d183576697532 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -337,8 +337,6 @@ fn test_apple(target: &str) { // FIXME(deprecated): These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). - "SF_SETTABLE" => true, // FIXME(deprecated): Removed since 12.0.1 / xnu-8019.41.5. See `ttycom.h` at // https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733 diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 3026cd488940c..356e1ca4465af 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4773,7 +4773,7 @@ pub const UF_APPEND: c_uint = 0x00000004; pub const UF_OPAQUE: c_uint = 0x00000008; pub const UF_COMPRESSED: c_uint = 0x00000020; pub const UF_TRACKED: c_uint = 0x00000040; -pub const SF_SETTABLE: c_uint = 0xffff0000; +pub const SF_SETTABLE: c_uint = 0x3fff0000; pub const SF_ARCHIVED: c_uint = 0x00010000; pub const SF_IMMUTABLE: c_uint = 0x00020000; pub const SF_APPEND: c_uint = 0x00040000; From ad6dd560e9967db3debc9b746531048721dfdb51 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 03:41:13 -0400 Subject: [PATCH 44/58] test: Change the `headers!` macro to a syntax that rustfmt will format Rustfmt will format `()` or `[]` macro invocations that contain valid Rust syntax, but not `{}` invocations. Switch to `()`, and update the syntax to be valid Rust so rustfmt cleans them up. (backport ) (cherry picked from commit a8b153236c1c7148a130c6969bb04886b1f3ebbd) --- libc-test/build.rs | 1708 ++++++++++++++++++++++---------------------- 1 file changed, 856 insertions(+), 852 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index d183576697532..22185284fab20 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -159,22 +159,24 @@ fn main() { } macro_rules! headers { - ($cfg:ident: [$m:expr]: $header:literal) => { - if $m { - $cfg.header($header); - } - }; - ($cfg:ident: $header:literal) => { - $cfg.header($header); - }; - ($($cfg:ident: $([$c:expr]:)* $header:literal,)*) => { - $(headers!($cfg: $([$c]:)* $header);)* - }; - ($cfg:ident: $( $([$c:expr]:)* $header:literal,)*) => { - headers!($($cfg: $([$c]:)* $header,)*); - }; - ($cfg:ident: $( $([$c:expr]:)* $header:literal),*) => { - headers!($($cfg: $([$c]:)* $header,)*); + ( + $cfg:ident, + $( + // Allow a simple header + $($header:literal)? + // As well as a style that is conditionally applied. + $(($pred:expr, $pred_header:literal))? + , + )+ + ) => { + $( + $( $cfg.header($header); )? + $( + if $pred { + $cfg.header($pred_header); + } + )? + )+ }; } @@ -188,7 +190,8 @@ fn test_apple(target: &str) { cfg.flag("-Wno-deprecated-declarations"); cfg.define("__APPLE_USE_RFC_3542", None); - headers! { cfg: + headers!( + cfg, "aio.h", "CommonCrypto/CommonCrypto.h", "CommonCrypto/CommonRandom.h", @@ -301,8 +304,8 @@ fn test_apple(target: &str) { "utmpx.h", "wchar.h", "xlocale.h", - [x86_64]: "crt_externs.h", - } + (x86_64, "crt_externs.h"), + ); // Skip anonymous unions/structs. cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); @@ -426,7 +429,8 @@ fn test_openbsd(target: &str) { let x86_64 = target.contains("x86_64"); - headers! { cfg: + headers!( + cfg, "elf.h", "errno.h", "execinfo.h", @@ -448,7 +452,7 @@ fn test_openbsd(target: &str) { "ctype.h", "dirent.h", "sys/socket.h", - [x86_64]:"machine/fpu.h", + (x86_64, "machine/fpu.h"), "net/if.h", "net/route.h", "net/if_arp.h", @@ -510,7 +514,7 @@ fn test_openbsd(target: &str) { "sys/shm.h", "sys/param.h", "sys/auxv.h", - } + ); cfg.rename_type(|ty| match ty { // FIXME(openbsd): https://github.com/rust-lang/libc/issues/1273 @@ -626,7 +630,8 @@ fn test_cygwin(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -676,7 +681,7 @@ fn test_cygwin(target: &str) { "utime.h", "wait.h", "wchar.h", - } + ); cfg.rename_type(|ty| match ty { "Ioctl" => Some("int".to_string()), @@ -802,7 +807,8 @@ fn test_windows(target: &str) { } cfg.define("_WIN32_WINNT", Some("0x8000")); - headers! { cfg: + headers!( + cfg, "direct.h", "errno.h", "fcntl.h", @@ -820,9 +826,9 @@ fn test_windows(target: &str) { "sys/utime.h", "time.h", "wchar.h", - [gnu]: "ws2tcpip.h", - [!gnu]: "Winsock2.h", - } + (gnu, "ws2tcpip.h"), + (!gnu, "Winsock2.h"), + ); cfg.rename_struct_ty(|ty| { match ty { @@ -921,8 +927,8 @@ fn test_redox(target: &str) { let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - headers! { - cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -960,7 +966,7 @@ fn test_redox(target: &str) { "unistd.h", "utime.h", "wchar.h", - } + ); ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } @@ -986,8 +992,8 @@ fn test_solarish(target: &str) { cfg.define("SIGINFO", Some("41")); } - headers! { - cfg: + headers!( + cfg, "aio.h", "ctype.h", "dirent.h", @@ -1066,19 +1072,14 @@ fn test_solarish(target: &str) { "utime.h", "utmpx.h", "wchar.h", - } + ); if is_illumos { - headers! { cfg: - "sys/epoll.h", - "sys/eventfd.h", - } + headers!(cfg, "sys/epoll.h", "sys/eventfd.h",); } if is_solaris { - headers! { cfg: - "sys/lgrp_user_impl.h", - } + headers!(cfg, "sys/lgrp_user_impl.h",); } cfg.skip_alias(move |ty| match ty.ident() { @@ -1273,8 +1274,8 @@ fn test_netbsd(target: &str) { cfg.flag("-Wno-deprecated-declarations"); cfg.define("_NETBSD_SOURCE", Some("1")); - headers! { - cfg: + headers!( + cfg, "elf.h", "errno.h", "fcntl.h", @@ -1359,7 +1360,7 @@ fn test_netbsd(target: &str) { "sys/reboot.h", "sys/shm.h", "iconv.h", - } + ); cfg.rename_type(move |ty| { match ty { @@ -1487,8 +1488,8 @@ fn test_dragonflybsd(target: &str) { let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - headers! { - cfg: + headers!( + cfg, "aio.h", "ctype.h", "dirent.h", @@ -1576,7 +1577,7 @@ fn test_dragonflybsd(target: &str) { "vm/vm_map.h", "wchar.h", "iconv.h", - } + ); cfg.rename_struct_ty(move |ty| { match ty { @@ -1713,7 +1714,8 @@ fn test_wasi(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "errno.h", @@ -1723,9 +1725,9 @@ fn test_wasi(target: &str) { "limits.h", "locale.h", "malloc.h", - [p2]: "netdb.h", - [p2]: "netinet/in.h", - [p2]: "netinet/tcp.h", + (p2, "netdb.h"), + (p2, "netinet/in.h"), + (p2, "netinet/tcp.h"), "poll.h", "pthread.h", "sched.h", @@ -1751,7 +1753,7 @@ fn test_wasi(target: &str) { "wasi/libc-nocwd.h", "wasi/libc.h", "wchar.h", - } + ); cfg.rename_struct_ty(move |ty| match ty { "FILE" | "fd_set" | "DIR" => Some(ty.to_string()), @@ -1812,151 +1814,150 @@ fn test_android(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: - "arpa/inet.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "grp.h", - "ifaddrs.h", - "libgen.h", - "limits.h", - "link.h", - "linux/sysctl.h", - "locale.h", - "malloc.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "netpacket/packet.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/auxv.h", - "sys/epoll.h", - "sys/eventfd.h", - "sys/file.h", - "sys/fsuid.h", - "sys/inotify.h", - "sys/ioctl.h", - "sys/klog.h", - "sys/mman.h", - "sys/mount.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/sendfile.h", - "sys/signalfd.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/swap.h", - "sys/syscall.h", - "sys/sysinfo.h", - "sys/system_properties.h", - "sys/time.h", - "sys/timerfd.h", - "sys/times.h", - "sys/types.h", - "sys/ucontext.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/xattr.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "unistd.h", - "utime.h", - "utmp.h", - "wchar.h", - "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", - [x86]: "sys/reg.h", - } + headers!( + cfg, + "arpa/inet.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "grp.h", + "ifaddrs.h", + "libgen.h", + "limits.h", + "link.h", + "linux/sysctl.h", + "locale.h", + "malloc.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/auxv.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/klog.h", + "sys/mman.h", + "sys/mount.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sendfile.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/system_properties.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/types.h", + "sys/ucontext.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/xattr.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "utmp.h", + "wchar.h", + "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"), + (x86, "sys/reg.h"), + ); // Include linux headers at the end: - headers! { cfg: - "asm/mman.h", - "linux/auxvec.h", - "linux/dccp.h", - "linux/elf.h", - "linux/errqueue.h", - "linux/falloc.h", - "linux/filter.h", - "linux/futex.h", - "linux/fs.h", - "linux/genetlink.h", - "linux/if_alg.h", - "linux/if_addr.h", - "linux/if_ether.h", - "linux/if_link.h", - "linux/rtnetlink.h", - "linux/if_tun.h", - "linux/kexec.h", - "linux/magic.h", - "linux/membarrier.h", - "linux/memfd.h", - "linux/mempolicy.h", - "linux/module.h", - "linux/mount.h", - "linux/net_tstamp.h", - "linux/netfilter/nfnetlink.h", - "linux/netfilter/nfnetlink_log.h", - "linux/netfilter/nfnetlink_queue.h", - "linux/netfilter/nf_tables.h", - "linux/netfilter_arp.h", - "linux/netfilter_bridge.h", - "linux/netfilter_ipv4.h", - "linux/netfilter_ipv6.h", - "linux/netfilter_ipv6/ip6_tables.h", - "linux/netlink.h", - "linux/quota.h", - "linux/reboot.h", - "linux/seccomp.h", - "linux/sched.h", - "linux/sockios.h", - "linux/uinput.h", - "linux/vm_sockets.h", - "linux/wait.h", - - } + headers!( + cfg, + "asm/mman.h", + "linux/auxvec.h", + "linux/dccp.h", + "linux/elf.h", + "linux/errqueue.h", + "linux/falloc.h", + "linux/filter.h", + "linux/futex.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_addr.h", + "linux/if_ether.h", + "linux/if_link.h", + "linux/rtnetlink.h", + "linux/if_tun.h", + "linux/kexec.h", + "linux/magic.h", + "linux/membarrier.h", + "linux/memfd.h", + "linux/mempolicy.h", + "linux/module.h", + "linux/mount.h", + "linux/net_tstamp.h", + "linux/netfilter/nfnetlink.h", + "linux/netfilter/nfnetlink_log.h", + "linux/netfilter/nfnetlink_queue.h", + "linux/netfilter/nf_tables.h", + "linux/netfilter_arp.h", + "linux/netfilter_bridge.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", + "linux/netfilter_ipv6/ip6_tables.h", + "linux/netlink.h", + "linux/quota.h", + "linux/reboot.h", + "linux/seccomp.h", + "linux/sched.h", + "linux/sockios.h", + "linux/uinput.h", + "linux/vm_sockets.h", + "linux/wait.h", + ); // Include Android-specific headers: - headers! { cfg: - "android/set_abort_message.h" - } + headers!(cfg, "android/set_abort_message.h",); cfg.rename_type(move |ty| match ty { "Ioctl" => Some("int".to_string()), @@ -2339,124 +2340,125 @@ fn test_freebsd(target: &str) { let freebsd14 = matches!(freebsd_ver, Some(n) if n >= 14); let freebsd15 = matches!(freebsd_ver, Some(n) if n >= 15); - headers! { cfg: - "aio.h", - "arpa/inet.h", - "bsm/audit.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "errno.h", - "execinfo.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "glob.h", - "grp.h", - "iconv.h", - "ifaddrs.h", - "kenv.h", - "langinfo.h", - "libgen.h", - "libutil.h", - "limits.h", - "link.h", - "locale.h", - "machine/elf.h", - "machine/reg.h", - "malloc_np.h", - "memstat.h", - "mqueue.h", - "net/bpf.h", - "net/if.h", - "net/if_arp.h", - "net/if_dl.h", - "net/if_mib.h", - "net/route.h", - "netdb.h", - "netinet/ip.h", - "netinet/in.h", - "netinet/sctp.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pthread_np.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/capsicum.h", - "sys/auxv.h", - "sys/cpuset.h", - "sys/domainset.h", - "sys/eui64.h", - "sys/event.h", - [freebsd13]:"sys/eventfd.h", - "sys/extattr.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/jail.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/procctl.h", - "sys/procdesc.h", - "sys/ptrace.h", - "sys/queue.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/rtprio.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/socketvar.h", - [freebsd15]:"sys/ktls.h", - "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h - "sys/stat.h", - "sys/statvfs.h", - "sys/sysctl.h", - "sys/thr.h", - "sys/time.h", - [freebsd14 || freebsd15]:"sys/timerfd.h", - [freebsd13 || freebsd14 || freebsd15]:"dev/evdev/input.h", - "sys/times.h", - "sys/timex.h", - "sys/types.h", - "sys/proc.h", - "kvm.h", // must be after "sys/types.h" - "sys/ucontext.h", - "sys/uio.h", - "sys/ktrace.h", - "sys/umtx.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/uuid.h", - "sys/vmmeter.h", - "sys/wait.h", - "libprocstat.h", - "devstat.h", - "syslog.h", - "termios.h", - "time.h", - "ufs/ufs/quota.h", - "unistd.h", - "utime.h", - "utmpx.h", - "wchar.h", - } + headers!( + cfg, + "aio.h", + "arpa/inet.h", + "bsm/audit.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "errno.h", + "execinfo.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "glob.h", + "grp.h", + "iconv.h", + "ifaddrs.h", + "kenv.h", + "langinfo.h", + "libgen.h", + "libutil.h", + "limits.h", + "link.h", + "locale.h", + "machine/elf.h", + "machine/reg.h", + "malloc_np.h", + "memstat.h", + "mqueue.h", + "net/bpf.h", + "net/if.h", + "net/if_arp.h", + "net/if_dl.h", + "net/if_mib.h", + "net/route.h", + "netdb.h", + "netinet/ip.h", + "netinet/in.h", + "netinet/sctp.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pthread_np.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/capsicum.h", + "sys/auxv.h", + "sys/cpuset.h", + "sys/domainset.h", + "sys/eui64.h", + "sys/event.h", + (freebsd13, "sys/eventfd.h"), + "sys/extattr.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/jail.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/procctl.h", + "sys/procdesc.h", + "sys/ptrace.h", + "sys/queue.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/rtprio.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/socketvar.h", + (freebsd15, "sys/ktls.h"), + "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h + "sys/stat.h", + "sys/statvfs.h", + "sys/sysctl.h", + "sys/thr.h", + "sys/time.h", + (freebsd14 || freebsd15, "sys/timerfd.h"), + (freebsd13 || freebsd14 || freebsd15, "dev/evdev/input.h"), + "sys/times.h", + "sys/timex.h", + "sys/types.h", + "sys/proc.h", + "kvm.h", // must be after "sys/types.h" + "sys/ucontext.h", + "sys/uio.h", + "sys/ktrace.h", + "sys/umtx.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/uuid.h", + "sys/vmmeter.h", + "sys/wait.h", + "libprocstat.h", + "devstat.h", + "syslog.h", + "termios.h", + "time.h", + "ufs/ufs/quota.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + ); cfg.rename_type(|ty| match ty { // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 @@ -3012,140 +3014,141 @@ fn test_emscripten(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); // FIXME(emscripten): ?? - headers! { cfg: - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "netpacket/packet.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "resolv.h", - "sched.h", - "sched.h", - "semaphore.h", - "shadow.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/resource.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/syscall.h", - "sys/sysinfo.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/wait.h", - "sys/xattr.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - } - - cfg.rename_struct_ty(move |ty| { - match ty { - // Just pass all these through, no need for a "struct" prefix - "FILE" | "fd_set" | "Dl_info" | "DIR" => Some(ty.to_string()), - - // LFS64 types have been removed in Emscripten 3.1.44 - // https://github.com/emscripten-core/emscripten/pull/19812 - "off64_t" => Some("off_t".to_string()), - - // typedefs don't need any keywords - t if t.ends_with("_t") => Some(t.to_string()), - _ => None, - } - }); - - cfg.rename_struct_field(move |struct_, field| { - match field.ident() { - // Our stat *_nsec fields normally don't actually exist but are part - // of a timeval struct - s if s.ends_with("_nsec") && struct_.ident().starts_with("stat") => { - Some(s.replace("e_nsec", ".tv_nsec")) - } - // Rust struct uses raw u64, rather than union - "u64" if struct_.ident() == "epoll_event" => Some("data.u64".to_string()), - _ => None, - } - }); - - cfg.skip_alias(move |ty| { - match ty.ident() { - // sighandler_t is crazy across platforms - // FIXME(emscripten): is this necessary? - "sighandler_t" => true, - - // LFS64 types have been removed in Emscripten 3.1.44 - // https://github.com/emscripten-core/emscripten/pull/19812 - t => t.ends_with("64") || t.ends_with("64_t"), - } - }); - - cfg.skip_union(|union_| { - if union_.ident().starts_with("__c_anonymous_") { - return true; - } - - match union_.ident() { - // No epoll support - // https://github.com/emscripten-core/emscripten/issues/5033 - ty if ty.starts_with("epoll") => true, - - _ => false, - } - }); - - cfg.skip_alias(|ty| { - match ty.ident() { - // LFS64 types have been removed in Emscripten 3.1.44 - // https://github.com/emscripten-core/emscripten/pull/19812 + headers!( + cfg, + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "resolv.h", + "sched.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "sys/xattr.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + ); + + cfg.rename_struct_ty(move |ty| { + match ty { + // Just pass all these through, no need for a "struct" prefix + "FILE" | "fd_set" | "Dl_info" | "DIR" => Some(ty.to_string()), + + // LFS64 types have been removed in Emscripten 3.1.44 + // https://github.com/emscripten-core/emscripten/pull/19812 + "off64_t" => Some("off_t".to_string()), + + // typedefs don't need any keywords + t if t.ends_with("_t") => Some(t.to_string()), + _ => None, + } + }); + + cfg.rename_struct_field(move |struct_, field| { + match field.ident() { + // Our stat *_nsec fields normally don't actually exist but are part + // of a timeval struct + s if s.ends_with("_nsec") && struct_.ident().starts_with("stat") => { + Some(s.replace("e_nsec", ".tv_nsec")) + } + // Rust struct uses raw u64, rather than union + "u64" if struct_.ident() == "epoll_event" => Some("data.u64".to_string()), + _ => None, + } + }); + + cfg.skip_alias(move |ty| { + match ty.ident() { + // sighandler_t is crazy across platforms + // FIXME(emscripten): is this necessary? + "sighandler_t" => true, + + // LFS64 types have been removed in Emscripten 3.1.44 + // https://github.com/emscripten-core/emscripten/pull/19812 + t => t.ends_with("64") || t.ends_with("64_t"), + } + }); + + cfg.skip_union(|union_| { + if union_.ident().starts_with("__c_anonymous_") { + return true; + } + + match union_.ident() { + // No epoll support + // https://github.com/emscripten-core/emscripten/issues/5033 + ty if ty.starts_with("epoll") => true, + + _ => false, + } + }); + + cfg.skip_alias(|ty| { + match ty.ident() { + // LFS64 types have been removed in Emscripten 3.1.44 + // https://github.com/emscripten-core/emscripten/pull/19812 ty => ty.ends_with("64") || ty.ends_with("64_t"), } }); @@ -3269,17 +3272,19 @@ fn test_neutrino(target: &str) { .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); cfg.include(qnx_target_val + "/usr/include/io-sock"); - headers! { cfg: + headers!( + cfg, "io-sock.h", "sys/types.h", "sys/socket.h", "sys/sysctl.h", "net/if.h", - "net/if_arp.h" - } + "net/if_arp.h", + ); } - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -3362,12 +3367,11 @@ fn test_neutrino(target: &str) { "net/bpf.h", "net/if_dl.h", "sys/syspage.h", - // TODO: The following header file doesn't appear as part of the default headers // found in a standard installation of Neutrino 7.1 SDP. The structures/ // functions dependent on it are currently commented out. //"sys/asyncmsg.h", - } + ); // Create and include a header file containing // items which are not included in any official @@ -3528,65 +3532,66 @@ fn test_vxworks(target: &str) { assert!(target.contains("vxworks")); let mut cfg = ctest_cfg(); - headers! { cfg: - "vxWorks.h", - "yvals.h", - "nfs/nfsCommon.h", - "rtpLibCommon.h", - "randomNumGen.h", - "taskLib.h", - "sysLib.h", - "ioLib.h", - "inetLib.h", - "socket.h", - "errnoLib.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "fcntl.h", - "grp.h", - "sys/poll.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "link.h", - "locale.h", - "sys/stat.h", - "netdb.h", - "pthread.h", - "pwd.h", - "sched.h", - "semaphore.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/file.h", - "sys/ioctl.h", - "sys/socket.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "netinet/tcp.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "wchar.h", - "errno.h", - "sys/mman.h", - "pathLib.h", - "mqueue.h", - } + headers!( + cfg, + "vxWorks.h", + "yvals.h", + "nfs/nfsCommon.h", + "rtpLibCommon.h", + "randomNumGen.h", + "taskLib.h", + "sysLib.h", + "ioLib.h", + "inetLib.h", + "socket.h", + "errnoLib.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "grp.h", + "sys/poll.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "link.h", + "locale.h", + "sys/stat.h", + "netdb.h", + "pthread.h", + "pwd.h", + "sched.h", + "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/file.h", + "sys/ioctl.h", + "sys/socket.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "netinet/tcp.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "wchar.h", + "errno.h", + "sys/mman.h", + "pathLib.h", + "mqueue.h", + ); // FIXME(vxworks) cfg.skip_const(move |constant| match constant.ident() { // sighandler_t weirdness @@ -3720,127 +3725,125 @@ fn test_linux(target: &str) { config_gnu_bits(target, &mut cfg); - headers! { cfg: - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "glob.h", - [gnu]: "gnu/libc-version.h", - "grp.h", - "iconv.h", - "ifaddrs.h", - "langinfo.h", - "libgen.h", - "limits.h", - "link.h", - "linux/sysctl.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "shadow.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/epoll.h", - "sys/eventfd.h", - "sys/file.h", - "sys/fsuid.h", - "sys/klog.h", - "sys/inotify.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/quota.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/sem.h", - "sys/sendfile.h", - "sys/shm.h", - "sys/signalfd.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/swap.h", - "sys/syscall.h", - "sys/time.h", - "sys/timerfd.h", - "sys/times.h", - "sys/timex.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - "errno.h", - // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit - // 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]: "sys/io.h", - // `sys/reg.h` is only available on x86 and x86_64 - [x86_64 || x86_32]: "sys/reg.h", - // sysctl system call is deprecated and not available on musl - // It is also unsupported in x32, deprecated since glibc 2.30: - [!(x32 || musl || gnu)]: "sys/sysctl.h", - // is not supported by musl: - // https://www.openwall.com/lists/musl/2015/04/09/3 - // is not present on uclibc. - [!(musl || uclibc)]: "execinfo.h", - } + headers!( + cfg, + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "glob.h", + (gnu, "gnu/libc-version.h"), + "grp.h", + "iconv.h", + "ifaddrs.h", + "langinfo.h", + "libgen.h", + "limits.h", + "link.h", + "linux/sysctl.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/klog.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sem.h", + "sys/sendfile.h", + "sys/shm.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/timex.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + "errno.h", + // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit + // 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, "sys/io.h"), + // `sys/reg.h` is only available on x86 and x86_64 + (x86_64 || x86_32, "sys/reg.h"), + // sysctl system call is deprecated and not available on musl + // It is also unsupported in x32, deprecated since glibc 2.30: + (!(x32 || musl || gnu), "sys/sysctl.h"), + // is not supported by musl: + // https://www.openwall.com/lists/musl/2015/04/09/3 + // is not present on uclibc. + (!(musl || uclibc), "execinfo.h"), + ); // Include linux headers at the end: - headers! { - cfg: - [loongarch64 || riscv64]: "asm/hwcap.h", - "asm/mman.h", - } + headers!(cfg, (loongarch64 || riscv64, "asm/hwcap.h"), "asm/mman.h",); if !wasm32 { - headers! { cfg: - [gnu]: "linux/aio_abi.h", + headers!( + cfg, + (gnu, "linux/aio_abi.h"), "linux/can.h", "linux/can/bcm.h", "linux/can/raw.h", @@ -3905,19 +3908,19 @@ fn test_linux(target: &str) { "linux/wireless.h", "sys/fanotify.h", // is not present on uclibc - [!uclibc]: "sys/auxv.h", - [gnu || musl]: "linux/close_range.h", - } + (!uclibc, "sys/auxv.h"), + (gnu || musl, "linux/close_range.h"), + ); } // note: aio.h must be included before sys/mount.h - headers! { - cfg: + headers!( + cfg, "sys/xattr.h", "sys/sysinfo.h", // AIO is not supported by uclibc: - [!uclibc]: "aio.h", - } + (!uclibc, "aio.h"), + ); // Just pass all these through, no need for a "struct" prefix let typedef_structs = [ @@ -4808,7 +4811,7 @@ fn test_linux_like_apis(target: &str) { if linux || android || emscripten { // test strerror_r from the `string.h` header config_gnu_bits(target, &mut cfg); - headers! { cfg: "string.h" } + headers!(cfg, "string.h",); cfg.skip_alias(|_| true) .skip_static(|_| true) @@ -4893,10 +4896,7 @@ fn test_linux_like_apis(target: &str) { .skip_const(move |constant| !ipv6_constants.contains(&constant.ident())); config_gnu_bits(target, &mut cfg); - headers! { - cfg: - "linux/in6.h" - } + headers!(cfg, "linux/in6.h",); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_ipv6.rs").unwrap(); } @@ -4977,137 +4977,140 @@ fn test_haiku(target: &str) { cfg.language(ctest::Language::CXX); // POSIX API - headers! { cfg: - "alloca.h", - "arpa/inet.h", - "arpa/nameser.h", - "arpa/nameser_compat.h", - "assert.h", - "complex.h", - "ctype.h", - "dirent.h", - "div_t.h", - "dlfcn.h", - "endian.h", - "errno.h", - "fcntl.h", - "fenv.h", - "fnmatch.h", - "fts.h", - "ftw.h", - "getopt.h", - "glob.h", - "grp.h", - "inttypes.h", - "iovec.h", - "langinfo.h", - "libgen.h", - "libio.h", - "limits.h", - "locale.h", - "malloc.h", - "malloc_debug.h", - "math.h", - "memory.h", - "monetary.h", - "net/if.h", - "net/if_dl.h", - "net/if_media.h", - "net/if_tun.h", - "net/if_types.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/ip6.h", - "netinet/ip_icmp.h", - "netinet/ip_var.h", - "netinet/tcp.h", - "netinet/udp.h", - "netinet6/in6.h", - "nl_types.h", - "null.h", - "poll.h", - "pthread.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "search.h", - "semaphore.h", - "setjmp.h", - "shadow.h", - "signal.h", - "size_t.h", - "spawn.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "strings.h", - "sys/cdefs.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/msg.h", - "sys/param.h", - "sys/poll.h", - "sys/resource.h", - "sys/select.h", - "sys/sem.h", - "sys/socket.h", - "sys/sockio.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/time.h", - "sys/timeb.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "tar.h", - "termios.h", - "time.h", - "uchar.h", - "unistd.h", - "utime.h", - "utmpx.h", - "wchar.h", - "wchar_t.h", - "wctype.h" - } + headers!( + cfg, + "alloca.h", + "arpa/inet.h", + "arpa/nameser.h", + "arpa/nameser_compat.h", + "assert.h", + "complex.h", + "ctype.h", + "dirent.h", + "div_t.h", + "dlfcn.h", + "endian.h", + "errno.h", + "fcntl.h", + "fenv.h", + "fnmatch.h", + "fts.h", + "ftw.h", + "getopt.h", + "glob.h", + "grp.h", + "inttypes.h", + "iovec.h", + "langinfo.h", + "libgen.h", + "libio.h", + "limits.h", + "locale.h", + "malloc.h", + "malloc_debug.h", + "math.h", + "memory.h", + "monetary.h", + "net/if.h", + "net/if_dl.h", + "net/if_media.h", + "net/if_tun.h", + "net/if_types.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/ip6.h", + "netinet/ip_icmp.h", + "netinet/ip_var.h", + "netinet/tcp.h", + "netinet/udp.h", + "netinet6/in6.h", + "nl_types.h", + "null.h", + "poll.h", + "pthread.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "search.h", + "semaphore.h", + "setjmp.h", + "shadow.h", + "signal.h", + "size_t.h", + "spawn.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/cdefs.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/msg.h", + "sys/param.h", + "sys/poll.h", + "sys/resource.h", + "sys/select.h", + "sys/sem.h", + "sys/socket.h", + "sys/sockio.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/time.h", + "sys/timeb.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "tar.h", + "termios.h", + "time.h", + "uchar.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + "wchar_t.h", + "wctype.h", + ); // BSD Extensions - headers! { cfg: - "ifaddrs.h", - "libutil.h", - "link.h", - "pty.h", - "stdlib.h", - "stringlist.h", - "sys/link_elf.h", - } + headers!( + cfg, + "ifaddrs.h", + "libutil.h", + "link.h", + "pty.h", + "stdlib.h", + "stringlist.h", + "sys/link_elf.h", + ); // Native API - headers! { cfg: - "kernel/OS.h", - "kernel/fs_attr.h", - "kernel/fs_index.h", - "kernel/fs_info.h", - "kernel/fs_query.h", - "kernel/fs_volume.h", - "kernel/image.h", - "kernel/scheduler.h", - "storage/FindDirectory.h", - "storage/StorageDefs.h", - "support/Errors.h", - "support/SupportDefs.h", - "support/TypeConstants.h" - } + headers!( + cfg, + "kernel/OS.h", + "kernel/fs_attr.h", + "kernel/fs_index.h", + "kernel/fs_info.h", + "kernel/fs_query.h", + "kernel/fs_volume.h", + "kernel/image.h", + "kernel/scheduler.h", + "storage/FindDirectory.h", + "storage/StorageDefs.h", + "support/Errors.h", + "support/SupportDefs.h", + "support/TypeConstants.h", + ); cfg.skip_union(|union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { @@ -5319,92 +5322,93 @@ fn test_aix(target: &str) { // 'IN6ADDR_LOOPBACK_INIT' in netinent/in.h. cfg.flag("-Wno-missing-braces"); - headers! { cfg: - "aio.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "glob.h", - "grp.h", - "iconv.h", - "langinfo.h", - "libgen.h", - "limits.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "netinet/in.h", // this needs be before net/if.h - "poll.h", // this needs be before net/if.h - "sys/pollset.h", // this needs to be before net/if.h - "net/if.h", - "net/bpf.h", // this needs to be after net/if.h - "net/if_dl.h", - "netdb.h", - "netinet/tcp.h", - "netinet/sctp.h", - "pthread.h", - "pwd.h", - "rpcsvc/mount.h", - "rpcsvc/rstat.h", - "regex.h", - "resolv.h", - "sched.h", - "search.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "strings.h", - "sys/aacct.h", - "sys/acct.h", - "sys/dr.h", - "sys/file.h", - "sys/io.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/ldr.h", - "sys/mman.h", - "sys/msg.h", - "sys/reg.h", - "sys/resource.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/stat.h", - "sys/statfs.h", - "sys/statvfs.h", - "sys/stropts.h", - "sys/termio.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vattr.h", - "sys/vminfo.h", - "sys/wait.h", - "sys/xti.h", - "syslog.h", - "termios.h", - "thread.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - } + headers!( + cfg, + "aio.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "glob.h", + "grp.h", + "iconv.h", + "langinfo.h", + "libgen.h", + "limits.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "netinet/in.h", // this needs be before net/if.h + "poll.h", // this needs be before net/if.h + "sys/pollset.h", // this needs to be before net/if.h + "net/if.h", + "net/bpf.h", // this needs to be after net/if.h + "net/if_dl.h", + "netdb.h", + "netinet/tcp.h", + "netinet/sctp.h", + "pthread.h", + "pwd.h", + "rpcsvc/mount.h", + "rpcsvc/rstat.h", + "regex.h", + "resolv.h", + "sched.h", + "search.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/aacct.h", + "sys/acct.h", + "sys/dr.h", + "sys/file.h", + "sys/io.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/ldr.h", + "sys/mman.h", + "sys/msg.h", + "sys/reg.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statfs.h", + "sys/statvfs.h", + "sys/stropts.h", + "sys/termio.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vattr.h", + "sys/vminfo.h", + "sys/wait.h", + "sys/xti.h", + "syslog.h", + "termios.h", + "thread.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + ); cfg.skip_alias(move |ty| match ty.ident() { // AIX does not define type 'sighandler_t'. From 3f52956b03621d4d420cfc022de071b55a84d15a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 03:53:04 -0400 Subject: [PATCH 45/58] style: Adjust a comment so rustfmt works Rustfmt was skipping this entire block because it doesn't support comments in the middle of chained `|`. So, add a `=> true` after `IPV6_FLOWINFO_PRIORITY` and the whole closure starts to get formatted again. (backport ) (cherry picked from commit 4e4d9c223e05ab7b34f144f6167984db3b7e4b95) --- libc-test/build.rs | 112 ++++++++++++++++++++------------------------- 1 file changed, 49 insertions(+), 63 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 22185284fab20..fe178dcb4426f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4212,13 +4212,11 @@ fn test_linux(target: &str) { || name == "SO_DEVMEM_DMABUF" || name == "SO_DEVMEM_DONTNEED" { - return true; + return true; } // FIXME(musl): Not in musl yet - if name == "SCM_DEVMEM_LINEAR" - || name == "SCM_DEVMEM_DMABUF" - { - return true; + if name == "SCM_DEVMEM_LINEAR" || name == "SCM_DEVMEM_DMABUF" { + return true; } // FIXME: Does not exist on non-x86 architectures, slated for removal // in libc in 1.0 @@ -4230,7 +4228,7 @@ fn test_linux(target: &str) { // Constants that don't exist on the old version of musl we test with, but do exist // on newer versions. match name { - | "FAN_EVENT_INFO_TYPE_ERROR" + "FAN_EVENT_INFO_TYPE_ERROR" | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" | "FAN_FS_ERROR" @@ -4252,8 +4250,7 @@ fn test_linux(target: &str) { | "RLIM_NLIMITS" | "SI_DETHREAD" | "SO_BUSY_POLL_BUDGET" - | "SO_PREFER_BUSY_POLL" - => return true, + | "SO_PREFER_BUSY_POLL" => return true, // Values changed in newer musl versions on these arches "O_LARGEFILE" if riscv64 || x86_64 => return true, _ => (), @@ -4264,13 +4261,13 @@ fn test_linux(target: &str) { // and can therefore not be tested here // // The IPV6 constants are tested in the `linux_ipv6.rs` tests: - | "IPV6_FLOWINFO" + "IPV6_FLOWINFO" | "IPV6_FLOWLABEL_MGR" | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" + | "IPV6_FLOWINFO_PRIORITY" => true, // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests: - | "F_CANCELLK" + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" @@ -4293,12 +4290,7 @@ fn test_linux(target: &str) { // FIXME(linux): conflicts with glibc headers and is tested in // `linux_termios.rs` below: - | "BOTHER" - | "IBSHIFT" - | "TCGETS2" - | "TCSETS2" - | "TCSETSW2" - | "TCSETSF2" => true, + "BOTHER" | "IBSHIFT" | "TCGETS2" | "TCSETS2" | "TCSETSW2" | "TCSETSF2" => true, // FIXME(musl): on musl the pthread types are defined a little differently // - these constants are used by the glibc implementation. @@ -4318,13 +4310,17 @@ fn test_linux(target: &str) { "SYS_clone3" if sparc64 => true, // 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 => true, + "SYS_memfd_secret" + if arm | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => + { + true + } // Skip as this signal codes and trap reasons need newer headers "TRAP_PERF" => true, // kernel constants not available in uclibc 1.0.34 - | "EXTPROC" + "EXTPROC" | "IPPROTO_BEETPH" | "IPPROTO_MPLS" | "IPV6_HDRINCL" @@ -4337,7 +4333,10 @@ fn test_linux(target: &str) { | "SHM_EXEC" | "UDP_GRO" | "UDP_SEGMENT" - if uclibc => true, + if uclibc => + { + true + } // headers conflicts with linux/pidfd.h "PIDFD_NONBLOCK" => true, @@ -4380,17 +4379,18 @@ fn test_linux(target: &str) { | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" - | "PR_SCHED_CORE_SHARE_TO" if old_musl => true, + | "PR_SCHED_CORE_SHARE_TO" + if old_musl => + { + true + } // Not present in glibc "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, // FIXME(linux): The below is no longer const in glibc 2.34: // https://github.com/bminor/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 - | "PTHREAD_STACK_MIN" - | "SIGSTKSZ" - | "MINSIGSTKSZ" - if gnu => true, + "PTHREAD_STACK_MIN" | "SIGSTKSZ" | "MINSIGSTKSZ" if gnu => true, // value changed "NF_NETDEV_NUMHOOKS" if sparc64 => true, @@ -4417,7 +4417,10 @@ fn test_linux(target: &str) { | "FAN_EVENT_INFO_TYPE_PIDFD" | "FAN_NOPIDFD" | "FAN_EPIDFD" - if musl => true, + if musl => + { + true + } // FIXME(linux): Requires >= 6.6 kernel headers. "XDP_USE_SG" | "XDP_PKT_CONTD" => true, @@ -4429,16 +4432,21 @@ fn test_linux(target: &str) { "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" - | "XDP_TX_METADATA" - => true, + | "XDP_TX_METADATA" => true, // FIXME(linux): Requires >= 6.11 kernel headers. "XDP_UMEM_TX_METADATA_LEN" => true, // FIXME(linux): Requires >= 6.11 kernel headers. - "NS_GET_MNTNS_ID" | "NS_GET_PID_FROM_PIDNS" | "NS_GET_TGID_FROM_PIDNS" | "NS_GET_PID_IN_PIDNS" | "NS_GET_TGID_IN_PIDNS" => true, + "NS_GET_MNTNS_ID" + | "NS_GET_PID_FROM_PIDNS" + | "NS_GET_TGID_FROM_PIDNS" + | "NS_GET_PID_IN_PIDNS" + | "NS_GET_TGID_IN_PIDNS" => true, // FIXME(linux): Requires >= 6.12 kernel headers. - "MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => true, + "MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => { + true + } // FIXME(linux): Requires >= 6.6 kernel headers. "SYS_fchmodat2" => true, @@ -4447,33 +4455,13 @@ fn test_linux(target: &str) { "SYS_mseal" => true, // FIXME(linux): seems to not be available all the time (from : - "PF_VCPU" - | "PF_IDLE" - | "PF_EXITING" - | "PF_POSTCOREDUMP" - | "PF_IO_WORKER" - | "PF_WQ_WORKER" - | "PF_FORKNOEXEC" - | "PF_MCE_PROCESS" - | "PF_SUPERPRIV" - | "PF_DUMPCORE" - | "PF_SIGNALED" - | "PF_MEMALLOC" - | "PF_NPROC_EXCEEDED" - | "PF_USED_MATH" - | "PF_USER_WORKER" - | "PF_NOFREEZE" - | "PF_KSWAPD" - | "PF_MEMALLOC_NOFS" - | "PF_MEMALLOC_NOIO" - | "PF_LOCAL_THROTTLE" - | "PF_KTHREAD" - | "PF_RANDOMIZE" - | "PF_NO_SETAFFINITY" - | "PF_MCE_EARLY" - | "PF_MEMALLOC_PIN" - | "PF_BLOCK_TS" - | "PF_SUSPEND_TASK" => true, + "PF_VCPU" | "PF_IDLE" | "PF_EXITING" | "PF_POSTCOREDUMP" | "PF_IO_WORKER" + | "PF_WQ_WORKER" | "PF_FORKNOEXEC" | "PF_MCE_PROCESS" | "PF_SUPERPRIV" + | "PF_DUMPCORE" | "PF_SIGNALED" | "PF_MEMALLOC" | "PF_NPROC_EXCEEDED" + | "PF_USED_MATH" | "PF_USER_WORKER" | "PF_NOFREEZE" | "PF_KSWAPD" + | "PF_MEMALLOC_NOFS" | "PF_MEMALLOC_NOIO" | "PF_LOCAL_THROTTLE" | "PF_KTHREAD" + | "PF_RANDOMIZE" | "PF_NO_SETAFFINITY" | "PF_MCE_EARLY" | "PF_MEMALLOC_PIN" + | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, // FIXME(linux): Requires >= 6.9 kernel headers. "EPIOCSPARAMS" | "EPIOCGPARAMS" => true, @@ -4485,14 +4473,12 @@ fn test_linux(target: &str) { "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, // FIXME(linux): Requires >= 6.12 kernel headers. - "SO_DEVMEM_LINEAR" - | "SO_DEVMEM_DMABUF" - | "SO_DEVMEM_DONTNEED" - | "SCM_DEVMEM_LINEAR" - | "SCM_DEVMEM_DMABUF" => true, + "SO_DEVMEM_LINEAR" | "SO_DEVMEM_DMABUF" | "SO_DEVMEM_DONTNEED" + | "SCM_DEVMEM_LINEAR" | "SCM_DEVMEM_DMABUF" => true, // FIXME(linux): Requires >= 6.4 kernel headers. - "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, + "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" + | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, // FIXME(linux): Requires >= 6.14 kernel headers. "SECBIT_EXEC_DENY_INTERACTIVE" From 97d388c87a7a8e2494f4c36939ceab7a6bb4889f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 22:51:30 -0500 Subject: [PATCH 46/58] test: Use automatic test detection Move from `test/` to `tests/`, which is the directory for autodetection. This means that we can drop `[[test]]` entries in `libc-test/Cargo.toml` that don't require nondefault configuration like `harness = false`. The style library had to be moved to `style_lib` so that `style` could be used as the test name. (backport ) (cherry picked from commit eab41969cb267cb69b952fcadb355fcd9359a032) --- libc-test/Cargo.toml | 30 ++++--------------- libc-test/{test => tests}/ctest.rs | 0 libc-test/{test => tests}/linux_elf.rs | 0 libc-test/{test => tests}/linux_fcntl.rs | 0 libc-test/{test => tests}/linux_if_arp.rs | 0 libc-test/{test => tests}/linux_ipv6.rs | 0 .../{test => tests}/linux_kernel_version.rs | 0 libc-test/{test => tests}/linux_strerror_r.rs | 0 libc-test/{test => tests}/linux_termios.rs | 0 libc-test/{test => tests}/semver.rs | 0 .../{test/check_style.rs => tests/style.rs} | 4 +-- .../{test/style => tests/style_lib}/mod.rs | 0 libc-test/{test => tests}/style_tests.rs | 4 +-- 13 files changed, 10 insertions(+), 28 deletions(-) rename libc-test/{test => tests}/ctest.rs (100%) rename libc-test/{test => tests}/linux_elf.rs (100%) rename libc-test/{test => tests}/linux_fcntl.rs (100%) rename libc-test/{test => tests}/linux_if_arp.rs (100%) rename libc-test/{test => tests}/linux_ipv6.rs (100%) rename libc-test/{test => tests}/linux_kernel_version.rs (100%) rename libc-test/{test => tests}/linux_strerror_r.rs (100%) rename libc-test/{test => tests}/linux_termios.rs (100%) rename libc-test/{test => tests}/semver.rs (100%) rename libc-test/{test/check_style.rs => tests/style.rs} (96%) rename libc-test/{test/style => tests/style_lib}/mod.rs (100%) rename libc-test/{test => tests}/style_tests.rs (99%) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 9ebac5ba11808..f761bab3a4dde 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -32,54 +32,36 @@ extra_traits = ["libc/extra_traits"] [[test]] name = "ctest" -path = "test/ctest.rs" harness = false [[test]] -name = "linux-fcntl" -path = "test/linux_fcntl.rs" +name = "linux_fcntl" harness = false [[test]] -name = "linux-if-arp" -path = "test/linux_if_arp.rs" +name = "linux_if_arp" harness = false [[test]] -name = "linux-ipv6" -path = "test/linux_ipv6.rs" +name = "linux_ipv6" harness = false [[test]] -name = "linux-elf" -path = "test/linux_elf.rs" +name = "linux_elf" harness = false [[test]] -name = "linux-strerror_r" -path = "test/linux_strerror_r.rs" +name = "linux_strerror_r" harness = false [[test]] -name = "linux-termios" -path = "test/linux_termios.rs" +name = "linux_termios" harness = false [[test]] name = "semver" -path = "test/semver.rs" harness = false -[[test]] -name = "style" -path = "test/check_style.rs" -harness = true - -[[test]] -name = "style_tests" -path = "test/style_tests.rs" -harness = true - # FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]` # once MSRV is above 1.64 and replaced with `[lints] workspace=true` diff --git a/libc-test/test/ctest.rs b/libc-test/tests/ctest.rs similarity index 100% rename from libc-test/test/ctest.rs rename to libc-test/tests/ctest.rs diff --git a/libc-test/test/linux_elf.rs b/libc-test/tests/linux_elf.rs similarity index 100% rename from libc-test/test/linux_elf.rs rename to libc-test/tests/linux_elf.rs diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/tests/linux_fcntl.rs similarity index 100% rename from libc-test/test/linux_fcntl.rs rename to libc-test/tests/linux_fcntl.rs diff --git a/libc-test/test/linux_if_arp.rs b/libc-test/tests/linux_if_arp.rs similarity index 100% rename from libc-test/test/linux_if_arp.rs rename to libc-test/tests/linux_if_arp.rs diff --git a/libc-test/test/linux_ipv6.rs b/libc-test/tests/linux_ipv6.rs similarity index 100% rename from libc-test/test/linux_ipv6.rs rename to libc-test/tests/linux_ipv6.rs diff --git a/libc-test/test/linux_kernel_version.rs b/libc-test/tests/linux_kernel_version.rs similarity index 100% rename from libc-test/test/linux_kernel_version.rs rename to libc-test/tests/linux_kernel_version.rs diff --git a/libc-test/test/linux_strerror_r.rs b/libc-test/tests/linux_strerror_r.rs similarity index 100% rename from libc-test/test/linux_strerror_r.rs rename to libc-test/tests/linux_strerror_r.rs diff --git a/libc-test/test/linux_termios.rs b/libc-test/tests/linux_termios.rs similarity index 100% rename from libc-test/test/linux_termios.rs rename to libc-test/tests/linux_termios.rs diff --git a/libc-test/test/semver.rs b/libc-test/tests/semver.rs similarity index 100% rename from libc-test/test/semver.rs rename to libc-test/tests/semver.rs diff --git a/libc-test/test/check_style.rs b/libc-test/tests/style.rs similarity index 96% rename from libc-test/test/check_style.rs rename to libc-test/tests/style.rs index d1d7fdf4aa150..d5af8dddbf973 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/tests/style.rs @@ -9,12 +9,12 @@ //! cargo test --test style //! ``` -pub mod style; +pub mod style_lib; use std::env; use std::path::Path; -use style::{Result, StyleChecker}; +use style_lib::{Result, StyleChecker}; /// Relative to `src/`. const SKIP_PREFIXES: &[&str] = &[ diff --git a/libc-test/test/style/mod.rs b/libc-test/tests/style_lib/mod.rs similarity index 100% rename from libc-test/test/style/mod.rs rename to libc-test/tests/style_lib/mod.rs diff --git a/libc-test/test/style_tests.rs b/libc-test/tests/style_tests.rs similarity index 99% rename from libc-test/test/style_tests.rs rename to libc-test/tests/style_tests.rs index be8fddbccf644..e136bb66d26a4 100644 --- a/libc-test/test/style_tests.rs +++ b/libc-test/tests/style_tests.rs @@ -1,8 +1,8 @@ //! Verifies the implementation of the style checker in [style]. -use style::StyleChecker; +use style_lib::StyleChecker; -pub mod style; +pub mod style_lib; #[test] fn check_style_accept_correct_module_layout() { From ce98b096e13a97fb26f4ccfb84750fa9e6d12a08 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 04:17:24 -0400 Subject: [PATCH 47/58] test: Commonize shared configuration Every platform needs the `__c_anonymous` config and most need to skip `__uint128`, so just do these in a common place. (backport ) (cherry picked from commit c22bf186d2986ad804fc7e928f1d1d3c33b0e565) --- libc-test/build.rs | 102 +++++++-------------------------------------- 1 file changed, 16 insertions(+), 86 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index fe178dcb4426f..51457f3b4f6e3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -72,6 +72,16 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); cfg.skip_private(true); + + // Skip anonymous unions/structs. + cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); + cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); + + // __uint128 is not declared in C, but is an alias we export. + // FIXME(1.0): These aliases will eventually be removed. + cfg.skip_alias(|ty| ty.ident() == "__uint128"); + cfg } @@ -307,10 +317,6 @@ fn test_apple(target: &str) { (x86_64, "crt_externs.h"), ); - // Skip anonymous unions/structs. - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| { match s.ident() { // FIXME(union): actually a union @@ -324,15 +330,6 @@ fn test_apple(target: &str) { } }); - cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_alias(|ty| { - match ty.ident() { - // FIXME(macos): "'__uint128' undeclared" in C - "__uint128" => true, - _ => false, - } - }); - cfg.skip_const(move |constant| { match constant.ident() { // They're declared via `deprecated_mach` and we don't support it anymore. @@ -590,9 +587,6 @@ fn test_openbsd(target: &str) { } }); - // Skip anonymous unions/structs. - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |ty| { match ty.ident() { // FIXME(union): actually a union @@ -729,14 +723,6 @@ fn test_cygwin(target: &str) { _ => false, }); - cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } - - false - }); - cfg.rename_struct_field(move |struct_, field| { match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part @@ -869,17 +855,12 @@ fn test_windows(target: &str) { }); cfg.skip_struct(move |struct_| { - let ty = struct_.ident(); - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + match struct_.ident() { // FIXME(windows): The size and alignment of this struct are incorrect "timespec" if gnu && i686 => true, _ => false, } }); - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_const(move |constant| { match constant.ident() { @@ -1141,15 +1122,12 @@ fn test_solarish(target: &str) { cfg.skip_union(|union_| { // the union handling is a mess - if union_.ident().starts_with("__c_anonymous_") || union_.ident().contains("door_desc_t_") { + if union_.ident().contains("door_desc_t_") { return true; } false }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } // the union handling is a mess if struct_.ident().contains("door_desc_t_") { return true; @@ -1392,13 +1370,7 @@ fn test_netbsd(target: &str) { } }); - cfg.skip_struct(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_union(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_alias(move |ty| { - if ty.ident().starts_with("__c_anonymous_") { - return true; - } match ty.ident() { // FIXME(netbsd): sighandler_t is crazy across platforms "sighandler_t" => true, @@ -1627,9 +1599,6 @@ fn test_dragonflybsd(target: &str) { }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since // there are header conflicts when including them with all the other @@ -2007,8 +1976,6 @@ fn test_android(target: &str) { "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, - // FIXME(android): "'__uint128' undeclared" in C - "__uint128" => true, // Added in API level 24 "if_nameindex" => true, @@ -2016,12 +1983,7 @@ fn test_android(target: &str) { } }); - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. @@ -2812,13 +2774,8 @@ fn test_freebsd(target: &str) { } }); - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { - let ty = struct_.ident(); - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + match struct_.ident() { // `procstat` is a private struct "procstat" => true, @@ -3132,10 +3089,6 @@ fn test_emscripten(target: &str) { }); cfg.skip_union(|union_| { - if union_.ident().starts_with("__c_anonymous_") { - return true; - } - match union_.ident() { // No epoll support // https://github.com/emscripten-core/emscripten/issues/5033 @@ -3154,9 +3107,6 @@ fn test_emscripten(target: &str) { }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // This is actually a union, not a struct "sigval" => true, @@ -3430,17 +3380,11 @@ fn test_neutrino(target: &str) { // Does not exist in Neutrino "locale_t" => true, - // FIXME: "'__uint128' undeclared" in C - "__uint128" => true, - _ => false, } }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { "Elf64_Phdr" | "Elf32_Phdr" => true, @@ -4014,9 +3958,6 @@ fn test_linux(target: &str) { // specific type. "Ioctl" => true, - // FIXME: "'__uint128' undeclared" in C - "__uint128" => true, - t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -4028,10 +3969,6 @@ fn test_linux(target: &str) { } }); - // Skip structs and enums that are unnamed in C. - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| struct_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| { let ty = struct_.ident(); @@ -4113,10 +4050,7 @@ fn test_linux(target: &str) { "xdp_umem_reg" => true, // FIXME(linux): Requires >= 6.8 kernel headers. - "xsk_tx_metadata" - | "__c_anonymous_xsk_tx_metadata_union" - | "xsk_tx_metadata_request" - | "xsk_tx_metadata_completion" => true, + "xsk_tx_metadata" | "xsk_tx_metadata_request" | "xsk_tx_metadata_completion" => true, // A new field was added in kernel 5.4, this is the old version for backwards compatibility. // https://github.com/torvalds/linux/commit/77cd0d7b3f257fd0e3096b4fdcff1a7d38e99e10 @@ -4797,9 +4731,9 @@ fn test_linux_like_apis(target: &str) { if linux || android || emscripten { // test strerror_r from the `string.h` header config_gnu_bits(target, &mut cfg); - headers!(cfg, "string.h",); - cfg.skip_alias(|_| true) + cfg.header("string.h") + .skip_alias(|_| true) .skip_static(|_| true) .skip_const(|_| true) .skip_struct(|_| true) @@ -5098,11 +5032,7 @@ fn test_haiku(target: &str) { "support/TypeConstants.h", ); - cfg.skip_union(|union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // FIXME(union): actually a union "sigval" => true, From a7cb0fc648823b926bf22a4a60b198bdc9a9952f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 05:58:28 -0400 Subject: [PATCH 48/58] apple: Port mcontext and ucontext to the new structure This includes `signal.h` stubs since that is a common header to import these types. (backport ) (cherry picked from commit 67f88659c80ce963de720fcfc5ebe6490c033f37) --- src/new/apple/apple_libc/signal.rs | 5 + src/new/apple/mod.rs | 10 ++ src/new/apple/xnu/arm/_mcontext.rs | 15 +++ src/new/apple/xnu/i386/_mcontext.rs | 15 +++ src/new/apple/xnu/mach/arm/_structs.rs | 37 ++++++++ src/new/apple/xnu/mach/i386/_structs.rs | 92 +++++++++++++++++++ src/new/apple/xnu/mach/machine/_structs.rs | 13 +++ src/new/apple/xnu/mach/mod.rs | 20 ++++ src/new/apple/xnu/machine/_mcontext.rs | 11 +++ src/new/apple/xnu/mod.rs | 30 ++++++ src/new/apple/xnu/sys/_types/_ucontext.rs | 17 ++++ src/new/apple/xnu/sys/mod.rs | 12 +++ src/new/apple/xnu/sys/signal.rs | 6 ++ src/new/mod.rs | 14 +++ src/unix/bsd/apple/b64/aarch64/mod.rs | 38 -------- src/unix/bsd/apple/b64/x86_64/mod.rs | 102 --------------------- triagebot.toml | 5 +- 17 files changed, 301 insertions(+), 141 deletions(-) create mode 100644 src/new/apple/apple_libc/signal.rs create mode 100644 src/new/apple/mod.rs create mode 100644 src/new/apple/xnu/arm/_mcontext.rs create mode 100644 src/new/apple/xnu/i386/_mcontext.rs create mode 100644 src/new/apple/xnu/mach/arm/_structs.rs create mode 100644 src/new/apple/xnu/mach/i386/_structs.rs create mode 100644 src/new/apple/xnu/mach/machine/_structs.rs create mode 100644 src/new/apple/xnu/mach/mod.rs create mode 100644 src/new/apple/xnu/machine/_mcontext.rs create mode 100644 src/new/apple/xnu/mod.rs create mode 100644 src/new/apple/xnu/sys/_types/_ucontext.rs create mode 100644 src/new/apple/xnu/sys/mod.rs create mode 100644 src/new/apple/xnu/sys/signal.rs diff --git a/src/new/apple/apple_libc/signal.rs b/src/new/apple/apple_libc/signal.rs new file mode 100644 index 0000000000000..971c47318c041 --- /dev/null +++ b/src/new/apple/apple_libc/signal.rs @@ -0,0 +1,5 @@ +//! Header: `signal.h` +//! +//! https://github.com/apple-oss-distributions/Libc/blob/main/include/signal.h + +pub use crate::sys::signal::*; diff --git a/src/new/apple/mod.rs b/src/new/apple/mod.rs new file mode 100644 index 0000000000000..c855a135ccf3b --- /dev/null +++ b/src/new/apple/mod.rs @@ -0,0 +1,10 @@ +//! Entrypoint for Apple headers, usually found as part of the Xcode SDK. + +pub(crate) mod xnu; +pub(crate) use xnu::*; + +pub(crate) mod apple_libc { + pub(crate) mod signal; +} + +pub(crate) use apple_libc::*; diff --git a/src/new/apple/xnu/arm/_mcontext.rs b/src/new/apple/xnu/arm/_mcontext.rs new file mode 100644 index 0000000000000..e57bc4f8adb09 --- /dev/null +++ b/src/new/apple/xnu/arm/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `arm/_mcontext.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/arm/_mcontext.h + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_arm_exception_state64, + pub __ss: __darwin_arm_thread_state64, + pub __ns: __darwin_arm_neon_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/src/new/apple/xnu/i386/_mcontext.rs b/src/new/apple/xnu/i386/_mcontext.rs new file mode 100644 index 0000000000000..8ca3b116d9f26 --- /dev/null +++ b/src/new/apple/xnu/i386/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `i386/_mcontext.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/i386/_mcontext.h + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_x86_exception_state64, + pub __ss: __darwin_x86_thread_state64, + pub __fs: __darwin_x86_float_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/src/new/apple/xnu/mach/arm/_structs.rs b/src/new/apple/xnu/mach/arm/_structs.rs new file mode 100644 index 0000000000000..d8d3b958ad5dd --- /dev/null +++ b/src/new/apple/xnu/mach/arm/_structs.rs @@ -0,0 +1,37 @@ +//! Header: `arm/_structs.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h + +#[cfg(target_arch = "arm")] +use crate::prelude::*; + +s! { + pub struct __darwin_arm_exception_state64 { + pub __far: u64, + pub __esr: u32, + pub __exception: u32, + } + + pub struct __darwin_arm_thread_state64 { + pub __x: [u64; 29], + pub __fp: u64, + pub __lr: u64, + pub __sp: u64, + pub __pc: u64, + pub __cpsr: u32, + pub __pad: u32, + } + + #[cfg(target_arch = "aarch64")] + pub struct __darwin_arm_neon_state64 { + pub __v: [crate::__uint128_t; 32], + pub __fpsr: u32, + pub __fpcr: u32, + } + + #[cfg(target_arch = "arm")] + #[repr(align(16))] + pub struct __darwin_arm_neon_state64 { + opaque: [c_char; (32 * 16) + (2 * size_of::())], + } +} diff --git a/src/new/apple/xnu/mach/i386/_structs.rs b/src/new/apple/xnu/mach/i386/_structs.rs new file mode 100644 index 0000000000000..ea274e26a6885 --- /dev/null +++ b/src/new/apple/xnu/mach/i386/_structs.rs @@ -0,0 +1,92 @@ +//! Header: `i386/_structs.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/i386/_structs.h + +use crate::prelude::*; + +s! { + pub struct __darwin_mmst_reg { + pub __mmst_reg: [c_char; 10], + pub __mmst_rsrv: [c_char; 6], + } + + pub struct __darwin_xmm_reg { + pub __xmm_reg: [c_char; 16], + } + + pub struct __darwin_x86_thread_state64 { + pub __rax: u64, + pub __rbx: u64, + pub __rcx: u64, + pub __rdx: u64, + pub __rdi: u64, + pub __rsi: u64, + pub __rbp: u64, + pub __rsp: u64, + pub __r8: u64, + pub __r9: u64, + pub __r10: u64, + pub __r11: u64, + pub __r12: u64, + pub __r13: u64, + pub __r14: u64, + pub __r15: u64, + pub __rip: u64, + pub __rflags: u64, + pub __cs: u64, + pub __fs: u64, + pub __gs: u64, + } + + pub struct __darwin_x86_exception_state64 { + pub __trapno: u16, + pub __cpu: u16, + pub __err: u32, + pub __faultvaddr: u64, + } + + pub struct __darwin_x86_float_state64 { + pub __fpu_reserved: [c_int; 2], + __fpu_fcw: c_short, + __fpu_fsw: c_short, + pub __fpu_ftw: u8, + pub __fpu_rsrv1: u8, + pub __fpu_fop: u16, + pub __fpu_ip: u32, + pub __fpu_cs: u16, + pub __fpu_rsrv2: u16, + pub __fpu_dp: u32, + pub __fpu_ds: u16, + pub __fpu_rsrv3: u16, + pub __fpu_mxcsr: u32, + pub __fpu_mxcsrmask: u32, + pub __fpu_stmm0: __darwin_mmst_reg, + pub __fpu_stmm1: __darwin_mmst_reg, + pub __fpu_stmm2: __darwin_mmst_reg, + pub __fpu_stmm3: __darwin_mmst_reg, + pub __fpu_stmm4: __darwin_mmst_reg, + pub __fpu_stmm5: __darwin_mmst_reg, + pub __fpu_stmm6: __darwin_mmst_reg, + pub __fpu_stmm7: __darwin_mmst_reg, + pub __fpu_xmm0: __darwin_xmm_reg, + pub __fpu_xmm1: __darwin_xmm_reg, + pub __fpu_xmm2: __darwin_xmm_reg, + pub __fpu_xmm3: __darwin_xmm_reg, + pub __fpu_xmm4: __darwin_xmm_reg, + pub __fpu_xmm5: __darwin_xmm_reg, + pub __fpu_xmm6: __darwin_xmm_reg, + pub __fpu_xmm7: __darwin_xmm_reg, + pub __fpu_xmm8: __darwin_xmm_reg, + pub __fpu_xmm9: __darwin_xmm_reg, + pub __fpu_xmm10: __darwin_xmm_reg, + pub __fpu_xmm11: __darwin_xmm_reg, + pub __fpu_xmm12: __darwin_xmm_reg, + pub __fpu_xmm13: __darwin_xmm_reg, + pub __fpu_xmm14: __darwin_xmm_reg, + 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], + pub __fpu_reserved1: c_int, + } +} diff --git a/src/new/apple/xnu/mach/machine/_structs.rs b/src/new/apple/xnu/mach/machine/_structs.rs new file mode 100644 index 0000000000000..47df1005c86f8 --- /dev/null +++ b/src/new/apple/xnu/mach/machine/_structs.rs @@ -0,0 +1,13 @@ +//! Header: `mach/machine/_structs.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/machine/_structs.h + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::mach::i386::_structs::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::mach::arm::_structs::*; + } else { + // Unsupported arch + } +} diff --git a/src/new/apple/xnu/mach/mod.rs b/src/new/apple/xnu/mach/mod.rs new file mode 100644 index 0000000000000..d5fbee83e970e --- /dev/null +++ b/src/new/apple/xnu/mach/mod.rs @@ -0,0 +1,20 @@ +//! Directory: `mach/` +//! +//! https://github.com/apple-oss-distributions/xnu/tree/main/osfmk/mach + +/// Directory: `mach/arm` +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _structs; +} + +/// Directory: `mach/i386` +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _structs; +} + +/// Directory: `mach/machine` +pub(crate) mod machine { + pub(crate) mod _structs; +} diff --git a/src/new/apple/xnu/machine/_mcontext.rs b/src/new/apple/xnu/machine/_mcontext.rs new file mode 100644 index 0000000000000..004b94707e33a --- /dev/null +++ b/src/new/apple/xnu/machine/_mcontext.rs @@ -0,0 +1,11 @@ +//! Header: `machine/_mcontext.h` + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::i386::_mcontext::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::arm::_mcontext::*; + } else { + // Unsupported arch + } +} diff --git a/src/new/apple/xnu/mod.rs b/src/new/apple/xnu/mod.rs new file mode 100644 index 0000000000000..8b8afb6bc39d3 --- /dev/null +++ b/src/new/apple/xnu/mod.rs @@ -0,0 +1,30 @@ +//! Source from XNU +//! +//! We omit nesting for the `bsd` module since most items of interest are in there. + +/// Directory: `arm/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _mcontext; +} + +/// Directory: `i386/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386 +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _mcontext; +} + +pub(crate) mod mach; + +/// Directory: `machine/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine +pub(crate) mod machine { + pub(crate) mod _mcontext; +} + +pub(crate) mod sys; diff --git a/src/new/apple/xnu/sys/_types/_ucontext.rs b/src/new/apple/xnu/sys/_types/_ucontext.rs new file mode 100644 index 0000000000000..53bc0f22d6691 --- /dev/null +++ b/src/new/apple/xnu/sys/_types/_ucontext.rs @@ -0,0 +1,17 @@ +//! Header: `sys/_types/_ucontext.h` + +pub use crate::machine::_mcontext::*; +use crate::prelude::*; + +s! { + pub struct __darwin_ucontext { + pub uc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_link: *mut ucontext_t, + pub uc_mcsize: usize, + pub uc_mcontext: mcontext_t, + } +} + +pub type ucontext_t = __darwin_ucontext; diff --git a/src/new/apple/xnu/sys/mod.rs b/src/new/apple/xnu/sys/mod.rs new file mode 100644 index 0000000000000..8fdbe2846b58b --- /dev/null +++ b/src/new/apple/xnu/sys/mod.rs @@ -0,0 +1,12 @@ +//! Directory: `sys/` +//! +//! https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys + +pub(crate) mod signal; + +/// Directory: `sys/_types` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types +pub(crate) mod _types { + pub(crate) mod _ucontext; +} diff --git a/src/new/apple/xnu/sys/signal.rs b/src/new/apple/xnu/sys/signal.rs new file mode 100644 index 0000000000000..8399c830dc8cd --- /dev/null +++ b/src/new/apple/xnu/sys/signal.rs @@ -0,0 +1,6 @@ +//! Header: `sys/signal.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/signal.h + +pub use crate::machine::_mcontext::*; +pub use crate::sys::_types::_ucontext::*; diff --git a/src/new/mod.rs b/src/new/mod.rs index 0a2a55b0f469b..332c7c9001ea5 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -3,6 +3,16 @@ //! //! Eventually everything should be moved over, and we will move this directory to the top //! level in `src`. +//! +//! # Basic structure +//! +//! Each child module here represents a library or group of libraries that we are binding. Each of +//! these has several submodules, representing either a directory or a header file in that library. +//! +//! `#include`s turn into `pub use ...*;` statements. Then at the root level (here), we choose +//! which top-level headers we want to reexport the definitions for. +//! +//! All modules are only crate-public since we don't reexport this structure. cfg_if! { if #[cfg(target_os = "linux")] { @@ -11,5 +21,9 @@ cfg_if! { } else if #[cfg(target_os = "android")] { mod bionic; pub use bionic::*; + } else if #[cfg(target_vendor = "apple")] { + mod apple; + pub(crate) use apple::*; + pub use signal::*; } } diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index a13013c09b03b..b5cbe8ff5175f 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,49 +1,11 @@ use crate::prelude::*; pub type boolean_t = c_int; -pub type mcontext_t = *mut __darwin_mcontext64; s! { pub struct malloc_zone_t { __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support } - - pub struct ucontext_t { - pub uc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub uc_stack: crate::stack_t, - pub uc_link: *mut crate::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_arm_exception_state64, - pub __ss: __darwin_arm_thread_state64, - pub __ns: __darwin_arm_neon_state64, - } - - pub struct __darwin_arm_exception_state64 { - pub __far: u64, - pub __esr: u32, - pub __exception: u32, - } - - pub struct __darwin_arm_thread_state64 { - pub __x: [u64; 29], - pub __fp: u64, - pub __lr: u64, - pub __sp: u64, - pub __pc: u64, - pub __cpsr: u32, - pub __pad: u32, - } - - pub struct __darwin_arm_neon_state64 { - pub __v: [crate::__uint128_t; 32], - pub __fpsr: u32, - pub __fpcr: u32, - } } s_no_extra_traits! { diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 5365becf66c3e..2b22f489b9c6b 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -1,110 +1,8 @@ use crate::prelude::*; pub type boolean_t = c_uint; -pub type mcontext_t = *mut __darwin_mcontext64; s! { - pub struct ucontext_t { - pub uc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub uc_stack: crate::stack_t, - pub uc_link: *mut crate::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_x86_exception_state64, - pub __ss: __darwin_x86_thread_state64, - pub __fs: __darwin_x86_float_state64, - } - - pub struct __darwin_x86_exception_state64 { - pub __trapno: u16, - pub __cpu: u16, - pub __err: u32, - pub __faultvaddr: u64, - } - - pub struct __darwin_x86_thread_state64 { - pub __rax: u64, - pub __rbx: u64, - pub __rcx: u64, - pub __rdx: u64, - pub __rdi: u64, - pub __rsi: u64, - pub __rbp: u64, - pub __rsp: u64, - pub __r8: u64, - pub __r9: u64, - pub __r10: u64, - pub __r11: u64, - pub __r12: u64, - pub __r13: u64, - pub __r14: u64, - pub __r15: u64, - pub __rip: u64, - pub __rflags: u64, - pub __cs: u64, - pub __fs: u64, - pub __gs: u64, - } - - pub struct __darwin_x86_float_state64 { - pub __fpu_reserved: [c_int; 2], - __fpu_fcw: c_short, - __fpu_fsw: c_short, - pub __fpu_ftw: u8, - pub __fpu_rsrv1: u8, - pub __fpu_fop: u16, - pub __fpu_ip: u32, - pub __fpu_cs: u16, - pub __fpu_rsrv2: u16, - pub __fpu_dp: u32, - pub __fpu_ds: u16, - pub __fpu_rsrv3: u16, - pub __fpu_mxcsr: u32, - pub __fpu_mxcsrmask: u32, - pub __fpu_stmm0: __darwin_mmst_reg, - pub __fpu_stmm1: __darwin_mmst_reg, - pub __fpu_stmm2: __darwin_mmst_reg, - pub __fpu_stmm3: __darwin_mmst_reg, - pub __fpu_stmm4: __darwin_mmst_reg, - pub __fpu_stmm5: __darwin_mmst_reg, - pub __fpu_stmm6: __darwin_mmst_reg, - pub __fpu_stmm7: __darwin_mmst_reg, - pub __fpu_xmm0: __darwin_xmm_reg, - pub __fpu_xmm1: __darwin_xmm_reg, - pub __fpu_xmm2: __darwin_xmm_reg, - pub __fpu_xmm3: __darwin_xmm_reg, - pub __fpu_xmm4: __darwin_xmm_reg, - pub __fpu_xmm5: __darwin_xmm_reg, - pub __fpu_xmm6: __darwin_xmm_reg, - pub __fpu_xmm7: __darwin_xmm_reg, - pub __fpu_xmm8: __darwin_xmm_reg, - pub __fpu_xmm9: __darwin_xmm_reg, - pub __fpu_xmm10: __darwin_xmm_reg, - pub __fpu_xmm11: __darwin_xmm_reg, - pub __fpu_xmm12: __darwin_xmm_reg, - pub __fpu_xmm13: __darwin_xmm_reg, - pub __fpu_xmm14: __darwin_xmm_reg, - pub __fpu_xmm15: __darwin_xmm_reg, - // 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], - pub __fpu_reserved1: c_int, - } - - pub struct __darwin_mmst_reg { - pub __mmst_reg: [c_char; 10], - pub __mmst_rsrv: [c_char; 6], - } - - pub struct __darwin_xmm_reg { - pub __xmm_reg: [c_char; 16], - } - pub struct malloc_introspection_t { _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now } diff --git a/triagebot.toml b/triagebot.toml index 9b27504ffc9ae..099a4f87f3d4f 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -75,7 +75,10 @@ trigger_files = [ trigger_files = ["src/unix/linux_like/mod.rs"] [autolabel."O-macos"] -trigger_files = ["src/unix/bsd/apple"] +trigger_files = [ + "src/unix/bsd/apple", + "src/new/apple", +] [autolabel."O-mips"] trigger_files = [ From 23a0500d73a15fc4bf759a3d45d81b64730753ee Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 19:15:17 -0400 Subject: [PATCH 49/58] linux: Switch from glob exports to select imports Match Apple to make it more clear what headers we want to map. (backport ) (cherry picked from commit ed6645d101aabb0ec14814bf6c301c903c595bd0) --- src/new/linux_uapi/linux/can.rs | 4 ---- src/new/linux_uapi/linux/can/bcm.rs | 2 +- src/new/linux_uapi/linux/can/raw.rs | 2 +- src/new/linux_uapi/linux/keyctl.rs | 3 +-- src/new/linux_uapi/linux/mod.rs | 6 +++--- src/new/linux_uapi/mod.rs | 1 - src/new/mod.rs | 15 ++++++++++++++- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 51e438434b09e..108a90b1a92c6 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -4,10 +4,6 @@ pub(crate) mod bcm; pub(crate) mod j1939; pub(crate) mod raw; -pub use bcm::*; -pub use j1939::*; -pub use raw::*; - use crate::prelude::*; pub const CAN_EFF_FLAG: canid_t = 0x80000000; diff --git a/src/new/linux_uapi/linux/can/bcm.rs b/src/new/linux_uapi/linux/can/bcm.rs index 2cdeb399b31f3..10f67d2db04e9 100644 --- a/src/new/linux_uapi/linux/can/bcm.rs +++ b/src/new/linux_uapi/linux/can/bcm.rs @@ -1,4 +1,4 @@ -//! `linux/can/bcm.h` +//! Header: `linux/can/bcm.h` pub use crate::linux::can::*; diff --git a/src/new/linux_uapi/linux/can/raw.rs b/src/new/linux_uapi/linux/can/raw.rs index 1f92a13edbba6..470334bd5d147 100644 --- a/src/new/linux_uapi/linux/can/raw.rs +++ b/src/new/linux_uapi/linux/can/raw.rs @@ -1,4 +1,4 @@ -//! `linux/can/raw.h` +//! Header: `linux/can/raw.h` pub use crate::linux::can::*; diff --git a/src/new/linux_uapi/linux/keyctl.rs b/src/new/linux_uapi/linux/keyctl.rs index 2c86df39e190b..cc6527a8a5113 100644 --- a/src/new/linux_uapi/linux/keyctl.rs +++ b/src/new/linux_uapi/linux/keyctl.rs @@ -1,6 +1,5 @@ -//! Header: `uapi/linux/keyctl.h` +//! Header: `linux/keyctl.h` -// linux/keyctl.h pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index e264892063807..993394e4370ca 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -1,6 +1,6 @@ -//! The `linux` directory within `include/uapi` in the Linux source tree. +//! Directory: `linux/` +//! +//! pub(crate) mod can; -pub use can::*; pub(crate) mod keyctl; -pub use keyctl::*; diff --git a/src/new/linux_uapi/mod.rs b/src/new/linux_uapi/mod.rs index e0d4e094c435f..8ac3022d16578 100644 --- a/src/new/linux_uapi/mod.rs +++ b/src/new/linux_uapi/mod.rs @@ -1,4 +1,3 @@ //! This directory maps to `include/uapi` in the Linux source tree. pub(crate) mod linux; -pub use linux::*; diff --git a/src/new/mod.rs b/src/new/mod.rs index 332c7c9001ea5..410c7f5536fb8 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -14,16 +14,29 @@ //! //! All modules are only crate-public since we don't reexport this structure. +// Libraries available on each platform cfg_if! { if #[cfg(target_os = "linux")] { mod linux_uapi; - pub use linux_uapi::*; + pub(crate) use linux_uapi::*; } else if #[cfg(target_os = "android")] { mod bionic; pub use bionic::*; } else if #[cfg(target_vendor = "apple")] { mod apple; pub(crate) use apple::*; + } +} + +// Headers we export +cfg_if! { + if #[cfg(target_os = "linux")] { + pub use linux::can::bcm::*; + pub use linux::can::j1939::*; + pub use linux::can::raw::*; + pub use linux::can::*; + pub use linux::keyctl::*; + } else if #[cfg(target_vendor = "apple")] { pub use signal::*; } } From a786018cac1ac603fef6cf5465e82298bc979da0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 24 Oct 2025 20:09:09 -0400 Subject: [PATCH 50/58] android: Switch from glob exports to select imports Match Apple and Linux to make it more clear what headers we want to map. Additionally, rename to `bionic_libc` since we may have others in the future (e.g. `bionic_uapi`). (backport ) (cherry picked from commit 0486b80b3d05c6854eda85eb69171e955e31547a) --- src/new/bionic/mod.rs | 2 -- src/new/bionic/sys/mod.rs | 2 -- src/new/bionic_libc/mod.rs | 5 +++++ src/new/bionic_libc/sys/mod.rs | 3 +++ src/new/{bionic => bionic_libc}/sys/socket.rs | 2 +- src/new/mod.rs | 8 +++++--- triagebot.toml | 5 ++++- 7 files changed, 18 insertions(+), 9 deletions(-) delete mode 100644 src/new/bionic/mod.rs delete mode 100644 src/new/bionic/sys/mod.rs create mode 100644 src/new/bionic_libc/mod.rs create mode 100644 src/new/bionic_libc/sys/mod.rs rename src/new/{bionic => bionic_libc}/sys/socket.rs (95%) diff --git a/src/new/bionic/mod.rs b/src/new/bionic/mod.rs deleted file mode 100644 index 644a4ab96d90f..0000000000000 --- a/src/new/bionic/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod sys; -pub use sys::*; diff --git a/src/new/bionic/sys/mod.rs b/src/new/bionic/sys/mod.rs deleted file mode 100644 index fd96d0821ac88..0000000000000 --- a/src/new/bionic/sys/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod socket; -pub use socket::*; diff --git a/src/new/bionic_libc/mod.rs b/src/new/bionic_libc/mod.rs new file mode 100644 index 0000000000000..2863b72cc2ed9 --- /dev/null +++ b/src/new/bionic_libc/mod.rs @@ -0,0 +1,5 @@ +//! This directory maps to `bionic/libc/include` in the Android source. +//! +//! + +pub(crate) mod sys; diff --git a/src/new/bionic_libc/sys/mod.rs b/src/new/bionic_libc/sys/mod.rs new file mode 100644 index 0000000000000..a882cbd99fca1 --- /dev/null +++ b/src/new/bionic_libc/sys/mod.rs @@ -0,0 +1,3 @@ +//! Directory: `sys/` + +pub(crate) mod socket; diff --git a/src/new/bionic/sys/socket.rs b/src/new/bionic_libc/sys/socket.rs similarity index 95% rename from src/new/bionic/sys/socket.rs rename to src/new/bionic_libc/sys/socket.rs index 49af36fe93356..c4a4e781275d9 100644 --- a/src/new/bionic/sys/socket.rs +++ b/src/new/bionic_libc/sys/socket.rs @@ -1,4 +1,4 @@ -//! Header: `bionic/libc/include/sys/socket.h` +//! Header: `sys/socket.h` use crate::prelude::*; diff --git a/src/new/mod.rs b/src/new/mod.rs index 410c7f5536fb8..73f99c15cf628 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -20,8 +20,8 @@ cfg_if! { mod linux_uapi; pub(crate) use linux_uapi::*; } else if #[cfg(target_os = "android")] { - mod bionic; - pub use bionic::*; + mod bionic_libc; + pub(crate) use bionic_libc::*; } else if #[cfg(target_vendor = "apple")] { mod apple; pub(crate) use apple::*; @@ -30,7 +30,9 @@ cfg_if! { // Headers we export cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(target_os = "android")] { + pub use sys::socket::*; + } else if #[cfg(target_os = "linux")] { pub use linux::can::bcm::*; pub use linux::can::j1939::*; pub use linux::can::raw::*; diff --git a/triagebot.toml b/triagebot.toml index 099a4f87f3d4f..0243834494fe3 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -34,7 +34,10 @@ trigger_files = [ new_pr = true [autolabel."O-android"] -trigger_files = ["src/unix/linux_like/android"] +trigger_files = [ + "src/new/bionic_libc", + "src/unix/linux_like/android", +] [autolabel."O-arm"] trigger_files = [ From 7cd894dbb2d7616c90774de79569c43111da9183 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 24 Oct 2025 20:23:52 -0400 Subject: [PATCH 51/58] apple: Move xnu and apple_libc up a level in the new structure There isn't any need to group these two modules. (backport ) (cherry picked from commit a83905dd6aa0655c4e9bd71a8a78d2856d665dd0) --- src/new/apple/mod.rs | 10 ---------- src/new/apple_libc/mod.rs | 3 +++ src/new/{apple => }/apple_libc/signal.rs | 0 src/new/{apple/xnu => apple_xnu}/arm/_mcontext.rs | 0 src/new/{apple/xnu => apple_xnu}/i386/_mcontext.rs | 0 src/new/{apple/xnu => apple_xnu}/mach/arm/_structs.rs | 0 src/new/{apple/xnu => apple_xnu}/mach/i386/_structs.rs | 0 .../{apple/xnu => apple_xnu}/mach/machine/_structs.rs | 0 src/new/{apple/xnu => apple_xnu}/mach/mod.rs | 0 src/new/{apple/xnu => apple_xnu}/machine/_mcontext.rs | 0 src/new/{apple/xnu => apple_xnu}/mod.rs | 0 .../{apple/xnu => apple_xnu}/sys/_types/_ucontext.rs | 0 src/new/{apple/xnu => apple_xnu}/sys/mod.rs | 0 src/new/{apple/xnu => apple_xnu}/sys/signal.rs | 0 src/new/mod.rs | 6 ++++-- triagebot.toml | 3 ++- 16 files changed, 9 insertions(+), 13 deletions(-) delete mode 100644 src/new/apple/mod.rs create mode 100644 src/new/apple_libc/mod.rs rename src/new/{apple => }/apple_libc/signal.rs (100%) rename src/new/{apple/xnu => apple_xnu}/arm/_mcontext.rs (100%) rename src/new/{apple/xnu => apple_xnu}/i386/_mcontext.rs (100%) rename src/new/{apple/xnu => apple_xnu}/mach/arm/_structs.rs (100%) rename src/new/{apple/xnu => apple_xnu}/mach/i386/_structs.rs (100%) rename src/new/{apple/xnu => apple_xnu}/mach/machine/_structs.rs (100%) rename src/new/{apple/xnu => apple_xnu}/mach/mod.rs (100%) rename src/new/{apple/xnu => apple_xnu}/machine/_mcontext.rs (100%) rename src/new/{apple/xnu => apple_xnu}/mod.rs (100%) rename src/new/{apple/xnu => apple_xnu}/sys/_types/_ucontext.rs (100%) rename src/new/{apple/xnu => apple_xnu}/sys/mod.rs (100%) rename src/new/{apple/xnu => apple_xnu}/sys/signal.rs (100%) diff --git a/src/new/apple/mod.rs b/src/new/apple/mod.rs deleted file mode 100644 index c855a135ccf3b..0000000000000 --- a/src/new/apple/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! Entrypoint for Apple headers, usually found as part of the Xcode SDK. - -pub(crate) mod xnu; -pub(crate) use xnu::*; - -pub(crate) mod apple_libc { - pub(crate) mod signal; -} - -pub(crate) use apple_libc::*; diff --git a/src/new/apple_libc/mod.rs b/src/new/apple_libc/mod.rs new file mode 100644 index 0000000000000..f53b8baa38ea1 --- /dev/null +++ b/src/new/apple_libc/mod.rs @@ -0,0 +1,3 @@ +//! Entrypoint for Apple headers, usually found as part of the Xcode SDK. + +pub(crate) mod signal; diff --git a/src/new/apple/apple_libc/signal.rs b/src/new/apple_libc/signal.rs similarity index 100% rename from src/new/apple/apple_libc/signal.rs rename to src/new/apple_libc/signal.rs diff --git a/src/new/apple/xnu/arm/_mcontext.rs b/src/new/apple_xnu/arm/_mcontext.rs similarity index 100% rename from src/new/apple/xnu/arm/_mcontext.rs rename to src/new/apple_xnu/arm/_mcontext.rs diff --git a/src/new/apple/xnu/i386/_mcontext.rs b/src/new/apple_xnu/i386/_mcontext.rs similarity index 100% rename from src/new/apple/xnu/i386/_mcontext.rs rename to src/new/apple_xnu/i386/_mcontext.rs diff --git a/src/new/apple/xnu/mach/arm/_structs.rs b/src/new/apple_xnu/mach/arm/_structs.rs similarity index 100% rename from src/new/apple/xnu/mach/arm/_structs.rs rename to src/new/apple_xnu/mach/arm/_structs.rs diff --git a/src/new/apple/xnu/mach/i386/_structs.rs b/src/new/apple_xnu/mach/i386/_structs.rs similarity index 100% rename from src/new/apple/xnu/mach/i386/_structs.rs rename to src/new/apple_xnu/mach/i386/_structs.rs diff --git a/src/new/apple/xnu/mach/machine/_structs.rs b/src/new/apple_xnu/mach/machine/_structs.rs similarity index 100% rename from src/new/apple/xnu/mach/machine/_structs.rs rename to src/new/apple_xnu/mach/machine/_structs.rs diff --git a/src/new/apple/xnu/mach/mod.rs b/src/new/apple_xnu/mach/mod.rs similarity index 100% rename from src/new/apple/xnu/mach/mod.rs rename to src/new/apple_xnu/mach/mod.rs diff --git a/src/new/apple/xnu/machine/_mcontext.rs b/src/new/apple_xnu/machine/_mcontext.rs similarity index 100% rename from src/new/apple/xnu/machine/_mcontext.rs rename to src/new/apple_xnu/machine/_mcontext.rs diff --git a/src/new/apple/xnu/mod.rs b/src/new/apple_xnu/mod.rs similarity index 100% rename from src/new/apple/xnu/mod.rs rename to src/new/apple_xnu/mod.rs diff --git a/src/new/apple/xnu/sys/_types/_ucontext.rs b/src/new/apple_xnu/sys/_types/_ucontext.rs similarity index 100% rename from src/new/apple/xnu/sys/_types/_ucontext.rs rename to src/new/apple_xnu/sys/_types/_ucontext.rs diff --git a/src/new/apple/xnu/sys/mod.rs b/src/new/apple_xnu/sys/mod.rs similarity index 100% rename from src/new/apple/xnu/sys/mod.rs rename to src/new/apple_xnu/sys/mod.rs diff --git a/src/new/apple/xnu/sys/signal.rs b/src/new/apple_xnu/sys/signal.rs similarity index 100% rename from src/new/apple/xnu/sys/signal.rs rename to src/new/apple_xnu/sys/signal.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 73f99c15cf628..326a5713becc5 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -23,8 +23,10 @@ cfg_if! { mod bionic_libc; pub(crate) use bionic_libc::*; } else if #[cfg(target_vendor = "apple")] { - mod apple; - pub(crate) use apple::*; + mod apple_libc; + mod apple_xnu; + pub(crate) use apple_libc::*; + pub(crate) use apple_xnu::*; } } diff --git a/triagebot.toml b/triagebot.toml index 0243834494fe3..7e8f309b40c67 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -80,7 +80,8 @@ trigger_files = ["src/unix/linux_like/mod.rs"] [autolabel."O-macos"] trigger_files = [ "src/unix/bsd/apple", - "src/new/apple", + "src/new/apple_lib", + "src/new/apple_xnu", ] [autolabel."O-mips"] From 966725a56e01fcedf41d77aabe2870ec4d6dae75 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 23 Oct 2025 20:02:23 -0400 Subject: [PATCH 52/58] reorg: Fill in the `src/new` structure Ensure each library we provide bindings for has a home module in order to make it easier to fill things in. Where possible, I included a link to the source tree. There is also a new module `common` that contains definitions intended to be shared across multiple libraries. (backport ) (cherry picked from commit b295e7887677432fdf093c49d14ac5111f86d884) --- src/new/aix/mod.rs | 4 + src/new/common/bsd.rs | 1 + src/new/common/freebsd_like.rs | 1 + src/new/common/linux_like/mod.rs | 1 + src/new/common/mod.rs | 38 +++++++++ src/new/common/netbsd_like.rs | 1 + src/new/common/posix/mod.rs | 1 + src/new/common/solarish.rs | 1 + src/new/cygwin/mod.rs | 3 + src/new/dragonfly/mod.rs | 4 + src/new/emscripten/mod.rs | 3 + src/new/espidf/mod.rs | 2 + src/new/freebsd/mod.rs | 4 + src/new/fuchsia/mod.rs | 2 + src/new/glibc/mod.rs | 4 + src/new/haiku/mod.rs | 2 + src/new/hermit_abi/mod.rs | 3 + src/new/horizon/mod.rs | 2 + src/new/hurd/mod.rs | 2 + src/new/illumos/mod.rs | 2 + src/new/l4re/mod.rs | 3 + src/new/mod.rs | 140 ++++++++++++++++++++++++++++++- src/new/musl/mod.rs | 4 + src/new/netbsd/mod.rs | 3 + src/new/newlib/mod.rs | 2 + src/new/nto/mod.rs | 2 + src/new/nuttx/mod.rs | 2 + src/new/openbsd/mod.rs | 4 + src/new/redox/mod.rs | 3 + src/new/relibc/mod.rs | 3 + src/new/rtems/mod.rs | 2 + src/new/sgx/mod.rs | 1 + src/new/solaris/mod.rs | 3 + src/new/solid/mod.rs | 2 + src/new/teeos/mod.rs | 2 + src/new/trusty/mod.rs | 2 + src/new/uclibc/mod.rs | 4 + src/new/ucrt/mod.rs | 4 + src/new/vita/mod.rs | 2 + src/new/vxworks/mod.rs | 2 + src/new/wasi/mod.rs | 3 + src/new/xous/mod.rs | 2 + 42 files changed, 272 insertions(+), 4 deletions(-) create mode 100644 src/new/aix/mod.rs create mode 100644 src/new/common/bsd.rs create mode 100644 src/new/common/freebsd_like.rs create mode 100644 src/new/common/linux_like/mod.rs create mode 100644 src/new/common/mod.rs create mode 100644 src/new/common/netbsd_like.rs create mode 100644 src/new/common/posix/mod.rs create mode 100644 src/new/common/solarish.rs create mode 100644 src/new/cygwin/mod.rs create mode 100644 src/new/dragonfly/mod.rs create mode 100644 src/new/emscripten/mod.rs create mode 100644 src/new/espidf/mod.rs create mode 100644 src/new/freebsd/mod.rs create mode 100644 src/new/fuchsia/mod.rs create mode 100644 src/new/glibc/mod.rs create mode 100644 src/new/haiku/mod.rs create mode 100644 src/new/hermit_abi/mod.rs create mode 100644 src/new/horizon/mod.rs create mode 100644 src/new/hurd/mod.rs create mode 100644 src/new/illumos/mod.rs create mode 100644 src/new/l4re/mod.rs create mode 100644 src/new/musl/mod.rs create mode 100644 src/new/netbsd/mod.rs create mode 100644 src/new/newlib/mod.rs create mode 100644 src/new/nto/mod.rs create mode 100644 src/new/nuttx/mod.rs create mode 100644 src/new/openbsd/mod.rs create mode 100644 src/new/redox/mod.rs create mode 100644 src/new/relibc/mod.rs create mode 100644 src/new/rtems/mod.rs create mode 100644 src/new/sgx/mod.rs create mode 100644 src/new/solaris/mod.rs create mode 100644 src/new/solid/mod.rs create mode 100644 src/new/teeos/mod.rs create mode 100644 src/new/trusty/mod.rs create mode 100644 src/new/uclibc/mod.rs create mode 100644 src/new/ucrt/mod.rs create mode 100644 src/new/vita/mod.rs create mode 100644 src/new/vxworks/mod.rs create mode 100644 src/new/wasi/mod.rs create mode 100644 src/new/xous/mod.rs diff --git a/src/new/aix/mod.rs b/src/new/aix/mod.rs new file mode 100644 index 0000000000000..79645f12d7360 --- /dev/null +++ b/src/new/aix/mod.rs @@ -0,0 +1,4 @@ +//! IBM AIX libc. +//! +//! * Headers are not public +//! * Manual pages: (under "Technical reference" for that version) diff --git a/src/new/common/bsd.rs b/src/new/common/bsd.rs new file mode 100644 index 0000000000000..818daf93489c9 --- /dev/null +++ b/src/new/common/bsd.rs @@ -0,0 +1 @@ +//! Interfaces common across the BSD family. diff --git a/src/new/common/freebsd_like.rs b/src/new/common/freebsd_like.rs new file mode 100644 index 0000000000000..f49f2c9c2c06e --- /dev/null +++ b/src/new/common/freebsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in FreeBSD-derived operating systems. This includes FreeBSD and DragonFlyBSD. diff --git a/src/new/common/linux_like/mod.rs b/src/new/common/linux_like/mod.rs new file mode 100644 index 0000000000000..9aceb4e09f0e3 --- /dev/null +++ b/src/new/common/linux_like/mod.rs @@ -0,0 +1 @@ +//! API that primarily comes from Linux but is also used other platforms (e.g. Android). diff --git a/src/new/common/mod.rs b/src/new/common/mod.rs new file mode 100644 index 0000000000000..cb0588ca26100 --- /dev/null +++ b/src/new/common/mod.rs @@ -0,0 +1,38 @@ +//! Interfaces that are common across multiple platforms +//! +//! We make these available everywhere but each platform must opt in to reexporting. +//! +//! There shouldn't be any repeated definitions or complex configuration in this module. On +//! platforms that don't use common APIs it is fine to use `#[cfg(not(...))]`, but if a platform +//! needs a custom definition then it should be defined in the platform-specific module. +//! +//! The goal is that platforms need to opt in to the definitions here, so that worst case we have +//! an unused warning on untested platforms (rather than exposing incorrect API). + +#[cfg(any( + target_vendor = "apple", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd", +))] +mod bsd; + +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", +))] +mod linux_like; + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] +mod freebsd_like; + +#[cfg(any(target_os = "netbsd", target_os = "openbsd"))] +mod netbsd_like; + +#[cfg(any(target_os = "illumos", target_os = "solaris"))] +mod solarish; + +mod posix; diff --git a/src/new/common/netbsd_like.rs b/src/new/common/netbsd_like.rs new file mode 100644 index 0000000000000..4267357ac9046 --- /dev/null +++ b/src/new/common/netbsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in NetBSD-derived operating systems. This includes NetBSD and OpenBSD. diff --git a/src/new/common/posix/mod.rs b/src/new/common/posix/mod.rs new file mode 100644 index 0000000000000..cb33296a9c656 --- /dev/null +++ b/src/new/common/posix/mod.rs @@ -0,0 +1 @@ +//! POSIX APIs that are used by a number of platforms diff --git a/src/new/common/solarish.rs b/src/new/common/solarish.rs new file mode 100644 index 0000000000000..f966114e370ae --- /dev/null +++ b/src/new/common/solarish.rs @@ -0,0 +1 @@ +//! Interfaces common in solaris-derived operating systems. This includes Solaris and Illumos. diff --git a/src/new/cygwin/mod.rs b/src/new/cygwin/mod.rs new file mode 100644 index 0000000000000..29d62f02f9fee --- /dev/null +++ b/src/new/cygwin/mod.rs @@ -0,0 +1,3 @@ +//! Cygwin libc. +//! +//! * Headers: diff --git a/src/new/dragonfly/mod.rs b/src/new/dragonfly/mod.rs new file mode 100644 index 0000000000000..9ea26f522be66 --- /dev/null +++ b/src/new/dragonfly/mod.rs @@ -0,0 +1,4 @@ +//! DragonFly BSD libc. +//! +//! * Headers: +//! * Manual pages: diff --git a/src/new/emscripten/mod.rs b/src/new/emscripten/mod.rs new file mode 100644 index 0000000000000..e58a3aceada16 --- /dev/null +++ b/src/new/emscripten/mod.rs @@ -0,0 +1,3 @@ +//! Emscripten libc. +//! +//! * Headers: diff --git a/src/new/espidf/mod.rs b/src/new/espidf/mod.rs new file mode 100644 index 0000000000000..061ea6e64614b --- /dev/null +++ b/src/new/espidf/mod.rs @@ -0,0 +1,2 @@ +//! Expressif libc. +// FIXME(espidf): link to headers needed. diff --git a/src/new/freebsd/mod.rs b/src/new/freebsd/mod.rs new file mode 100644 index 0000000000000..a1241c7a68cef --- /dev/null +++ b/src/new/freebsd/mod.rs @@ -0,0 +1,4 @@ +//! FreeBSD libc. +//! +//! * Headers: +//! * Symbol map: diff --git a/src/new/fuchsia/mod.rs b/src/new/fuchsia/mod.rs new file mode 100644 index 0000000000000..c1d275c95b3f6 --- /dev/null +++ b/src/new/fuchsia/mod.rs @@ -0,0 +1,2 @@ +//! Fuschia libc. +// FIXME(fuchsia): link to headers needed. diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs new file mode 100644 index 0000000000000..8714820906414 --- /dev/null +++ b/src/new/glibc/mod.rs @@ -0,0 +1,4 @@ +//! GNU libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) diff --git a/src/new/haiku/mod.rs b/src/new/haiku/mod.rs new file mode 100644 index 0000000000000..c119b67376269 --- /dev/null +++ b/src/new/haiku/mod.rs @@ -0,0 +1,2 @@ +//! Haiku OS libc. +// FIXME(haiku): link to headers needed. diff --git a/src/new/hermit_abi/mod.rs b/src/new/hermit_abi/mod.rs new file mode 100644 index 0000000000000..65f59fe12d691 --- /dev/null +++ b/src/new/hermit_abi/mod.rs @@ -0,0 +1,3 @@ +//! Hermit kernel libc. +//! +//! * Headers: diff --git a/src/new/horizon/mod.rs b/src/new/horizon/mod.rs new file mode 100644 index 0000000000000..338e9f0a4d840 --- /dev/null +++ b/src/new/horizon/mod.rs @@ -0,0 +1,2 @@ +//! Switch libc. +// FIXME(horizon): link to headers or manpages needed. diff --git a/src/new/hurd/mod.rs b/src/new/hurd/mod.rs new file mode 100644 index 0000000000000..12198d58bd582 --- /dev/null +++ b/src/new/hurd/mod.rs @@ -0,0 +1,2 @@ +//! GNU Hurd libc. +// FIXME(hurd): link to headers needed. diff --git a/src/new/illumos/mod.rs b/src/new/illumos/mod.rs new file mode 100644 index 0000000000000..66f6cb1ffd3c8 --- /dev/null +++ b/src/new/illumos/mod.rs @@ -0,0 +1,2 @@ +//! Illumos libc. +// FIXME(illumos): link to headers needed. diff --git a/src/new/l4re/mod.rs b/src/new/l4re/mod.rs new file mode 100644 index 0000000000000..cbf725f406b6b --- /dev/null +++ b/src/new/l4re/mod.rs @@ -0,0 +1,3 @@ +//! L4re. +//! +//! * Headers: diff --git a/src/new/mod.rs b/src/new/mod.rs index 326a5713becc5..27f232cb56882 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -14,11 +14,36 @@ //! //! All modules are only crate-public since we don't reexport this structure. -// Libraries available on each platform +mod common; + +/* The `pub(crate) use ...` statements are commented while the modules are empty */ + +// Platform libraries and combined platform+libc +// +// Not supported or not needed: +// * amdhsa +// * cuda +// * lynxos178 +// * managarm +// * motor +// * none +// * psp +// * psx +// * uefi +// * unknown +// * vexos +// * zkvm +// +// Combined to target_vendor = "apple" +// * ios +// * macos +// * tvos +// * visionos +// * watchos cfg_if! { - if #[cfg(target_os = "linux")] { - mod linux_uapi; - pub(crate) use linux_uapi::*; + if #[cfg(target_os = "aix")] { + mod aix; + // pub(crate) use aix::*; } else if #[cfg(target_os = "android")] { mod bionic_libc; pub(crate) use bionic_libc::*; @@ -27,6 +52,113 @@ cfg_if! { mod apple_xnu; pub(crate) use apple_libc::*; pub(crate) use apple_xnu::*; + } else if #[cfg(target_os = "cygwin")] { + mod cygwin; + // pub(crate) use cygwin::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + // pub(crate) use dragonfly::*; + } else if #[cfg(target_os = "emscripten")] { + mod emscripten; + // pub(crate) use emscripten::*; + } else if #[cfg(target_os = "espidf")] { + mod espidf; + // pub(crate) use espidf::*; + } else if #[cfg(target_os = "freebsd")] { + mod freebsd; + // pub(crate) use freebsd::*; + } else if #[cfg(target_os = "fuchsia")] { + mod fuchsia; + // pub(crate) use fuchsia::*; + } else if #[cfg(target_os = "haiku")] { + mod haiku; + // pub(crate) use haiku::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit_abi; + // pub(crate) use hermit_abi::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + // pub(crate) use horizon::*; + } else if #[cfg(target_os = "hurd")] { + mod hurd; + // pub(crate) use hurd::*; + } else if #[cfg(target_os = "illumos")] { + mod illumos; + // pub(crate) use illumos::*; + } else if #[cfg(target_os = "l4re")] { + mod l4re; + // pub(crate) use l4re::*; + } else if #[cfg(target_os = "linux")] { + mod linux_uapi; + pub(crate) use linux_uapi::*; + } else if #[cfg(target_os = "netbsd")] { + mod netbsd; + // pub(crate) use netbsd::*; + } else if #[cfg(target_os = "nto")] { + mod nto; + // pub(crate) use nto::*; + } else if #[cfg(target_os = "nuttx")] { + mod nuttx; + // pub(crate) use nuttx::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + // pub(crate) use openbsd::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + // pub(crate) use redox::*; + } else if #[cfg(target_os = "rtems")] { + mod rtems; + // pub(crate) use rtems::*; + } else if #[cfg(target_os = "solaris")] { + mod solaris; + // pub(crate) use solaris::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + // pub(crate) use solid::*; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + // pub(crate) use teeos::*; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + // pub(crate) use trusty::*; + } else if #[cfg(target_os = "vita")] { + mod vita; + // pub(crate) use vita::*; + } else if #[cfg(target_os = "vxworks")] { + mod vxworks; + // pub(crate) use vxworks::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + // pub(crate) use wasi::*; + } else if #[cfg(target_os = "windows")] { + mod ucrt; + // pub(crate) use ucrt::*; + } else if #[cfg(target_os = "xous")] { + mod xous; + // pub(crate) use xous::*; + } +} + +// Multi-platform libc +cfg_if! { + if #[cfg(target_env = "gnu")] { + mod glibc; + // pub(crate) use glibc::*; + } else if #[cfg(target_env = "musl")] { + mod musl; + // pub(crate) use musl::*; + } else if #[cfg(target_env = "newlib")] { + mod newlib; + // pub(crate) use newlib::*; + } else if #[cfg(target_env = "relibc")] { + mod relibc; + // pub(crate) use relibc::*; + } else if #[cfg(target_env = "sgx")] { + mod sgx; + // pub(crate) use sgx::*; + } else if #[cfg(target_env = "uclibc")] { + mod uclibc; + // pub(crate) use uclibc::*; } } diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs new file mode 100644 index 0000000000000..49f9abae21fb7 --- /dev/null +++ b/src/new/musl/mod.rs @@ -0,0 +1,4 @@ +//! Musl libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs new file mode 100644 index 0000000000000..14b6a5f869e8f --- /dev/null +++ b/src/new/netbsd/mod.rs @@ -0,0 +1,3 @@ +//! NetBSD libc. +//! +//! * Manual pages: diff --git a/src/new/newlib/mod.rs b/src/new/newlib/mod.rs new file mode 100644 index 0000000000000..d5564cafcfd50 --- /dev/null +++ b/src/new/newlib/mod.rs @@ -0,0 +1,2 @@ +//! Newlib libc. +// FIXME(newlib): link to headers needed. diff --git a/src/new/nto/mod.rs b/src/new/nto/mod.rs new file mode 100644 index 0000000000000..8fa2d814eb8df --- /dev/null +++ b/src/new/nto/mod.rs @@ -0,0 +1,2 @@ +//! QNX Neutrino libc. +// FIXME(nto): link to manpages needed. diff --git a/src/new/nuttx/mod.rs b/src/new/nuttx/mod.rs new file mode 100644 index 0000000000000..89b9c05e849bd --- /dev/null +++ b/src/new/nuttx/mod.rs @@ -0,0 +1,2 @@ +//! RTEMS libc. +// FIXME(nuttx): link to headers needed. diff --git a/src/new/openbsd/mod.rs b/src/new/openbsd/mod.rs new file mode 100644 index 0000000000000..f97044effe76c --- /dev/null +++ b/src/new/openbsd/mod.rs @@ -0,0 +1,4 @@ +//! OpenBSD libc. +//! +//! * Headers: +//! * Manual pages: diff --git a/src/new/redox/mod.rs b/src/new/redox/mod.rs new file mode 100644 index 0000000000000..cf7806a2437ad --- /dev/null +++ b/src/new/redox/mod.rs @@ -0,0 +1,3 @@ +//! Redox libc. +//! +//! * Headers: diff --git a/src/new/relibc/mod.rs b/src/new/relibc/mod.rs new file mode 100644 index 0000000000000..baf26912ec7f0 --- /dev/null +++ b/src/new/relibc/mod.rs @@ -0,0 +1,3 @@ +//! Redox OS libc. +//! +//! * Headers: diff --git a/src/new/rtems/mod.rs b/src/new/rtems/mod.rs new file mode 100644 index 0000000000000..bd3dc3954c71e --- /dev/null +++ b/src/new/rtems/mod.rs @@ -0,0 +1,2 @@ +//! RTEMS libc. +// FIXME(rtems): link to headers needed. diff --git a/src/new/sgx/mod.rs b/src/new/sgx/mod.rs new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/new/sgx/mod.rs @@ -0,0 +1 @@ + diff --git a/src/new/solaris/mod.rs b/src/new/solaris/mod.rs new file mode 100644 index 0000000000000..b5d55492995de --- /dev/null +++ b/src/new/solaris/mod.rs @@ -0,0 +1,3 @@ +//! Solaris libc. +//! +//! * Manual pages: (under "Reference Manuals") diff --git a/src/new/solid/mod.rs b/src/new/solid/mod.rs new file mode 100644 index 0000000000000..4a197cfb62c5a --- /dev/null +++ b/src/new/solid/mod.rs @@ -0,0 +1,2 @@ +//! Kyoto Microcomputer SOLID. +// FIXME(solid): link to headers needed. diff --git a/src/new/teeos/mod.rs b/src/new/teeos/mod.rs new file mode 100644 index 0000000000000..96f44d3d39361 --- /dev/null +++ b/src/new/teeos/mod.rs @@ -0,0 +1,2 @@ +//! Per the target docs, TEEOS uses part of musl as its libc. +// FIXME(teeos): link to headers needed. diff --git a/src/new/trusty/mod.rs b/src/new/trusty/mod.rs new file mode 100644 index 0000000000000..261ecb09e46de --- /dev/null +++ b/src/new/trusty/mod.rs @@ -0,0 +1,2 @@ +//! Trusty libc. +// FIXME(trusty): link to headers needed. diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs new file mode 100644 index 0000000000000..eda4b01d92d2c --- /dev/null +++ b/src/new/uclibc/mod.rs @@ -0,0 +1,4 @@ +//! uClibc. +//! +//! * About: +//! * Headers: (mirror) diff --git a/src/new/ucrt/mod.rs b/src/new/ucrt/mod.rs new file mode 100644 index 0000000000000..f6b5f5d1ef8fc --- /dev/null +++ b/src/new/ucrt/mod.rs @@ -0,0 +1,4 @@ +//! Windows Universal C Runtime. +//! +//! * Manual pages: +//! * UCRT information: diff --git a/src/new/vita/mod.rs b/src/new/vita/mod.rs new file mode 100644 index 0000000000000..21205ebd046fb --- /dev/null +++ b/src/new/vita/mod.rs @@ -0,0 +1,2 @@ +//! VITASDK system library. +// FIXME(vita): link to headers or manpages needed. diff --git a/src/new/vxworks/mod.rs b/src/new/vxworks/mod.rs new file mode 100644 index 0000000000000..a3116fce03803 --- /dev/null +++ b/src/new/vxworks/mod.rs @@ -0,0 +1,2 @@ +//! VxWorks libc. +// FIXME(vxworks): link to headers needed. diff --git a/src/new/wasi/mod.rs b/src/new/wasi/mod.rs new file mode 100644 index 0000000000000..341e6d5d16499 --- /dev/null +++ b/src/new/wasi/mod.rs @@ -0,0 +1,3 @@ +//! WASI libc. +//! +//! * Headers: diff --git a/src/new/xous/mod.rs b/src/new/xous/mod.rs new file mode 100644 index 0000000000000..8a9a28586c448 --- /dev/null +++ b/src/new/xous/mod.rs @@ -0,0 +1,2 @@ +//! Xous libc. +// FIXME(xous): link to headers needed. From fb05ec711df1a2d8756e02338e6fdcab956452f4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 05:13:34 -0400 Subject: [PATCH 53/58] fmt: Use vertical import formatting within `libc` The crate has a lot of reexports and will be getting many more. Change the formatting to vertical to reduce the possibility of conflicts. (backport ) (cherry picked from commit c04afc0831fde82f301ca232eb8030321f9347aa) --- ci/style.sh | 2 +- rustfmt.toml | 1 + src/macros.rs | 45 ++++++++++++++++--- src/rustfmt.toml | 7 +++ src/unix/aix/mod.rs | 5 ++- src/unix/bsd/apple/mod.rs | 5 ++- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 5 ++- src/unix/bsd/freebsdlike/freebsd/mod.rs | 5 ++- src/unix/bsd/netbsdlike/netbsd/mod.rs | 5 ++- src/unix/bsd/netbsdlike/openbsd/mod.rs | 5 ++- src/unix/linux_like/android/mod.rs | 5 ++- src/unix/linux_like/emscripten/lfs64.rs | 5 ++- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 5 ++- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 5 ++- src/unix/linux_like/linux/gnu/b32/m68k/mod.rs | 5 ++- src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 5 ++- src/unix/linux_like/linux/gnu/b32/powerpc.rs | 5 ++- .../linux_like/linux/gnu/b32/riscv32/mod.rs | 5 ++- .../linux_like/linux/gnu/b32/sparc/mod.rs | 5 ++- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 5 ++- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 5 ++- .../linux/gnu/b64/loongarch64/mod.rs | 6 ++- .../linux_like/linux/gnu/b64/mips64/mod.rs | 6 ++- .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 6 ++- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 5 ++- src/unix/linux_like/linux/gnu/b64/s390x.rs | 6 ++- .../linux_like/linux/gnu/b64/sparc64/mod.rs | 6 ++- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 5 ++- src/unix/linux_like/linux/mod.rs | 8 +++- .../linux_like/linux/musl/b32/riscv32/mod.rs | 5 ++- .../linux/musl/b64/loongarch64/mod.rs | 5 ++- .../linux_like/linux/musl/b64/riscv64/mod.rs | 5 ++- src/unix/linux_like/linux/musl/lfs64.rs | 5 ++- src/unix/newlib/aarch64/mod.rs | 6 ++- src/unix/newlib/arm/mod.rs | 6 ++- src/unix/newlib/espidf/mod.rs | 6 ++- src/unix/newlib/powerpc/mod.rs | 6 ++- src/unix/nuttx/mod.rs | 7 ++- src/unix/solarish/compat.rs | 6 ++- src/unix/solarish/illumos.rs | 10 ++++- src/unix/solarish/solaris.rs | 11 ++++- 41 files changed, 220 insertions(+), 46 deletions(-) create mode 100644 src/rustfmt.toml diff --git a/ci/style.sh b/ci/style.sh index c5fddbad1f8b1..ef57a5efd0402 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -40,7 +40,7 @@ while IFS= read -r file; do # Format the file. We need to invoke `rustfmt` directly since `cargo fmt` # can't figure out the module tree with the hacks in place. failed=false - rustfmt --config-path rustfmt.toml "$file" ${check:+"$check"} || failed=true + rustfmt "$file" ${check:+"$check"} || failed=true # Restore all changes to the files. perl -pi -e 's/fn (\w+)_fmt_tmp\(\)/$1!/g' "$file" diff --git a/rustfmt.toml b/rustfmt.toml index de0fc5ecc0166..8016e2bbfeca9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,4 @@ +# Note that there is a separate configuration for `src/` edition = "2021" error_on_line_overflow = true group_imports = "StdExternalCrate" diff --git a/src/macros.rs b/src/macros.rs index 59dcbfa905c82..a5359db0f62c5 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -76,26 +76,59 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use core::default::Default; #[allow(unused_imports)] - pub(crate) use core::marker::{Copy, Send, Sync}; + pub(crate) use core::marker::{ + Copy, + Send, + Sync, + }; #[allow(unused_imports)] pub(crate) use core::option::Option; #[allow(unused_imports)] pub(crate) use core::prelude::v1::derive; #[allow(unused_imports)] - pub(crate) use core::{fmt, hash, iter, mem, ptr}; + pub(crate) use core::{ + fmt, + hash, + iter, + mem, + ptr, + }; #[allow(unused_imports)] pub(crate) use fmt::Debug; #[allow(unused_imports)] - pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; + pub(crate) use mem::{ + align_of, + align_of_val, + size_of, + size_of_val, + }; #[allow(unused_imports)] - pub(crate) use crate::types::{CEnumRepr, Padding}; + pub(crate) use crate::types::{ + CEnumRepr, + Padding, + }; // Commonly used types defined in this crate #[allow(unused_imports)] pub(crate) use crate::{ - c_char, c_double, c_float, c_int, c_long, c_longlong, c_short, c_uchar, c_uint, - c_ulong, c_ulonglong, c_ushort, c_void, intptr_t, size_t, ssize_t, uintptr_t, + c_char, + c_double, + c_float, + c_int, + c_long, + c_longlong, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ulonglong, + c_ushort, + c_void, + intptr_t, + size_t, + ssize_t, + uintptr_t, }; } }; diff --git a/src/rustfmt.toml b/src/rustfmt.toml new file mode 100644 index 0000000000000..19e4b2fa60beb --- /dev/null +++ b/src/rustfmt.toml @@ -0,0 +1,7 @@ +# Note that there is a separate top-level configuration for everything else +edition = "2021" +error_on_line_overflow = true +group_imports = "StdExternalCrate" +imports_granularity = "Module" +# This crate gets large lists of reexports. Use vertical to reduce conflicts. +imports_layout = "Vertical" diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 05ff2fb082900..b699a3c8001c8 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{in_addr_t, in_port_t}; +use crate::{ + in_addr_t, + in_port_t, +}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 356e1ca4465af..ec05791d9aed0 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3,7 +3,10 @@ //! This covers *-apple-* triples currently use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type wchar_t = i32; pub type clock_t = c_ulong; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 4e054f9c89056..632d83b0ea3b7 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type dev_t = u32; pub type wchar_t = i32; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 2b601bd203808..47698830a0398 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type fflags_t = u32; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 9f0831323af79..262c644aace5a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type clock_t = c_uint; pub type suseconds_t = c_int; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index b28f4557f5218..199986b851e91 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1,6 +1,9 @@ use crate::prelude::*; use crate::unix::bsd::O_SYNC; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type clock_t = i64; pub type suseconds_t = c_long; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fa2fd4e63dc55..c829adc656d22 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1,7 +1,10 @@ //! Android-specific definitions for linux-like values use crate::prelude::*; -use crate::{cmsghdr, msghdr}; +use crate::{ + cmsghdr, + msghdr, +}; cfg_if! { if #[cfg(doc)] { diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs index 06be875446bb6..501540943889f 100644 --- a/src/unix/linux_like/emscripten/lfs64.rs +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -109,7 +109,10 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use crate::{open as open64, openat as openat64}; +pub use crate::{ + open as open64, + openat as openat64, +}; #[inline] pub unsafe extern "C" fn posix_fadvise64( 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 900851ab5f42c..0f7181e2aee1a 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; 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 95881894a4b94..bb06c49df0a25 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; 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 d614fddeca9d9..ceaab898074b4 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; 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 3d2775cd800ae..98ce89e124891 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 791f14956806d..54470e10d6145 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; 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 b04ee50462745..f4f04c91b7f87 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = 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 801f31e2c0e34..03ecff3f342e1 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -1,7 +1,10 @@ //! SPARC-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; 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 5f0dfe90adf81..26a95f85972f1 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; pub type greg_t = i32; 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 28b4e40fde543..b5af0e8ec9548 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -1,7 +1,10 @@ //! AArch64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; pub type nlink_t = u32; 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 8f15ce4d1529a..1eeb6098284b8 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -1,5 +1,9 @@ use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; 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 7f66330d9c7ed..da43c3268813a 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -1,5 +1,9 @@ use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type blksize_t = i64; pub type nlink_t = u64; 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 00e47647a44d8..153d25e2f3deb 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -1,7 +1,11 @@ //! PowerPC64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; pub type nlink_t = u64; 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 bfbc8ee5cf683..e5546cdae7fb3 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = 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 029485c5b4a32..5bea1a100b1d7 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -1,7 +1,11 @@ //! s390x use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type blksize_t = i64; pub type nlink_t = u64; 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 f18e53a99b466..0a40d7599bad9 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -1,7 +1,11 @@ //! SPARC64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; pub type nlink_t = u32; 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 cf871f2a7d84a..e100871275776 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 @@ -1,7 +1,10 @@ //! x86_64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; pub type nlink_t = u64; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 34ee66d1b6557..45031ab2aa32c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,7 +1,13 @@ //! Linux-specific definitions for linux-like values use crate::prelude::*; -use crate::{sock_filter, _IO, _IOR, _IOW, _IOWR}; +use crate::{ + sock_filter, + _IO, + _IOR, + _IOW, + _IOWR, +}; pub type useconds_t = u32; pub type dev_t = u64; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index ea4b51f006f0f..d78df7528d26f 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index e014fbf48c0da..6ae9637cb58c6 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -1,7 +1,10 @@ //! LoongArch-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 8389af961cf58..cd93ef706deeb 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; diff --git a/src/unix/linux_like/linux/musl/lfs64.rs b/src/unix/linux_like/linux/musl/lfs64.rs index e6506fd3d385d..4d595fc42d72f 100644 --- a/src/unix/linux_like/linux/musl/lfs64.rs +++ b/src/unix/linux_like/linux/musl/lfs64.rs @@ -117,7 +117,10 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use crate::{open as open64, openat as openat64}; +pub use crate::{ + open as open64, + openat as openat64, +}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index e4640580e2478..56c268fc5f2bb 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -49,4 +49,8 @@ pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index aea4ed764b03c..26f3d52436b84 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -51,4 +51,8 @@ pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 57a033fcaf263..9bec89a7d78d4 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -117,4 +117,8 @@ extern "C" { pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; } -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index c4d4a2ed07c5e..f51a1b2cbe602 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -3,7 +3,11 @@ use crate::prelude::*; pub type clock_t = c_ulong; pub type wchar_t = c_int; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; // the newlib shipped with devkitPPC does not support the following components: // - sockaddr diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 3d3e2c3448841..41d59beeae4cd 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -1,5 +1,10 @@ use crate::prelude::*; -use crate::{in6_addr, in_addr_t, timespec, DIR}; +use crate::{ + in6_addr, + in_addr_t, + timespec, + DIR, +}; pub type nlink_t = u16; pub type ino_t = u16; diff --git a/src/unix/solarish/compat.rs b/src/unix/solarish/compat.rs index 22bcf12edcc82..6876a9d8fd319 100644 --- a/src/unix/solarish/compat.rs +++ b/src/unix/solarish/compat.rs @@ -3,7 +3,11 @@ use core::cmp::min; use crate::unix::solarish::*; -use crate::{c_char, c_int, size_t}; +use crate::{ + c_char, + c_int, + size_t, +}; pub unsafe fn cfmakeraw(termios: *mut crate::termios) { (*termios).c_iflag &= diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index fbeadaf344fa0..42aa5731f9aaa 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -1,7 +1,13 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, - PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, + off_t, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, }; pub type lgrp_rsrc_t = c_int; diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 58b097a16269b..c23ec5109cb9c 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -1,7 +1,14 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, termios, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, - PRIV_DEBUG, PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, + off_t, + termios, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, }; pub type door_attr_t = c_uint; From 01074645d308fe874e513e0f192a23ce21600ce5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 14:37:37 -0400 Subject: [PATCH 54/58] nuttx: Resolve warnings Fix duplicate exports for nuttx. (backport ) (cherry picked from commit 82e3aed6cbe77ff9df4e25c9fbf7c29b56323359) --- src/unix/mod.rs | 3 +++ src/unix/nuttx/mod.rs | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e341c7d115691..7caf78319e4fd 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -40,6 +40,8 @@ cfg_if! { extern_ty! { pub enum DIR {} } + +#[cfg(not(target_os = "nuttx"))] pub type locale_t = *mut c_void; s! { @@ -131,6 +133,7 @@ s! { __reserved: [c_long; 16], } + #[cfg(not(target_os = "nuttx"))] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 41d59beeae4cd..fe7c6ecb3007a 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -236,11 +236,6 @@ s! { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: u32, } - - pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } } // Reserved two pointer size for reserved area for some structures. @@ -528,7 +523,6 @@ 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 SIGIOT: c_int = 6; pub const SIGBUS: c_int = 7; pub const SIGFPE: c_int = 8; pub const SIGKILL: c_int = 9; From 63f5e444bb79ba239f6e408fb17be5debcb69e5b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 14:40:36 -0400 Subject: [PATCH 55/58] teeos: Switch to the `s!` macro Add the missing expected traits. (backport ) (cherry picked from commit d6d774f73e6677695d55a36da58236d7b840b199) --- src/teeos/mod.rs | 134 ++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 71 deletions(-) diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index fd9c0b168aba4..f9f8569360f97 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -61,89 +61,81 @@ pub type wctype_t = c_ulong; pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; -#[repr(align(16))] -pub struct _CLongDouble(pub u128); - -#[repr(align(8))] -#[repr(C)] -pub struct pthread_cond_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_COND_T], +s_paren! { + #[repr(align(16))] + pub struct _CLongDouble(pub u128); } -#[repr(align(8))] -#[repr(C)] -pub struct pthread_mutex_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], -} +s! { + #[repr(align(8))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_COND_T], + } -#[repr(align(4))] -#[repr(C)] -pub struct pthread_mutexattr_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], -} + #[repr(align(8))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } -#[repr(align(4))] -#[repr(C)] -pub struct pthread_condattr_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], -} + #[repr(align(4))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } -#[repr(C)] -pub struct pthread_attr_t { - __size: [u64; 7], -} + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } -#[repr(C)] -pub struct cpu_set_t { - bits: [c_ulong; 128 / size_of::()], -} + pub struct pthread_attr_t { + __size: [u64; 7], + } -#[repr(C)] -pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, -} + pub struct cpu_set_t { + bits: [c_ulong; 128 / size_of::()], + } -#[repr(C)] -pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, -} + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } -#[repr(C)] -pub struct tm { - pub tm_sec: c_int, - pub tm_min: c_int, - pub tm_hour: c_int, - pub tm_mday: c_int, - pub tm_mon: c_int, - pub tm_year: c_int, - pub tm_wday: c_int, - pub tm_yday: c_int, - pub tm_isdst: c_int, - pub __tm_gmtoff: c_long, - pub __tm_zone: *const c_char, -} + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } -#[repr(C)] -pub struct mbstate_t { - pub __opaque1: c_uint, - pub __opaque2: c_uint, -} + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_long, + pub __tm_zone: *const c_char, + } -#[repr(C)] -pub struct sem_t { - pub __val: [c_int; 4 * size_of::() / size_of::()], -} + pub struct mbstate_t { + pub __opaque1: c_uint, + pub __opaque2: c_uint, + } -#[repr(C)] -pub struct div_t { - pub quot: c_int, - pub rem: c_int, + pub struct sem_t { + pub __val: [c_int; 4 * size_of::() / size_of::()], + } + + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } } // fcntl From dfe4fe03343375655be4774e356ed48414b682b8 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 15:21:39 -0400 Subject: [PATCH 56/58] wali: Fix unknown config `target_vendor = "wali"` no longer seems to exist, so use wasm+musl to enable the module instead. Also fix missing types in the wali module. (backport ) (cherry picked from commit 57a0228bf3b50ec6102288230cab8ff387f60bce) --- .../linux_like/linux/musl/b64/wasm32/mod.rs | 2 +- .../linux_like/linux/musl/b64/wasm32/wali.rs | 288 +++++++++--------- 2 files changed, 145 insertions(+), 145 deletions(-) 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 29750e79e17e6..00dc4e5b97f2d 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -681,7 +681,7 @@ pub const TOSTOP: crate::tcflag_t = 0x00000100; pub const FLUSHO: crate::tcflag_t = 0x00001000; cfg_if! { - if #[cfg(target_vendor = "wali")] { + if #[cfg(all(target_family = "wasm", target_env = "musl"))] { mod wali; pub use self::wali::*; } diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs b/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs index bda5c241c1d2d..f347e8a69ddd0 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs @@ -1,400 +1,400 @@ //! WebAssembly Linux Interface syscall specification +use crate::prelude::*; + // --- Autogenerated from WALI/scripts/autogen.py --- #[link(wasm_import_module = "wali")] extern "C" { /* 0 */ #[link_name = "SYS_read"] - pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> c_long; /* 1 */ #[link_name = "SYS_write"] - pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> c_long; /* 2 */ #[link_name = "SYS_open"] - pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> c_long; /* 3 */ #[link_name = "SYS_close"] - pub fn __syscall_SYS_close(a1: i32) -> ::c_long; + pub fn __syscall_SYS_close(a1: i32) -> c_long; /* 4 */ #[link_name = "SYS_stat"] - pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> c_long; /* 5 */ #[link_name = "SYS_fstat"] - pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> c_long; /* 6 */ #[link_name = "SYS_lstat"] - pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> c_long; /* 7 */ #[link_name = "SYS_poll"] - pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> c_long; /* 8 */ #[link_name = "SYS_lseek"] - pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> ::c_long; + pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> c_long; /* 9 */ #[link_name = "SYS_mmap"] - pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> ::c_long; + pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> c_long; /* 10 */ #[link_name = "SYS_mprotect"] - pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> c_long; /* 11 */ #[link_name = "SYS_munmap"] - pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> c_long; /* 12 */ #[link_name = "SYS_brk"] - pub fn __syscall_SYS_brk(a1: i32) -> ::c_long; + pub fn __syscall_SYS_brk(a1: i32) -> c_long; /* 13 */ #[link_name = "SYS_rt_sigaction"] - pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 14 */ #[link_name = "SYS_rt_sigprocmask"] - pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 15 */ #[link_name = "SYS_rt_sigreturn"] - pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> ::c_long; + pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> c_long; /* 16 */ #[link_name = "SYS_ioctl"] - pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> c_long; /* 17 */ #[link_name = "SYS_pread64"] - pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> ::c_long; + pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; /* 18 */ #[link_name = "SYS_pwrite64"] - pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> ::c_long; + pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; /* 19 */ #[link_name = "SYS_readv"] - pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> c_long; /* 20 */ #[link_name = "SYS_writev"] - pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> c_long; /* 21 */ #[link_name = "SYS_access"] - pub fn __syscall_SYS_access(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_access(a1: i32, a2: i32) -> c_long; /* 22 */ #[link_name = "SYS_pipe"] - pub fn __syscall_SYS_pipe(a1: i32) -> ::c_long; + pub fn __syscall_SYS_pipe(a1: i32) -> c_long; /* 23 */ #[link_name = "SYS_select"] - pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 24 */ #[link_name = "SYS_sched_yield"] - pub fn __syscall_SYS_sched_yield() -> ::c_long; + pub fn __syscall_SYS_sched_yield() -> c_long; /* 25 */ #[link_name = "SYS_mremap"] - pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> c_long; /* 26 */ #[link_name = "SYS_msync"] - pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> c_long; /* 28 */ #[link_name = "SYS_madvise"] - pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> c_long; /* 32 */ #[link_name = "SYS_dup"] - pub fn __syscall_SYS_dup(a1: i32) -> ::c_long; + pub fn __syscall_SYS_dup(a1: i32) -> c_long; /* 33 */ #[link_name = "SYS_dup2"] - pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> c_long; /* 35 */ #[link_name = "SYS_nanosleep"] - pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> c_long; /* 37 */ #[link_name = "SYS_alarm"] - pub fn __syscall_SYS_alarm(a1: i32) -> ::c_long; + pub fn __syscall_SYS_alarm(a1: i32) -> c_long; /* 38 */ #[link_name = "SYS_setitimer"] - pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> c_long; /* 39 */ #[link_name = "SYS_getpid"] - pub fn __syscall_SYS_getpid() -> ::c_long; + pub fn __syscall_SYS_getpid() -> c_long; /* 41 */ #[link_name = "SYS_socket"] - pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> c_long; /* 42 */ #[link_name = "SYS_connect"] - pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> c_long; /* 43 */ #[link_name = "SYS_accept"] - pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> c_long; /* 44 */ #[link_name = "SYS_sendto"] - pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> ::c_long; + pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> c_long; /* 45 */ #[link_name = "SYS_recvfrom"] - pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) - -> ::c_long; + pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) -> c_long; /* 46 */ #[link_name = "SYS_sendmsg"] - pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> c_long; /* 47 */ #[link_name = "SYS_recvmsg"] - pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> c_long; /* 48 */ #[link_name = "SYS_shutdown"] - pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> c_long; /* 49 */ #[link_name = "SYS_bind"] - pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> c_long; /* 50 */ #[link_name = "SYS_listen"] - pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> c_long; /* 51 */ #[link_name = "SYS_getsockname"] - pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> c_long; /* 52 */ #[link_name = "SYS_getpeername"] - pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> c_long; /* 53 */ #[link_name = "SYS_socketpair"] - pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 54 */ #[link_name = "SYS_setsockopt"] - pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> ::c_long; + pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> c_long; /* 55 */ #[link_name = "SYS_getsockopt"] - pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 57 */ #[link_name = "SYS_fork"] - pub fn __syscall_SYS_fork() -> ::c_long; + pub fn __syscall_SYS_fork() -> c_long; /* 59 */ #[link_name = "SYS_execve"] - pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> c_long; /* 60 */ #[link_name = "SYS_exit"] - pub fn __syscall_SYS_exit(a1: i32) -> ::c_long; + pub fn __syscall_SYS_exit(a1: i32) -> c_long; /* 61 */ #[link_name = "SYS_wait4"] - pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 62 */ #[link_name = "SYS_kill"] - pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> c_long; /* 63 */ #[link_name = "SYS_uname"] - pub fn __syscall_SYS_uname(a1: i32) -> ::c_long; + pub fn __syscall_SYS_uname(a1: i32) -> c_long; /* 72 */ #[link_name = "SYS_fcntl"] - pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> c_long; /* 73 */ #[link_name = "SYS_flock"] - pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> c_long; /* 74 */ #[link_name = "SYS_fsync"] - pub fn __syscall_SYS_fsync(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fsync(a1: i32) -> c_long; /* 75 */ #[link_name = "SYS_fdatasync"] - pub fn __syscall_SYS_fdatasync(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fdatasync(a1: i32) -> c_long; /* 77 */ #[link_name = "SYS_ftruncate"] - pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> ::c_long; + pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> c_long; /* 78 */ #[link_name = "SYS_getdents"] - pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> c_long; /* 79 */ #[link_name = "SYS_getcwd"] - pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> c_long; /* 80 */ #[link_name = "SYS_chdir"] - pub fn __syscall_SYS_chdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_chdir(a1: i32) -> c_long; /* 81 */ #[link_name = "SYS_fchdir"] - pub fn __syscall_SYS_fchdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fchdir(a1: i32) -> c_long; /* 82 */ #[link_name = "SYS_rename"] - pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> c_long; /* 83 */ #[link_name = "SYS_mkdir"] - pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> c_long; /* 84 */ #[link_name = "SYS_rmdir"] - pub fn __syscall_SYS_rmdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_rmdir(a1: i32) -> c_long; /* 86 */ #[link_name = "SYS_link"] - pub fn __syscall_SYS_link(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_link(a1: i32, a2: i32) -> c_long; /* 87 */ #[link_name = "SYS_unlink"] - pub fn __syscall_SYS_unlink(a1: i32) -> ::c_long; + pub fn __syscall_SYS_unlink(a1: i32) -> c_long; /* 88 */ #[link_name = "SYS_symlink"] - pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> c_long; /* 89 */ #[link_name = "SYS_readlink"] - pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> c_long; /* 90 */ #[link_name = "SYS_chmod"] - pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> c_long; /* 91 */ #[link_name = "SYS_fchmod"] - pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> c_long; /* 92 */ #[link_name = "SYS_chown"] - pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> c_long; /* 93 */ #[link_name = "SYS_fchown"] - pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> c_long; /* 95 */ #[link_name = "SYS_umask"] - pub fn __syscall_SYS_umask(a1: i32) -> ::c_long; + pub fn __syscall_SYS_umask(a1: i32) -> c_long; /* 97 */ #[link_name = "SYS_getrlimit"] - pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> c_long; /* 98 */ #[link_name = "SYS_getrusage"] - pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> c_long; /* 99 */ #[link_name = "SYS_sysinfo"] - pub fn __syscall_SYS_sysinfo(a1: i32) -> ::c_long; + pub fn __syscall_SYS_sysinfo(a1: i32) -> c_long; /* 102 */ #[link_name = "SYS_getuid"] - pub fn __syscall_SYS_getuid() -> ::c_long; + pub fn __syscall_SYS_getuid() -> c_long; /* 104 */ #[link_name = "SYS_getgid"] - pub fn __syscall_SYS_getgid() -> ::c_long; + pub fn __syscall_SYS_getgid() -> c_long; /* 105 */ #[link_name = "SYS_setuid"] - pub fn __syscall_SYS_setuid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_setuid(a1: i32) -> c_long; /* 106 */ #[link_name = "SYS_setgid"] - pub fn __syscall_SYS_setgid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_setgid(a1: i32) -> c_long; /* 107 */ #[link_name = "SYS_geteuid"] - pub fn __syscall_SYS_geteuid() -> ::c_long; + pub fn __syscall_SYS_geteuid() -> c_long; /* 108 */ #[link_name = "SYS_getegid"] - pub fn __syscall_SYS_getegid() -> ::c_long; + pub fn __syscall_SYS_getegid() -> c_long; /* 109 */ #[link_name = "SYS_setpgid"] - pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> c_long; /* 110 */ #[link_name = "SYS_getppid"] - pub fn __syscall_SYS_getppid() -> ::c_long; + pub fn __syscall_SYS_getppid() -> c_long; /* 112 */ #[link_name = "SYS_setsid"] - pub fn __syscall_SYS_setsid() -> ::c_long; + pub fn __syscall_SYS_setsid() -> c_long; /* 113 */ #[link_name = "SYS_setreuid"] - pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> c_long; /* 114 */ #[link_name = "SYS_setregid"] - pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> c_long; /* 115 */ #[link_name = "SYS_getgroups"] - pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> c_long; /* 116 */ #[link_name = "SYS_setgroups"] - pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> c_long; /* 117 */ #[link_name = "SYS_setresuid"] - pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> c_long; /* 119 */ #[link_name = "SYS_setresgid"] - pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> c_long; /* 121 */ #[link_name = "SYS_getpgid"] - pub fn __syscall_SYS_getpgid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_getpgid(a1: i32) -> c_long; /* 124 */ #[link_name = "SYS_getsid"] - pub fn __syscall_SYS_getsid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_getsid(a1: i32) -> c_long; /* 127 */ #[link_name = "SYS_rt_sigpending"] - pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> c_long; /* 130 */ #[link_name = "SYS_rt_sigsuspend"] - pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> c_long; /* 131 */ #[link_name = "SYS_sigaltstack"] - pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> c_long; /* 132 */ #[link_name = "SYS_utime"] - pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> c_long; /* 137 */ #[link_name = "SYS_statfs"] - pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> c_long; /* 138 */ #[link_name = "SYS_fstatfs"] - pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> c_long; /* 157 */ #[link_name = "SYS_prctl"] - pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> ::c_long; + pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> c_long; /* 160 */ #[link_name = "SYS_setrlimit"] - pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> c_long; /* 161 */ #[link_name = "SYS_chroot"] - pub fn __syscall_SYS_chroot(a1: i32) -> ::c_long; + pub fn __syscall_SYS_chroot(a1: i32) -> c_long; /* 186 */ #[link_name = "SYS_gettid"] - pub fn __syscall_SYS_gettid() -> ::c_long; + pub fn __syscall_SYS_gettid() -> c_long; /* 200 */ #[link_name = "SYS_tkill"] - pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> c_long; /* 202 */ #[link_name = "SYS_futex"] - pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> ::c_long; + pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; /* 204 */ #[link_name = "SYS_sched_getaffinity"] - pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> c_long; /* 217 */ #[link_name = "SYS_getdents64"] - pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> c_long; /* 218 */ #[link_name = "SYS_set_tid_address"] - pub fn __syscall_SYS_set_tid_address(a1: i32) -> ::c_long; + pub fn __syscall_SYS_set_tid_address(a1: i32) -> c_long; /* 221 */ #[link_name = "SYS_fadvise"] - pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> c_long; /* 228 */ #[link_name = "SYS_clock_gettime"] - pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> c_long; /* 229 */ #[link_name = "SYS_clock_getres"] - pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> c_long; /* 230 */ #[link_name = "SYS_clock_nanosleep"] - pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 231 */ #[link_name = "SYS_exit_group"] - pub fn __syscall_SYS_exit_group(a1: i32) -> ::c_long; + pub fn __syscall_SYS_exit_group(a1: i32) -> c_long; /* 233 */ #[link_name = "SYS_epoll_ctl"] - pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 257 */ #[link_name = "SYS_openat"] - pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 258 */ #[link_name = "SYS_mkdirat"] - pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> c_long; /* 260 */ #[link_name = "SYS_fchownat"] - pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 262 */ #[link_name = "SYS_fstatat"] - pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 263 */ #[link_name = "SYS_unlinkat"] - pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> c_long; /* 265 */ #[link_name = "SYS_linkat"] - pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 266 */ #[link_name = "SYS_symlinkat"] - pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> c_long; /* 267 */ #[link_name = "SYS_readlinkat"] - pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 268 */ #[link_name = "SYS_fchmodat"] - pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 269 */ #[link_name = "SYS_faccessat"] - pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 270 */ #[link_name = "SYS_pselect6"] - pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) - -> ::c_long; + pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; /* 271 */ #[link_name = "SYS_ppoll"] - pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> ::c_long; + pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> c_long; /* 280 */ #[link_name = "SYS_utimensat"] - pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 281 */ #[link_name = "SYS_epoll_pwait"] pub fn __syscall_SYS_epoll_pwait( @@ -404,38 +404,38 @@ extern "C" { a4: i32, a5: i32, a6: u32, - ) -> ::c_long; + ) -> c_long; /* 284 */ #[link_name = "SYS_eventfd"] - pub fn __syscall_SYS_eventfd(a1: i32) -> ::c_long; + pub fn __syscall_SYS_eventfd(a1: i32) -> c_long; /* 288 */ #[link_name = "SYS_accept4"] - pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 290 */ #[link_name = "SYS_eventfd2"] - pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> c_long; /* 291 */ #[link_name = "SYS_epoll_create1"] - pub fn __syscall_SYS_epoll_create1(a1: i32) -> ::c_long; + pub fn __syscall_SYS_epoll_create1(a1: i32) -> c_long; /* 292 */ #[link_name = "SYS_dup3"] - pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> c_long; /* 293 */ #[link_name = "SYS_pipe2"] - pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> c_long; /* 302 */ #[link_name = "SYS_prlimit64"] - pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 316 */ #[link_name = "SYS_renameat2"] - pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 318 */ #[link_name = "SYS_getrandom"] - pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> c_long; /* 332 */ #[link_name = "SYS_statx"] - pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 439 */ #[link_name = "SYS_faccessat2"] - pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; } From 73d83da313fb4357701cf93521c99dc745473a3f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 25 Oct 2025 15:23:40 -0400 Subject: [PATCH 57/58] espidf: Fix the duplicate definition of gethostname (backport ) (cherry picked from commit f6388933578ef33b7b830eacae8d293b816b14c0) --- src/unix/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 7caf78319e4fd..0de47f4e92b8e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1466,6 +1466,7 @@ extern "C" { link_name = "mknod@FBSD_1.0" )] pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; + #[cfg(not(target_os = "espidf"))] pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn endservent(); pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; From f8339e81ad0e82d1b949c17de626236a32e1f0a2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 3 Nov 2025 19:54:37 -0600 Subject: [PATCH 58/58] ci: Ignore `repr_align_removed` for cargo-semver-checks This flagged a changed struct in the latest version. Alignment isn't something users should be relying upon, so ignore it globally. --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a4df1a263ca75..141a77f791ea8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,3 +178,7 @@ expl_impl_clone_on_copy = "allow" uninlined_format_args = "allow" unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets used_underscore_binding = "allow" + +[package.metadata.cargo-semver-checks.lints] +# Alignment is an internal detail that users must not rely upon +repr_align_removed = "warn"