From 0a1791ba77c12c9b9cd8a796782e0f78507e2c18 Mon Sep 17 00:00:00 2001 From: Tom Pusateri Date: Fri, 5 Dec 2025 18:39:32 -0500 Subject: [PATCH 01/24] Add interface LINK_STATE_* definitions from sys/net/if.h (backport ) (cherry picked from commit d06928fa2091e21698049e370433419170a211ba) --- src/new/netbsd/net/if_.rs | 4 ++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/new/netbsd/net/if_.rs b/src/new/netbsd/net/if_.rs index 7cceadfc2b3d6..99e4f97a3748b 100644 --- a/src/new/netbsd/net/if_.rs +++ b/src/new/netbsd/net/if_.rs @@ -29,6 +29,10 @@ s! { } } +pub const LINK_STATE_UNKNOWN: c_int = 0; // link invalid/unknown +pub const LINK_STATE_DOWN: c_int = 1; // link is down +pub const LINK_STATE_UP: c_int = 2; // link is up + pub const IFF_UP: c_int = 0x0001; // interface is up pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 8b12116ab25ae..92a59b53a6a60 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1461,6 +1461,15 @@ const SI_PAD: size_t = (SI_MAXSZ / size_of::()) - 3; pub const MAP_STACK: c_int = 0x4000; pub const MAP_CONCEAL: c_int = 0x8000; +// https://github.com/openbsd/src/blob/f8a2f73b6503213f5eb24ca315ac7e1f9421c0c9/sys/net/if.h#L135 +pub const LINK_STATE_UNKNOWN: c_int = 0; // link unknown +pub const LINK_STATE_INVALID: c_int = 1; // link invalid +pub const LINK_STATE_DOWN: c_int = 2; // link is down +pub const LINK_STATE_KALIVE_DOWN: c_int = 3; // keepalive reports down +pub const LINK_STATE_UP: c_int = 4; // link is up +pub const LINK_STATE_HALF_DUPLEX: c_int = 5; // link is up and half duplex +pub const LINK_STATE_FULL_DUPLEX: c_int = 6; // link is up and full duplex + // https://github.com/openbsd/src/blob/HEAD/sys/net/if.h#L187 pub const IFF_UP: c_int = 0x1; // interface is up pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid From e87910aa0d253e0e07da360c335b75c21d65b076 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Dec 2025 13:23:39 -0800 Subject: [PATCH 02/24] Remove nonexistent clocks on WASI These were added way back when in #2499 and while they may have existed in a historical version of wasi-libc they most certainly do not exist in the current wasi-libc. Any usage of them is already-breaking, so this deletes these items. (backport ) (cherry picked from commit e883afcede949948e513be5ffac0a75375002a1b) --- src/wasi/mod.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 9f2539b9400a0..9dbe60a02f35c 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -407,13 +407,7 @@ pub const _SC_SYMLOOP_MAX: c_int = 173; #[allow(unused_unsafe)] pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; #[allow(unused_unsafe)] -pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; -#[allow(unused_unsafe)] pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; -#[allow(unused_unsafe)] -pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = - unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; pub const ABDAY_1: crate::nl_item = 0x20000; pub const ABDAY_2: crate::nl_item = 0x20001; @@ -586,9 +580,7 @@ extern "C" { pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char; static _CLOCK_MONOTONIC: u8; - static _CLOCK_PROCESS_CPUTIME_ID: u8; static _CLOCK_REALTIME: u8; - static _CLOCK_THREAD_CPUTIME_ID: u8; pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int; pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; From 9ddb99073e44c95a63ba7403f405c06f7d8984a2 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 11 Dec 2025 10:11:45 -0700 Subject: [PATCH 03/24] Revert the workaround for Rust bug 132185 It's been fixed since probably sometime in February. https://github.com/rust-lang/rust/issues/132185 (backport ) (cherry picked from commit a3efefee3e3a6ed1e000fa0dd1fb4077e5c867ef) --- .cirrus.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 0abb17a8ce5d1..ff11c9cccb528 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -3,9 +3,6 @@ task: env: HOME: /tmp # cargo cache needs it TARGET: x86_64-unknown-freebsd - # FIXME(freebsd): FreeBSD has a segfault when `RUST_BACKTRACE` is set - # https://github.com/rust-lang/rust/issues/132185 - RUST_BACKTRACE: "0" matrix: # FIXME(#4740): FreeBSD 13 tests are extremely flaky and fail most of the time # - name: nightly freebsd-13 x86_64 From 2a30c24308013835fa796dd3a40025a77b1e6806 Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Tue, 16 Dec 2025 08:53:02 +0000 Subject: [PATCH 04/24] libc-test: semver: Move Linux s390x ucontext symbols to GNU symbol list Musl does not provide these. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit 3d372c69e2dfff2ad70c4cdd1bd2b0ff55d5193b) --- libc-test/semver/linux-gnu-s390x.txt | 6 ++++++ libc-test/semver/linux-s390x.txt | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libc-test/semver/linux-gnu-s390x.txt b/libc-test/semver/linux-gnu-s390x.txt index ec90f4184b638..d52ba2a2a1422 100644 --- a/libc-test/semver/linux-gnu-s390x.txt +++ b/libc-test/semver/linux-gnu-s390x.txt @@ -1,4 +1,10 @@ PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +getcontext +makecontext +mcontext_t +setcontext +swapcontext sysctl +ucontext_t diff --git a/libc-test/semver/linux-s390x.txt b/libc-test/semver/linux-s390x.txt index ac59c8eaee4d2..f2a16a6d8fe62 100644 --- a/libc-test/semver/linux-s390x.txt +++ b/libc-test/semver/linux-s390x.txt @@ -103,11 +103,5 @@ __psw_t flock64 fpreg_t fpregset_t -getcontext greg_t -makecontext -mcontext_t -setcontext -swapcontext termios2 -ucontext_t From 66b08e81874fb3c55df3bda1bea6175ea892161b Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Tue, 16 Dec 2025 08:57:28 +0000 Subject: [PATCH 05/24] musl: s390x: Fix definition of SIGSTKSZ/MINSIGSTKSZ These have had the values 10240 and 4096 respectively since the introduction of the s390x port in musl back in 2016. Signed-off-by: Jens Reidel (backport ) (cherry picked from commit cde9e8af47b2498f3f9d880469802ff6a370cdb3) --- src/unix/linux_like/linux/musl/b64/s390x.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index d8ce68e662089..744d148921f12 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -161,8 +161,8 @@ pub const SA_NOCLDWAIT: c_int = 2; pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 4; pub const SIGBUS: c_int = 7; -pub const SIGSTKSZ: size_t = 0x2000; -pub const MINSIGSTKSZ: size_t = 2048; +pub const SIGSTKSZ: size_t = 10240; +pub const MINSIGSTKSZ: size_t = 4096; pub const SIG_SETMASK: c_int = 2; pub const O_NOCTTY: c_int = 256; From bf448822ad0c868f8b45b39b384b8575c067d8b5 Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:08:31 +0200 Subject: [PATCH 06/24] Add AT_EXECVE_CHECK (backport ) (cherry picked from commit ec1e1e5da4578c88ef57e35ab234eb1c55cfe83c) --- libc-test/build.rs | 3 +++ libc-test/semver/linux.txt | 1 + src/unix/linux_like/linux/mod.rs | 3 +++ 3 files changed, 7 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 69ddcd3ba27a3..4ad94c35f6a72 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4638,6 +4638,9 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.9 kernel headers. "AT_HWCAP3" | "AT_HWCAP4" => true, + // Linux 6.14 + "AT_EXECVE_CHECK" => true, + _ => false, } }); diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index e9f4e9eccd62f..1670cf76c057c 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -163,6 +163,7 @@ AT_ENTRY AT_EUID AT_EXECFD AT_EXECFN +AT_EXECVE_CHECK AT_FDCWD AT_FLAGS AT_GID diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e59648ab5808a..f133c8e80cc9a 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1457,6 +1457,9 @@ pub const IFF_LOWER_UP: c_int = 0x10000; pub const IFF_DORMANT: c_int = 0x20000; pub const IFF_ECHO: c_int = 0x40000; +// linux/fcntl.h +pub const AT_EXECVE_CHECK: c_int = 0x10000; + // linux/if_addr.h pub const IFA_UNSPEC: c_ushort = 0; pub const IFA_ADDRESS: c_ushort = 1; From 24b23380c0186cf9540ae47fdb5a5643fc8ac48b Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Wed, 3 Dec 2025 19:31:26 -0500 Subject: [PATCH 07/24] aix: Fix swapped struct/union test skips and missing `c_enum` Closes: https://github.com/rust-lang/libc/issues/4870 [ replace the commit summary - Trevor ] (backport ) (cherry picked from commit 0bd3900d54027ee439f6e7417c781671dda0ad07) --- libc-test/build.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4ad94c35f6a72..f0796a65f2ed1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5661,14 +5661,24 @@ fn test_aix(target: &str) { // FIXME(union): actually a union. "sigval" => true, - // '__poll_ctl_ext_u' and '__pollfd_ext_u' are for unnamed unions. - "__poll_ctl_ext_u" => true, - "__pollfd_ext_u" => true, - // 'struct fpreg_t' is not defined in AIX headers. It is created to // allow type 'double' to be used in signal contexts. "fpreg_t" => true, + // These structures are guarded by the `_KERNEL` macro in the AIX + // header. + "fileops_t" | "file" => true, + + _ => false, + } + }); + + cfg.skip_union(|union_| { + match union_.ident() { + // '__poll_ctl_ext_u' and '__pollfd_ext_u' are for unnamed unions. + "__poll_ctl_ext_u" => true, + "__pollfd_ext_u" => true, + // This type is defined for a union used within `struct ld_info`. // The AIX header does not declare a separate standalone union // type for it. @@ -5677,10 +5687,6 @@ fn test_aix(target: &str) { // This is a simplified version of the AIX union `_simple_lock`. "_kernel_simple_lock" => true, - // These structures are guarded by the `_KERNEL` macro in the AIX - // header. - "fileops_t" | "file" => true, - _ => false, } }); @@ -5807,6 +5813,9 @@ fn test_aix(target: &str) { _ => false, }); + let c_enums = ["uio_rw"]; + cfg.alias_is_c_enum(move |e| c_enums.contains(&e)); + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } From c29def328c71e3edf4335e847d87e9be260b9792 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 30 Oct 2025 09:50:49 +0000 Subject: [PATCH 08/24] musl: riscv: fix public padding fields in `stat/stat64` (backport ) (cherry picked from commit de1bd4e5aae856b74a1653a8ef5a55cae55fd102) --- src/unix/linux_like/linux/musl/b64/riscv64/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 b987f8358b365..2ba3f66e453ca 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -22,10 +22,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - pub __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, @@ -44,10 +44,10 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, + __pad1: Padding, pub st_size: off64_t, pub st_blksize: crate::blksize_t, - pub __pad2: c_int, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, pub st_atime: crate::time_t, pub st_atime_nsec: c_long, From 46758b81dc75cb85777311b6cadcb6227175d646 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 30 Oct 2025 09:27:09 +0000 Subject: [PATCH 09/24] musl: Merge stat64 and stat with `stat` The structures are the same - and this follows the upstream definition On musl at least, blkcnt64_t == blkcnt_t == i64 and ino_t == ino64_t == u64 (backport ) (cherry picked from commit 9ca4ae9afacf0a66849b0a723f55c1e739d99961) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 24 ++------------- .../linux_like/linux/musl/b32/mips/mod.rs | 25 ++-------------- src/unix/linux_like/linux/musl/b32/powerpc.rs | 23 ++------------- .../linux_like/linux/musl/b32/riscv32/mod.rs | 29 ++----------------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 24 ++------------- .../linux_like/linux/musl/b64/aarch64/mod.rs | 24 ++------------- .../linux/musl/b64/loongarch64/mod.rs | 29 ++----------------- src/unix/linux_like/linux/musl/b64/mips64.rs | 26 ++--------------- .../linux_like/linux/musl/b64/powerpc64.rs | 23 ++------------- .../linux_like/linux/musl/b64/riscv64/mod.rs | 29 ++----------------- src/unix/linux_like/linux/musl/b64/s390x.rs | 21 +------------- .../linux_like/linux/musl/b64/wasm32/mod.rs | 23 ++------------- .../linux_like/linux/musl/b64/x86_64/mod.rs | 23 ++------------- 13 files changed, 28 insertions(+), 295 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index dea804a527026..0f2daa5fc018c 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = u32; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -26,28 +28,6 @@ s! { pub st_ino: crate::ino_t, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __st_dev_padding: Padding, - __st_ino_truncated: c_long, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_rdev_padding: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_ino: crate::ino_t, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, 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 d563c5e420a12..b4a7f1a575dda 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = c_int; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -27,29 +29,6 @@ s! { __st_padding4: Padding<[c_long; 14]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __st_padding1: Padding<[c_long; 2]>, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_padding2: Padding<[c_long; 2]>, - pub st_size: off_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - __st_padding3: Padding, - pub st_blocks: crate::blkcnt64_t, - __st_padding4: Padding<[c_long; 14]>, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 4bf82c7b0cac4..6e5bcde7ce112 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = i32; +pub type stat64 = stat; + s! { pub struct termios { pub c_iflag: crate::tcflag_t, @@ -36,27 +38,6 @@ s! { __unused: Padding<[c_long; 2]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_rdev_padding: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_long; 2]>, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, 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 4237c579a1a7f..45fa0a2081ff1 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -1,13 +1,12 @@ //! RISC-V-specific definitions for 32-bit linux-like values +use crate::off_t; use crate::prelude::*; -use crate::{ - off64_t, - off_t, -}; pub type wchar_t = c_int; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -31,28 +30,6 @@ s! { __unused: Padding<[c_int; 2usize]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, - pub st_size: off64_t, - pub st_blksize: crate::blksize_t, - pub __pad2: c_int, - pub st_blocks: crate::blkcnt64_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2]>, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_flags: c_int, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index ada436fc99b56..0db24b65932ff 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -3,6 +3,8 @@ use crate::prelude::*; pub type wchar_t = i32; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -26,28 +28,6 @@ s! { pub st_ino: crate::ino_t, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __st_dev_padding: Padding, - __st_ino_truncated: c_long, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __st_rdev_padding: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_ino: crate::ino_t, - } - pub struct mcontext_t { __private: [u32; 22], } diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index cc52a179e7203..e28310be3ee32 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -7,6 +7,8 @@ pub type wchar_t = u32; pub type nlink_t = u32; pub type blksize_t = c_int; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -30,28 +32,6 @@ s! { __unused: Padding<[c_uint; 2]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __pad0: Padding, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - __pad1: Padding, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_uint; 2]>, - } - pub struct user_regs_struct { pub regs: [c_ulonglong; 31], pub sp: c_ulonglong, 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 f41f61de62bcf..8e890be51848f 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -1,10 +1,7 @@ //! LoongArch-specific definitions for 64-bit linux-like values +use crate::off_t; use crate::prelude::*; -use crate::{ - off64_t, - off_t, -}; pub type wchar_t = c_int; @@ -13,6 +10,8 @@ pub type blksize_t = c_int; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -36,28 +35,6 @@ s! { __unused: Padding<[c_int; 2usize]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub __pad1: crate::dev_t, - pub st_size: off64_t, - pub st_blksize: crate::blksize_t, - pub __pad2: c_int, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2]>, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 9626e3db78b8e..1fb8618c30c0b 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -7,6 +7,8 @@ pub type __s64 = c_long; pub type nlink_t = c_uint; pub type blksize_t = i64; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -32,30 +34,6 @@ s! { __pad5: Padding<[c_int; 14]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - __pad1: Padding<[c_int; 3]>, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __pad2: Padding<[c_uint; 2]>, - pub st_size: off_t, - __pad3: Padding, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - __pad4: Padding, - pub st_blocks: crate::blkcnt_t, - __pad5: Padding<[c_int; 14]>, - } - pub struct stack_t { pub ss_sp: *mut c_void, pub ss_size: size_t, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index dbf20c565e438..4885ea2f0e182 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -7,6 +7,8 @@ pub type __s64 = c_long; pub type nlink_t = u64; pub type blksize_t = c_long; +pub type stat64 = stat; + s! { pub struct termios { pub c_iflag: crate::tcflag_t, @@ -40,27 +42,6 @@ s! { __unused: Padding<[c_long; 3]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - __pad0: Padding, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __reserved: Padding<[c_long; 3]>, - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_atime: crate::time_t, 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 2ba3f66e453ca..bd395e49cefc1 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -1,10 +1,7 @@ //! RISC-V-specific definitions for 64-bit linux-like values +use crate::off_t; use crate::prelude::*; -use crate::{ - off64_t, - off_t, -}; pub type wchar_t = c_int; @@ -13,6 +10,8 @@ pub type blksize_t = c_int; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -36,28 +35,6 @@ s! { __unused: Padding<[c_int; 2usize]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - __pad1: Padding, - pub st_size: off64_t, - pub st_blksize: crate::blksize_t, - __pad2: Padding, - pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_int; 2]>, - } - pub struct ipc_perm { pub __key: crate::key_t, pub uid: crate::uid_t, diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 744d148921f12..0ee6c11c6a1e6 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -8,6 +8,7 @@ pub type greg_t = u64; pub type __u64 = u64; pub type __s64 = i64; pub type statfs64 = statfs; +pub type stat64 = stat; s! { pub struct ipc_perm { @@ -50,26 +51,6 @@ s! { __unused: Padding<[c_long; 3]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, - __unused: Padding<[c_long; 3]>, - } - pub struct statfs { pub f_type: c_uint, pub f_bsize: c_uint, 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 d4d0fe69839b3..1a4d89632dcc9 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -9,6 +9,8 @@ pub type blksize_t = c_long; pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -31,27 +33,6 @@ s! { __unused: Padding<[c_long; 3]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - __pad0: Padding, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __reserved: Padding<[c_long; 3]>, - } - pub struct ipc_perm { #[cfg(musl_v1_2_3)] pub __key: crate::key_t, diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index f7f449cbc8936..dcc41752c6e86 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -8,6 +8,8 @@ pub type __u64 = c_ulonglong; pub type __s64 = c_longlong; pub type greg_t = i64; +pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -30,27 +32,6 @@ s! { __unused: Padding<[c_long; 3]>, } - pub struct stat64 { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino64_t, - pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - __pad0: Padding, - pub st_rdev: crate::dev_t, - pub st_size: off_t, - pub st_blksize: crate::blksize_t, - pub st_blocks: crate::blkcnt64_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __reserved: Padding<[c_long; 3]>, - } - pub struct user_regs_struct { pub r15: c_ulong, pub r14: c_ulong, From 89688c5fe4cb2f679e4151d44268ebd643637de2 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Tue, 13 May 2025 04:32:23 +0000 Subject: [PATCH 10/24] musl: add musl_time64 feature This feature is enabled with independently from musl_v1_2_3 to support time64. Defining this feature makes this roughly equivalent to upstream commit bminor/musl@f12bd8e. (backport ) (cherry picked from commit 47960b4b00cd114074faa1fff098c9dde6c32908) --- build.rs | 30 ++++++++++++++++++++++++++---- libc-test/build.rs | 9 ++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/build.rs b/build.rs index 3277ae73df951..0b63b985f9a29 100644 --- a/build.rs +++ b/build.rs @@ -28,6 +28,8 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", + // Corresponds to `_REDIR_TIME64` in musl + "musl32_time64", "vxworks_lt_25_09", ]; @@ -49,6 +51,9 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ), ]; +/// Musl architectures that set `#define _REDIR_TIME64 1`. +const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "mips", "powerpc", "x86"]; + fn main() { // Avoid unnecessary re-building. println!("cargo:rerun-if-changed=build.rs"); @@ -99,12 +104,29 @@ fn main() { _ => (), } - let musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + let mut musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); - // loongarch64 and ohos have already updated - if musl_v1_2_3 || target_arch == "loongarch64" || target_env == "ohos" { - // FIXME(musl): enable time64 api as well + + // OpenHarmony uses a fork of the musl libc + let musl = target_env == "musl" || target_env == "ohos"; + + // loongarch64 and ohos only exist with recent musl + if target_arch == "loongarch64" || target_env == "ohos" { + musl_v1_2_3 = true; + } + + if musl && musl_v1_2_3 { set_cfg("musl_v1_2_3"); + if MUSL_REDIR_TIME64_ARCHES.contains(&target_arch.as_str()) { + set_cfg("musl32_time64"); + set_cfg("linux_time_bits64"); + } + } + + let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); + if linux_time_bits64 { + set_cfg("linux_time_bits64"); } println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS"); diff --git a/libc-test/build.rs b/libc-test/build.rs index f0796a65f2ed1..0f2533a14121d 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3836,6 +3836,7 @@ fn test_linux(target: &str) { let i686 = target.contains("i686"); let ppc = target.contains("powerpc"); let ppc64 = target.contains("powerpc64"); + let ppc32 = ppc && !ppc64; let s390x = target.contains("s390x"); let sparc64 = target.contains("sparc64"); let x32 = target.contains("x32"); @@ -3848,6 +3849,8 @@ fn test_linux(target: &str) { let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); let mips = target.contains("mips"); + let mips64 = target.contains("mips64"); + let mips32 = mips && !mips64; let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); if musl_v1_2_3 { @@ -3856,8 +3859,12 @@ fn test_linux(target: &str) { let old_musl = musl && !musl_v1_2_3; let mut cfg = ctest_cfg(); - if musl_v1_2_3 { + if (musl_v1_2_3 || loongarch64) && musl { cfg.cfg("musl_v1_2_3", None); + if arm || ppc32 || x86_32 || mips32 { + cfg.cfg("musl32_time64", None); + cfg.cfg("linux_time_bits64", None); + } } cfg.define("_GNU_SOURCE", None) // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are From 4089c85d674232f09b7804c9fa68039399ca2ed4 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Tue, 13 May 2025 04:40:47 +0000 Subject: [PATCH 11/24] musl: time64: adjust struct timespec definition This is equivalent to upstream commit bminor/musl@9b2921b. (backport ) (cherry picked from commit fa7e710e77f3c9025759580ccf1dbf56db343789) --- src/unix/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 1c4033da3d339..6ebf322b0247d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -72,10 +72,14 @@ s! { #[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))] pub struct timespec { pub tv_sec: time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] pub tv_nsec: i64, #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] pub tv_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, } pub struct rlimit { From 98532ed60bdd864ebd5cb1ae969c51cb2f10df52 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Tue, 13 May 2025 06:22:38 +0000 Subject: [PATCH 12/24] musl: time64: set link names for symbols This corresponds to upstream commit bminor/musl@1febd21 (most symbols) and bminor/musl@22daaea (only dlsym) (backport ) (cherry picked from commit 6fcc954468d7a2f595935f46c8f356c768b4e229) --- src/new/common/posix/pthread.rs | 1 + src/new/musl/sys/socket.rs | 1 + src/unix/linux_like/linux/mod.rs | 22 +++++++--- src/unix/linux_like/linux/musl/mod.rs | 3 ++ src/unix/linux_like/linux_l4re_shared.rs | 13 ++++-- src/unix/linux_like/mod.rs | 9 ++-- src/unix/mod.rs | 52 +++++++++++++----------- 7 files changed, 67 insertions(+), 34 deletions(-) diff --git a/src/new/common/posix/pthread.rs b/src/new/common/posix/pthread.rs index 50c6f98131294..146cd6042b0bb 100644 --- a/src/new/common/posix/pthread.rs +++ b/src/new/common/posix/pthread.rs @@ -195,6 +195,7 @@ extern "C" { #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] + #[cfg_attr(musl32_time64, link_name = "__pthread_mutex_timedlock_time64")] pub fn pthread_mutex_timedlock( lock: *mut crate::pthread_mutex_t, abstime: *const crate::timespec, diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs index 24731914641cc..e723043dc0a36 100644 --- a/src/new/musl/sys/socket.rs +++ b/src/new/musl/sys/socket.rs @@ -41,6 +41,7 @@ extern "C" { vlen: c_uint, flags: c_uint, ) -> c_int; + #[cfg_attr(musl32_time64, link_name = "__recvmmsg_time64")] pub fn recvmmsg( sockfd: c_int, msgvec: *mut crate::mmsghdr, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index f133c8e80cc9a..82920894f3e24 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4172,7 +4172,10 @@ cfg_if! { msg_len: size_t, msg_prio: *mut c_uint, ) -> ssize_t; - #[cfg_attr(gnu_time_bits64, link_name = "__mq_timedreceive_time64")] + #[cfg_attr( + any(gnu_time_bits64, musl32_time64), + link_name = "__mq_timedreceive_time64" + )] pub fn mq_timedreceive( mqd: mqd_t, msg_ptr: *mut c_char, @@ -4186,7 +4189,10 @@ cfg_if! { msg_len: size_t, msg_prio: c_uint, ) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__mq_timedsend_time64")] + #[cfg_attr( + any(gnu_time_bits64, musl32_time64), + link_name = "__mq_timedsend_time64" + )] pub fn mq_timedsend( mqd: mqd_t, msg_ptr: *const c_char, @@ -4210,6 +4216,7 @@ extern "C" { pub fn lcong48(p: *mut c_ushort); #[cfg_attr(gnu_time_bits64, link_name = "__lutimes64")] + #[cfg_attr(musl32_time64, link_name = "__lutimes_time64")] pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; @@ -4285,9 +4292,9 @@ extern "C" { pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int; pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timerfd_gettime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timerfd_gettime64")] pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timerfd_settime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timerfd_settime64")] pub fn timerfd_settime( fd: c_int, flags: c_int, @@ -4304,6 +4311,7 @@ extern "C" { ) -> c_int; pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__sigtimedwait64")] + #[cfg_attr(musl32_time64, link_name = "__sigtimedwait_time64")] pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -4366,6 +4374,7 @@ extern "C" { pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__sched_rr_get_interval64")] + #[cfg_attr(musl32_time64, link_name = "__sched_rr_get_interval_time64")] pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; pub fn setns(fd: c_int, nstype: c_int) -> c_int; @@ -4382,7 +4391,10 @@ extern "C" { ... ) -> c_int; pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__clock_nanosleep_time64")] + #[cfg_attr( + any(gnu_time_bits64, musl32_time64), + link_name = "__clock_nanosleep_time64" + )] pub fn clock_nanosleep( clk_id: crate::clockid_t, flags: c_int, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 6a233f8b0ffbe..208330b4ab75b 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -750,6 +750,7 @@ extern "C" { new_limit: *const crate::rlimit, old_limit: *mut crate::rlimit, ) -> c_int; + #[cfg_attr(musl32_time64, link_name = "__gettimeofday_time64")] pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; pub fn ptrace(request: c_int, ...) -> c_long; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; @@ -785,7 +786,9 @@ extern "C" { // Added in `musl` 1.2.2 pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + #[cfg_attr(musl32_time64, link_name = "__adjtimex_time64")] pub fn adjtimex(buf: *mut crate::timex) -> c_int; + #[cfg_attr(musl32_time64, link_name = "__clock_adjtime64")] pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::timex) -> c_int; pub fn ctermid(s: *mut c_char) -> *mut c_char; diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index b3d014482cfc7..39f24f9087247 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1648,7 +1648,10 @@ cfg_if! { pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; - #[cfg_attr(gnu_time_bits64, link_name = "__aio_suspend_time64")] + #[cfg_attr( + any(musl32_time64, gnu_time_bits64), + link_name = "__aio_suspend_time64" + )] pub fn aio_suspend( aiocb_list: *const *const crate::aiocb, nitems: c_int, @@ -1711,6 +1714,7 @@ cfg_if! { flags: c_ulong, ) -> isize; #[cfg_attr(gnu_time_bits64, link_name = "__futimes64")] + #[cfg_attr(musl32_time64, link_name = "__futimes_time64")] pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; } } @@ -1812,8 +1816,10 @@ extern "C" { ) -> c_int; pub fn sched_get_priority_max(policy: c_int) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__settimeofday64")] + #[cfg_attr(musl32_time64, link_name = "__settimeofday_time64")] pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__sem_timedwait64")] + #[cfg_attr(musl32_time64, link_name = "__sem_timedwait_time64")] pub fn sem_timedwait(sem: *mut crate::sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut crate::sem_t, sval: *mut c_int) -> c_int; pub fn mount( @@ -1826,6 +1832,7 @@ extern "C" { #[cfg_attr(gnu_time_bits64, link_name = "__prctl_time64")] pub fn prctl(option: c_int, ...) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__ppoll64")] + #[cfg_attr(musl32_time64, link_name = "__ppoll_time64")] pub fn ppoll( fds: *mut crate::pollfd, nfds: crate::nfds_t, @@ -1916,9 +1923,9 @@ extern "C" { pub fn timer_delete(timerid: crate::timer_t) -> c_int; #[cfg(not(target_os = "l4re"))] pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timer_gettime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timer_gettime64")] pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__timer_settime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__timer_settime64")] pub fn timer_settime( timerid: crate::timer_t, flags: c_int, diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index c5726545105ac..19195f0432912 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1879,10 +1879,11 @@ extern "C" { pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__clock_getres64")] + #[cfg_attr(musl32_time64, link_name = "__clock_getres_time64")] pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__clock_gettime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__clock_gettime64")] pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__clock_settime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__clock_settime64")] pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; #[cfg(not(target_os = "l4re"))] pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; @@ -1901,9 +1902,11 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__futimens64")] + #[cfg_attr(musl32_time64, link_name = "__futimens_time64")] #[cfg(not(target_os = "l4re"))] pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; #[cfg_attr(gnu_time_bits64, link_name = "__utimensat64")] + #[cfg_attr(musl32_time64, link_name = "__utimensat_time64")] pub fn utimensat( dirfd: c_int, path: *const c_char, @@ -1955,7 +1958,7 @@ extern "C" { pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; #[cfg(not(target_os = "l4re"))] pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; - #[cfg_attr(gnu_time_bits64, link_name = "__wait4_time64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__wait4_time64")] #[cfg(not(target_os = "l4re"))] pub fn wait4( pid: crate::pid_t, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6ebf322b0247d..2458df9b5adf2 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -887,6 +887,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "fstat64" )] + #[cfg_attr(musl32_time64, link_name = "__fstat_time64")] pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; @@ -905,6 +906,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "stat64" )] + #[cfg_attr(musl32_time64, link_name = "__stat_time64")] pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; pub fn pclose(stream: *mut crate::FILE) -> c_int; @@ -999,6 +1001,7 @@ extern "C" { link_name = "fstatat64" )] #[cfg(not(target_os = "l4re"))] + #[cfg_attr(musl32_time64, link_name = "__fstatat_time64")] pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; #[cfg(not(target_os = "l4re"))] pub fn linkat( @@ -1108,6 +1111,7 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] #[cfg_attr(gnu_time_bits64, link_name = "__nanosleep64")] + #[cfg_attr(musl32_time64, link_name = "__nanosleep_time64")] pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int; pub fn tcgetpgrp(fd: c_int) -> pid_t; pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int; @@ -1152,7 +1156,7 @@ extern "C" { pub fn umask(mask: mode_t) -> mode_t; #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] - #[cfg_attr(gnu_time_bits64, link_name = "__utime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__utime64")] pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; #[cfg_attr( @@ -1207,6 +1211,7 @@ extern "C" { all(not(gnu_time_bits64), gnu_file_offset_bits64), link_name = "lstat64" )] + #[cfg_attr(musl32_time64, link_name = "__lstat_time64")] pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; #[cfg_attr( @@ -1238,6 +1243,7 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")] + #[cfg_attr(musl32_time64, link_name = "__getrusage_time64")] pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; #[cfg_attr( @@ -1320,6 +1326,7 @@ extern "C" { link_name = "pthread_cond_timedwait$UNIX2003" )] #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")] + #[cfg_attr(musl32_time64, link_name = "__pthread_cond_timedwait_time64")] pub fn pthread_cond_timedwait( cond: *mut crate::pthread_cond_t, lock: *mut crate::pthread_mutex_t, @@ -1388,9 +1395,11 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] #[cfg_attr(gnu_time_bits64, link_name = "__utimes64")] + #[cfg_attr(musl32_time64, link_name = "__utimes_time64")] pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; pub fn dlerror() -> *mut c_char; + #[cfg_attr(musl32_time64, link_name = "__dlsym_time64")] pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; pub fn dlclose(handle: *mut c_void) -> c_int; @@ -1439,49 +1448,44 @@ extern "C" { pub fn res_init() -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64_r")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl32_time64, link_name = "__gmtime64_r")] pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` #[cfg_attr(gnu_time_bits64, link_name = "__localtime64_r")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl32_time64, link_name = "__localtime64_r")] pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "mktime$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__mktime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__mktime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] pub fn mktime(tm: *mut tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__time50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME: for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__time64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__time64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] pub fn time(time: *mut time_t) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__gmtime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] pub fn gmtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__localtime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__localtime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] pub fn localtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` - #[cfg_attr(gnu_time_bits64, link_name = "__difftime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__difftime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] pub fn difftime(time1: time_t, time0: time_t) -> c_double; #[cfg(not(target_os = "aix"))] #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] - #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] - // FIXME(time): for `time_t` #[cfg_attr(gnu_time_bits64, link_name = "__timegm64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl32_time64, link_name = "__timegm_time64")] pub fn timegm(tm: *mut crate::tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] @@ -1542,6 +1546,7 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__select50")] #[cfg_attr(target_os = "aix", link_name = "__fd_select")] #[cfg_attr(gnu_time_bits64, link_name = "__select64")] + #[cfg_attr(musl32_time64, link_name = "__select_time64")] pub fn select( nfds: c_int, readfds: *mut fd_set, @@ -1670,7 +1675,7 @@ cfg_if! { )))] { extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")] - #[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")] + #[cfg_attr(any(gnu_time_bits64, musl32_time64), link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; } } else if #[cfg(target_os = "solaris")] { @@ -1848,6 +1853,7 @@ cfg_if! { )] #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] #[cfg_attr(gnu_time_bits64, link_name = "__pselect64")] + #[cfg_attr(musl32_time64, link_name = "__pselect_time64")] pub fn pselect( nfds: c_int, readfds: *mut fd_set, From 02d273bb8644c4fc873e582ab72978ca35b7bfdc Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Tue, 13 May 2025 07:25:07 +0000 Subject: [PATCH 13/24] musl: time64: update struct sched_param A bunch of properties were removed upstream and set to reserved. This matches upstream commit bminor/musl@827aa8f and bminor/musl@2d69fcf (backport ) (cherry picked from commit 72a590fa1fd5faf3f947e02cda45e2b1ec165c8e) --- src/new/emscripten/mod.rs | 1 + src/new/emscripten/sched.rs | 38 +++++++++++++++++++++++++++++++++++++ src/new/mod.rs | 2 ++ src/new/musl/mod.rs | 1 + src/new/musl/sched.rs | 38 +++++++++++++++++++++++++++++++++++++ src/unix/linux_like/mod.rs | 9 +-------- 6 files changed, 81 insertions(+), 8 deletions(-) create mode 100644 src/new/emscripten/sched.rs create mode 100644 src/new/musl/sched.rs diff --git a/src/new/emscripten/mod.rs b/src/new/emscripten/mod.rs index f0765d3e06fff..9b74464059bb1 100644 --- a/src/new/emscripten/mod.rs +++ b/src/new/emscripten/mod.rs @@ -3,4 +3,5 @@ //! * Headers: pub(crate) mod pthread; +pub(crate) mod sched; pub(crate) mod unistd; diff --git a/src/new/emscripten/sched.rs b/src/new/emscripten/sched.rs new file mode 100644 index 0000000000000..3bf854ef33c29 --- /dev/null +++ b/src/new/emscripten/sched.rs @@ -0,0 +1,38 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(musl_v1_2_3)] { + s! { + struct __c_anon_sched_param__reserved2 { + __reserved1: crate::time_t, + __reserved2: c_long, + } + + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: Padding, + #[cfg(musl32_time64)] + __reserved2: Padding<[c_long; 4]>, + #[cfg(not(musl32_time64))] + __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, + __reserved3: Padding, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_max_repl: c_int, + } + } + } +} diff --git a/src/new/mod.rs b/src/new/mod.rs index dd451bb5286bd..3e373ce520d7c 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -58,6 +58,7 @@ cfg_if! { pub(crate) use dragonfly::*; } else if #[cfg(target_os = "emscripten")] { mod emscripten; + pub use emscripten::sched::*; pub(crate) use emscripten::*; } else if #[cfg(target_os = "espidf")] { mod espidf; @@ -150,6 +151,7 @@ cfg_if! { } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { // OhOS also uses the musl libc mod musl; + pub use musl::sched::*; pub(crate) use musl::*; } else if #[cfg(target_env = "newlib")] { mod newlib; diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs index 9fd4d8e96100d..a6551c342da67 100644 --- a/src/new/musl/mod.rs +++ b/src/new/musl/mod.rs @@ -29,4 +29,5 @@ pub(crate) mod sys { pub(crate) mod socket; } +pub(crate) mod sched; pub(crate) mod unistd; diff --git a/src/new/musl/sched.rs b/src/new/musl/sched.rs new file mode 100644 index 0000000000000..3bf854ef33c29 --- /dev/null +++ b/src/new/musl/sched.rs @@ -0,0 +1,38 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(musl_v1_2_3)] { + s! { + struct __c_anon_sched_param__reserved2 { + __reserved1: crate::time_t, + __reserved2: c_long, + } + + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: Padding, + #[cfg(musl32_time64)] + __reserved2: Padding<[c_long; 4]>, + #[cfg(not(musl32_time64))] + __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, + __reserved3: Padding, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_max_repl: c_int, + } + } + } +} diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 19195f0432912..291c2b634664b 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -103,16 +103,9 @@ s! { pub tm_zone: *const c_char, } + #[cfg(not(any(target_env = "musl", target_os = "emscripten", target_env = "ohos")))] pub struct sched_param { pub sched_priority: c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_low_priority: c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_repl_period: crate::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_init_budget: crate::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] - pub sched_ss_max_repl: c_int, } pub struct Dl_info { From 918b54163aac1778526d327f697f1f729f83fdc4 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 4 Dec 2025 12:28:17 +0000 Subject: [PATCH 14/24] musl: convert inline timespecs to timespec (backport ) (cherry picked from commit 80b82d8330ac736023ce166e29c4d6160f09b0e5) --- libc-test/build.rs | 4 ++-- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b32/hexagon.rs | 14 ++++++++++++++ src/unix/linux_like/linux/musl/b32/mips/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b32/powerpc.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b32/riscv32/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 15 +++++++++++++++ .../linux_like/linux/musl/b64/loongarch64/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/mips64.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/powerpc64.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/riscv64/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/s390x.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/wasm32/mod.rs | 15 +++++++++++++++ src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 15 +++++++++++++++ 15 files changed, 211 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 0f2533a14121d..e39eb4e34be9e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4118,9 +4118,9 @@ fn test_linux(target: &str) { cfg.rename_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { // Our stat *_nsec fields normally don't actually exist but are part - // of a timeval struct + // of a timeval struct - this is fixed in musl_v1_2_3 ("stat" | "statfs" | "statvfs" | "stat64" | "statfs64" | "statvfs64", f) - if f.ends_with("_nsec") => + if !musl_v1_2_3 && f.ends_with("_nsec") => { Some(f.replace("e_nsec", ".tv_nsec")) } diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 0f2daa5fc018c..e1d0a5b37dc5c 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -19,12 +19,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_ino: crate::ino_t, } diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 8ce439cee5bf9..7aa01d625cdcd 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -17,13 +17,27 @@ s! { pub st_blksize: crate::blksize_t, __st_blksize_padding: Padding, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_int; 2]>, } 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 b4a7f1a575dda..e3b9ec7fa3dcb 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -17,12 +17,27 @@ s! { pub st_rdev: crate::dev_t, __st_padding2: Padding<[c_long; 2]>, pub st_size: off_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, __st_padding3: Padding, pub st_blocks: crate::blkcnt_t, diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 6e5bcde7ce112..1b28e331827df 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -29,12 +29,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_long; 2]>, } 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 45fa0a2081ff1..5561dcb34d358 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -21,12 +21,27 @@ s! { pub st_blksize: crate::blksize_t, pub __pad2: c_int, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_int; 2usize]>, } diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 0db24b65932ff..73b1ef9618e28 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -19,12 +19,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_ino: crate::ino_t, } diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index e28310be3ee32..47f29d5e11abf 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -23,12 +23,27 @@ s! { pub st_blksize: crate::blksize_t, __pad1: Padding, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_uint; 2]>, } 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 8e890be51848f..29f7d49cc8320 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -26,12 +26,27 @@ s! { pub st_blksize: crate::blksize_t, __pad2: Padding, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_int; 2usize]>, } diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 1fb8618c30c0b..d05b40bd38a11 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -22,12 +22,27 @@ s! { __pad2: Padding<[c_uint; 2]>, pub st_size: off_t, __pad3: Padding, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, __pad4: Padding, pub st_blocks: crate::blkcnt_t, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 4885ea2f0e182..6e0d6db6a1978 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -33,12 +33,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_long; 3]>, } 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 bd395e49cefc1..ba9bebd84cc73 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -26,12 +26,27 @@ s! { pub st_blksize: crate::blksize_t, __pad2: Padding, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_int; 2usize]>, } diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 0ee6c11c6a1e6..7776e10b60dce 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -40,12 +40,27 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_size: off_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, __unused: Padding<[c_long; 3]>, 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 1a4d89632dcc9..06b34c25d9238 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -24,12 +24,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_long; 3]>, } diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index dcc41752c6e86..ec9a31bccf577 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -23,12 +23,27 @@ s! { pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] pub st_ctime_nsec: c_long, + + #[cfg(musl_v1_2_3)] + pub st_atim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_mtim: crate::timespec, + #[cfg(musl_v1_2_3)] + pub st_ctim: crate::timespec, + __unused: Padding<[c_long; 3]>, } From 21d3b84610353aef750ccb5240ad0833a7852e42 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Mon, 19 May 2025 10:43:43 +0000 Subject: [PATCH 15/24] musl: time64: change time_t type and structs Change time_t type to i64 Change struct stat, msqid_ds and shmid_ds to reflect This commit follows upstream bminor/musl@3814333 and bminor/musl@d6dcfe4 It also implements a fix from bminor/musl@0fbd7d6 (backport ) (cherry picked from commit 793fa971aabfbadb1ef9564cdc9fcdc31f3ef636) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 94 +++++++-- .../linux_like/linux/musl/b32/mips/mod.rs | 178 ++++++++++++++---- src/unix/linux_like/linux/musl/b32/powerpc.rs | 97 ++++++++-- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 94 +++++++-- src/unix/linux_like/linux/musl/mod.rs | 15 ++ 5 files changed, 393 insertions(+), 85 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index e1d0a5b37dc5c..0f96453fde4f4 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -20,27 +20,33 @@ s! { pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_mtime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_mtime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_ctime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_atim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_mtim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_ctim: crate::timespec, pub st_ino: crate::ino_t, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct stack_t { @@ -72,27 +78,78 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, __pad1: Padding, __pad2: Padding, + + #[cfg(musl32_time64)] + __pad3: c_ulong, + #[cfg(musl32_time64)] + shm_atime: crate::time_t, + #[cfg(musl32_time64)] + shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + shm_ctime: crate::time_t, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: Padding, + #[cfg(musl32_time64)] + __msg_stime_hi: Padding, + #[cfg(musl32_time64)] + __msg_rtime_lo: Padding, + #[cfg(musl32_time64)] + __msg_rtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -100,6 +157,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: Padding, __pad2: Padding, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, } pub struct mcontext_t { 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 e3b9ec7fa3dcb..0771a7f67c888 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -18,30 +18,40 @@ s! { __st_padding2: Padding<[c_long; 2]>, pub st_size: off_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_mtime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_mtime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_ctime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_atim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_mtim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_ctim: crate::timespec, pub st_blksize: crate::blksize_t, __st_padding3: Padding, pub st_blocks: crate::blkcnt_t, + #[cfg(not(musl32_time64))] __st_padding4: Padding<[c_long; 14]>, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, + + #[cfg(musl32_time64)] + __st_padding4: Padding<[c_long; 2]>, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct stack_t { @@ -73,40 +83,40 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_ctime_lo: Padding, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] __pad1: Padding, + #[cfg(not(musl32_time64))] __pad2: Padding, - } - pub struct msqid_ds { - pub msg_perm: crate::ipc_perm, - #[cfg(target_endian = "big")] - __unused1: Padding, - pub msg_stime: crate::time_t, - #[cfg(target_endian = "little")] - __unused1: Padding, - #[cfg(target_endian = "big")] - __unused2: Padding, - pub msg_rtime: crate::time_t, - #[cfg(target_endian = "little")] - __unused2: Padding, - #[cfg(target_endian = "big")] - __unused3: Padding, - pub msg_ctime: crate::time_t, - #[cfg(target_endian = "little")] - __unused3: Padding, - pub __msg_cbytes: c_ulong, - pub msg_qnum: crate::msgqnum_t, - pub msg_qbytes: crate::msglen_t, - pub msg_lspid: crate::pid_t, - pub msg_lrpid: crate::pid_t, - __pad1: Padding, - __pad2: Padding, + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __shm_ctime_hi: Padding, + #[cfg(musl32_time64)] + __pad1: Padding, + #[cfg(musl32_time64)] + pub shm_atime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_ctime: crate::time_t, } pub struct statfs { @@ -140,6 +150,94 @@ s! { } } +cfg_if! { + if #[cfg(musl32_time64)] { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(target_endian = "big")] + __msg_stime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_stime_lo: Padding, + #[cfg(target_endian = "big")] + __msg_rtime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_rtime_lo: Padding, + #[cfg(target_endian = "big")] + __msg_ctime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_ctime_lo: Padding, + + #[cfg(target_endian = "little")] + __msg_stime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_stime_hi: Padding, + #[cfg(target_endian = "little")] + __msg_rtime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_rtime_hi: Padding, + #[cfg(target_endian = "little")] + __msg_ctime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_ctime_hi: Padding, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + } + } + } else { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(target_endian = "big")] + __unused1: Padding, + #[cfg(target_endian = "big")] + pub msg_stime: crate::time_t, + #[cfg(target_endian = "big")] + __unused2: Padding, + #[cfg(target_endian = "big")] + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "big")] + __unused3: Padding, + #[cfg(target_endian = "big")] + pub msg_ctime: crate::time_t, + + #[cfg(target_endian = "little")] + pub msg_stime: crate::time_t, + #[cfg(target_endian = "little")] + __unused1: Padding, + #[cfg(target_endian = "little")] + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "little")] + __unused2: Padding, + #[cfg(target_endian = "little")] + pub msg_ctime: crate::time_t, + #[cfg(target_endian = "little")] + __unused3: Padding, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } + } + } +} + s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 1b28e331827df..64a2719abbc11 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -30,27 +30,33 @@ s! { pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_mtime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_mtime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_ctime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_atim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_mtim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_ctim: crate::timespec, __unused: Padding<[c_long; 2]>, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct stack_t { @@ -82,29 +88,83 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_ctime_hi: Padding, + #[cfg(musl32_time64)] + __shm_ctime_lo: Padding, + + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused4: Padding, + + #[cfg(musl32_time64)] + __pad1: Padding, + pub shm_segsz: size_t, pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] __pad1: Padding, __pad2: Padding, + + #[cfg(musl32_time64)] + pub shm_atime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_ctime: crate::time_t, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_hi: Padding, + #[cfg(musl32_time64)] + __msg_stime_lo: Padding, + #[cfg(musl32_time64)] + __msg_rtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_rtime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -112,6 +172,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: Padding, __pad2: Padding, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, } } diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 73b1ef9618e28..3f2145bc266ef 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -20,27 +20,33 @@ s! { pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_atime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_mtime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_mtime_nsec: c_long, - #[cfg(not(musl_v1_2_3))] - pub st_ctime: crate::time_t, - #[cfg(not(musl_v1_2_3))] - pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_atim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_mtim: crate::timespec, - #[cfg(musl_v1_2_3)] + #[cfg(not(musl32_time64))] pub st_ctim: crate::timespec, pub st_ino: crate::ino_t, + + #[cfg(musl32_time64)] + pub st_atim: crate::timespec, + #[cfg(musl32_time64)] + pub st_mtim: crate::timespec, + #[cfg(musl32_time64)] + pub st_ctim: crate::timespec, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, } pub struct mcontext_t { @@ -76,27 +82,78 @@ s! { pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_atime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub shm_cpid: crate::pid_t, pub shm_lpid: crate::pid_t, pub shm_nattch: c_ulong, __pad1: Padding, __pad2: Padding, + + #[cfg(musl32_time64)] + __pad3: c_ulong, + #[cfg(musl32_time64)] + shm_atime: crate::time_t, + #[cfg(musl32_time64)] + shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + shm_ctime: crate::time_t, } pub struct msqid_ds { pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] __unused1: Padding, + #[cfg(not(musl32_time64))] pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] __unused2: Padding, + #[cfg(not(musl32_time64))] pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] __unused3: Padding, + pub __msg_cbytes: c_ulong, pub msg_qnum: crate::msgqnum_t, pub msg_qbytes: crate::msglen_t, @@ -104,6 +161,13 @@ s! { pub msg_lrpid: crate::pid_t, __pad1: Padding, __pad2: Padding, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, } pub struct user_fpxregs_struct { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 208330b4ab75b..f257e51d044e3 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -3,6 +3,9 @@ use crate::prelude::*; pub type pthread_t = *mut c_void; pub type clock_t = c_long; +#[cfg(musl32_time64)] +pub type time_t = i64; +#[cfg(not(musl32_time64))] #[cfg_attr( not(feature = "rustc-dep-of-std"), deprecated( @@ -13,6 +16,18 @@ pub type clock_t = c_long; ) )] pub type time_t = c_long; +#[cfg(musl32_time64)] +pub type suseconds_t = i64; +#[cfg(not(musl32_time64))] +#[cfg_attr( + not(feature = "rustc-dep-of-std"), + deprecated( + since = "0.2.80", + note = "This type is changed to 64-bit in musl 1.2.0, \ + we'll follow that change in the future release. \ + See #1848 for more info." + ) +)] pub type suseconds_t = c_long; pub type ino_t = u64; pub type off_t = i64; From 1626e1aef32d4c28ed6972bef78ce5f0d44e0972 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Mon, 19 May 2025 10:47:37 +0000 Subject: [PATCH 16/24] musl: time64: update {IPC,MSG,SEM}_STAT definitions This is primarily based on a small part of bminor/musl@3814333. This also integrates bminor/musl@3c02bac, which update MSG_STAT, SEM_STAT, SEM_STAT_ANY. These are based on the value of IPC_STAT, however we can just use `cfg` as it is effectively the same. (backport ) (cherry picked from commit 3d9801debc89299c7b4afb1cb12a647810430f94) --- src/unix/linux_like/linux/mod.rs | 7 +++---- src/unix/linux_like/linux_l4re_shared.rs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 82920894f3e24..7b2c21df5516c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,5 +1,4 @@ //! Linux-specific definitions for linux-like values - use crate::prelude::*; use crate::{ sock_filter, @@ -1609,7 +1608,7 @@ pub const RENAME_NOREPLACE: c_uint = 1; pub const RENAME_EXCHANGE: c_uint = 2; pub const RENAME_WHITEOUT: c_uint = 4; -pub const MSG_STAT: c_int = 11; +pub const MSG_STAT: c_int = 11 | (crate::IPC_STAT & 0x100); pub const MSG_INFO: c_int = 12; pub const MSG_NOTIFICATION: c_int = 0x8000; @@ -1626,9 +1625,9 @@ pub const GETNCNT: c_int = 14; pub const GETZCNT: c_int = 15; pub const SETVAL: c_int = 16; pub const SETALL: c_int = 17; -pub const SEM_STAT: c_int = 18; +pub const SEM_STAT: c_int = 18 | (crate::IPC_STAT & 0x100); pub const SEM_INFO: c_int = 19; -pub const SEM_STAT_ANY: c_int = 20; +pub const SEM_STAT_ANY: c_int = 20 | (crate::IPC_STAT & 0x100); pub const QFMT_VFS_OLD: c_int = 1; pub const QFMT_VFS_V0: c_int = 2; diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 39f24f9087247..bd3cfafeb6e72 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -976,7 +976,7 @@ pub const IPC_NOWAIT: c_int = 0o4000; pub const IPC_RMID: c_int = 0; pub const IPC_SET: c_int = 1; -pub const IPC_STAT: c_int = 2; +pub const IPC_STAT: c_int = if cfg!(musl32_time64) { 0x102 } else { 2 }; pub const IPC_INFO: c_int = 3; pub const SHM_R: c_int = 0o400; From 761901cdca4bd4e189f874c246f12d4a9dbb6023 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 24 May 2025 12:34:36 +0000 Subject: [PATCH 17/24] semver: linux powerpc: split GNU-specific symbols into own file. This fixes test failures on musl. (backport ) (cherry picked from commit 8195473b4407f59a5e89b358485b4f55d39d5cf1) --- libc-test/semver/linux-powerpc-gnu.txt | 16 ++++++++++++++++ libc-test/semver/linux-powerpc.txt | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 libc-test/semver/linux-powerpc-gnu.txt diff --git a/libc-test/semver/linux-powerpc-gnu.txt b/libc-test/semver/linux-powerpc-gnu.txt new file mode 100644 index 0000000000000..d63be666e789f --- /dev/null +++ b/libc-test/semver/linux-powerpc-gnu.txt @@ -0,0 +1,16 @@ +KEYCTL_CAPABILITIES +KEYCTL_CAPS0_BIG_KEY +KEYCTL_CAPS0_CAPABILITIES +KEYCTL_CAPS0_DIFFIE_HELLMAN +KEYCTL_CAPS0_INVALIDATE +KEYCTL_CAPS0_MOVE +KEYCTL_CAPS0_PERSISTENT_KEYRINGS +KEYCTL_CAPS0_PUBLIC_KEY +KEYCTL_CAPS0_RESTRICT_KEYRING +KEYCTL_CAPS1_NS_KEYRING_NAME +KEYCTL_CAPS1_NS_KEY_TAG +KEYCTL_MOVE +PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP +PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +sysctl diff --git a/libc-test/semver/linux-powerpc.txt b/libc-test/semver/linux-powerpc.txt index 2826bb98d20e3..a559c891a4f95 100644 --- a/libc-test/semver/linux-powerpc.txt +++ b/libc-test/semver/linux-powerpc.txt @@ -2,27 +2,12 @@ B2500000 B3000000 B3500000 B4000000 -KEYCTL_CAPABILITIES -KEYCTL_CAPS0_BIG_KEY -KEYCTL_CAPS0_CAPABILITIES -KEYCTL_CAPS0_DIFFIE_HELLMAN -KEYCTL_CAPS0_INVALIDATE -KEYCTL_CAPS0_MOVE -KEYCTL_CAPS0_PERSISTENT_KEYRINGS -KEYCTL_CAPS0_PUBLIC_KEY -KEYCTL_CAPS0_RESTRICT_KEYRING -KEYCTL_CAPS1_NS_KEYRING_NAME -KEYCTL_CAPS1_NS_KEY_TAG -KEYCTL_MOVE MADV_SOFT_OFFLINE MAP_SYNC NFT_MSG_DELOBJ NFT_MSG_GETOBJ NFT_MSG_GETOBJ_RESET NFT_MSG_NEWOBJ -PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTRACE_GETFPREGS PTRACE_GETREGS PTRACE_SETFPREGS @@ -158,4 +143,3 @@ TIOCSRS485 flock64 fsblkcnt64_t fsfilcnt64_t -sysctl From db00c4302c3529bd9dfb4b859797274329828532 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 26 Jun 2025 10:40:22 +0000 Subject: [PATCH 18/24] libc-test: add allowlist for positive s! marco configs Namely, this allows `target_endian` as well as adds a constant array where certain configs are explicitly allowed (e.g. musl32_time64). (backport ) (cherry picked from commit 75fb1f0658fc95b7614a6c6f0b0026389e8eefd9) --- libc-test/tests/style_lib/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libc-test/tests/style_lib/mod.rs b/libc-test/tests/style_lib/mod.rs index 04eec91df635d..34d3cc807c6a1 100644 --- a/libc-test/tests/style_lib/mod.rs +++ b/libc-test/tests/style_lib/mod.rs @@ -51,6 +51,12 @@ use syn::visit::{ use syn::Token; const ALLOWED_REPEATED_MACROS: &[&str] = &["s", "s_no_extra_traits", "s_paren"]; +const ALLOWED_POSITIVE_S_CFGS: &[&str] = &[ + "gnu_file_offset_bits64", + "gnu_time_bits64", + "musl32_time64", + "musl_v1_2_3", +]; pub type Error = Box; pub type Result = std::result::Result; @@ -285,6 +291,8 @@ impl StyleChecker { if !meta_str.starts_with("not") && !meta_str.starts_with("any") && !meta_str.starts_with("all") + && !meta_str.starts_with("target_endian") + && !ALLOWED_POSITIVE_S_CFGS.contains(&meta_str.as_str()) { self.error( "positive #[cfg] for s! macro".to_string(), From 0a9180b9cb4777207ffa296840582103a392c97c Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 30 Oct 2025 08:48:38 +0000 Subject: [PATCH 19/24] libc-test: delete handle_s_macro_no_attrs Unfortunately does not seem to handle cfg_if well (backport ) (cherry picked from commit 587fd843559374b9083d66fd6ecff9f831cfc671) --- libc-test/tests/style_lib/mod.rs | 23 +---------------------- libc-test/tests/style_tests.rs | 13 ------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/libc-test/tests/style_lib/mod.rs b/libc-test/tests/style_lib/mod.rs index 34d3cc807c6a1..d436dcaaa2800 100644 --- a/libc-test/tests/style_lib/mod.rs +++ b/libc-test/tests/style_lib/mod.rs @@ -242,25 +242,6 @@ impl StyleChecker { self.state = initial_state; } - /// If we see a normal s! macro without any attributes we just need - /// to check if there are any duplicates. - fn handle_s_macro_no_attrs(&mut self, item_macro: &syn::ItemMacro) { - let span = item_macro.span(); - match self.seen_s_macro_cfgs.get("") { - Some(seen_span) => { - self.error( - "duplicate s! macro".to_string(), - span, - format!("other s! macro"), - (Some(*seen_span), "combine the two".to_string()), - ); - } - None => { - self.seen_s_macro_cfgs.insert(String::new(), span); - } - } - } - /// If an s! macro has attributes we check for any duplicates as well /// as if they are standalone positive cfgs that would be better /// in a separate file. @@ -367,9 +348,7 @@ impl<'ast> Visit<'ast> for StyleChecker { /// instead of [syn::Macro] because it contains the attributes. fn visit_item_macro(&mut self, item_macro: &'ast syn::ItemMacro) { if item_macro.mac.path.is_ident("s") { - if item_macro.attrs.is_empty() { - self.handle_s_macro_no_attrs(item_macro); - } else { + if !item_macro.attrs.is_empty() { self.handle_s_macro_with_attrs(item_macro); } } diff --git a/libc-test/tests/style_tests.rs b/libc-test/tests/style_tests.rs index e136bb66d26a4..c325a51770b6e 100644 --- a/libc-test/tests/style_tests.rs +++ b/libc-test/tests/style_tests.rs @@ -154,19 +154,6 @@ s! { pub struct bar { /* ... */ } } checker.finalize().unwrap(); } -#[test] -fn check_style_reject_duplicated_s_macro() { - let contents = r#" -s! {} -s! {} -"# - .to_string(); - - let mut checker = StyleChecker::new(); - checker.check_string(contents).unwrap(); - assert!(checker.finalize().is_err()); -} - #[test] fn check_style_reject_duplicated_s_macro_cfg() { let contents = r#" From 9826b56187a91f39e44b6f8c21005f779cd10fb5 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 4 Dec 2025 13:19:12 +0000 Subject: [PATCH 20/24] Revert "test: Skip `input_event.time` on recent musl" This reverts commit 34e758376862382e0da205c918160f398e9e72b5. (backport ) (cherry picked from commit 092ccf22c974f18202a869f50e15a8f03524c3a8) --- libc-test/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e39eb4e34be9e..21c6702b2ce17 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4893,8 +4893,6 @@ fn test_linux(target: &str) { ("xsk_tx_metadata", "xsk_tx_metadata_union") => true, // After musl 1.2.0, the type becomes `int` instead of `long`. ("utmpx", "ut_session") if musl => true, - // FIXME(musl,time): changed with the musl time updates - ("input_event", "time") if musl_v1_2_3 => true, // `frames` is a flexible array member ("bcm_msg_head", "frames") => true, // FAM From b4a456d3324bee11a7578199e7d698177ada9158 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Thu, 4 Dec 2025 13:19:04 +0000 Subject: [PATCH 21/24] Revert "test: musl: Skip time64-dependent API on new musl" This reverts commit 72fe537010f9600bfedbb43af89bdb8ff967317e. (backport ) (cherry picked from commit 7726e8fb57c1cdbb1a66dbb5366d19567a5f5f8c) --- libc-test/build.rs | 77 ---------------------------------------------- 1 file changed, 77 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 21c6702b2ce17..37907d1ae4a67 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4947,83 +4947,6 @@ fn test_linux(target: &str) { _ => false, }); - // FIXME(musl,time): these should be resolved with the time64 updates - if musl_v1_2_3 { - // Time primitives changed, as did structs containing them - cfg.skip_alias(|ty| match ty.ident() { - "time_t" | "suseconds_t" => true, - _ => false, - }); - cfg.skip_struct(|s| match s.ident() { - "utimbuf" | "timeval" | "timespec" | "rusage" | "itimerval" | "itimerspec" - | "timex" | "ntptimeval" | "stat" | "shmid_ds" | "msqid_ds" => true, - _ => false, - }); - - cfg.skip_const(|c| match c.ident() { - // Changed syscall numbers under `linux_time_bits64` - "SO_TIMESTAMP" | "SO_TIMESTAMPNS" | "SO_TIMESTAMPING" | "SO_RCVTIMEO" - | "SO_SNDTIMEO" => true, - // Derived from `SO_` constants - "SCM_TIMESTAMP" | "SCM_TIMESTAMPNS" | "SCM_TIMESTAMPING" => true, - // `IPC_STAT` and derived values - "IPC_STAT" | "SEM_STAT" | "SEM_STAT_ANY" => true, - _ => false, - }); - - // Functions that got a new link name - cfg.skip_fn_ptrcheck(|f| match f { - "pthread_mutex_timedlock" - | "recvmmsg" - | "fstat" - | "stat" - | "fstatat" - | "nanosleep" - | "utime" - | "lstat" - | "getrusage" - | "pthread_cond_timedwait" - | "utimes" - | "dlsym" - | "gmtime_r" - | "localtime_r" - | "mktime" - | "time" - | "gmtime" - | "localtime" - | "difftime" - | "timegm" - | "select" - | "adjtime" - | "pselect" - | "clock_getres" - | "clock_gettime" - | "clock_settime" - | "futimens" - | "utimensat" - | "wait4" - | "aio_suspend" - | "futimes" - | "mq_timedreceive" - | "mq_timedsend" - | "lutimes" - | "timerfd_gettime" - | "timerfd_settime" - | "sigtimedwait" - | "settimeofday" - | "sched_rr_get_interval" - | "sem_timedwait" - | "ppoll" - | "clock_nanosleep" - | "timer_gettime" - | "timer_settime" - | "gettimeofday" - | "adjtimex" - | "clock_adjtime" => true, - _ => false, - }); - } - ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); if !l4re { From 9e9c6f8c5746e7fae73fa0835ad6d8a262618ee0 Mon Sep 17 00:00:00 2001 From: Aphek Date: Thu, 4 Dec 2025 00:46:33 -0300 Subject: [PATCH 22/24] newlib: Fix ambiguous glob exports and other warnings for Vita and 3DS (backport ) (cherry picked from commit fb18f2667c4adb45f46913282d5c0c48f158692d) --- src/new/vita/mod.rs | 2 -- src/new/vita/unistd.rs | 7 ------- src/unix/mod.rs | 3 ++- src/unix/newlib/generic.rs | 10 +++++----- src/unix/newlib/horizon/mod.rs | 9 ++++++--- src/unix/newlib/mod.rs | 26 -------------------------- src/unix/newlib/rtems/mod.rs | 2 -- src/unix/newlib/vita/mod.rs | 2 -- 8 files changed, 13 insertions(+), 48 deletions(-) delete mode 100644 src/new/vita/unistd.rs diff --git a/src/new/vita/mod.rs b/src/new/vita/mod.rs index 38783a3f19fbc..21205ebd046fb 100644 --- a/src/new/vita/mod.rs +++ b/src/new/vita/mod.rs @@ -1,4 +1,2 @@ //! VITASDK system library. // FIXME(vita): link to headers or manpages needed. - -pub(crate) mod unistd; diff --git a/src/new/vita/unistd.rs b/src/new/vita/unistd.rs deleted file mode 100644 index 8d55ee5823315..0000000000000 --- a/src/new/vita/unistd.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Header: `unistd.h` - -pub use crate::new::common::posix::unistd::{ - STDERR_FILENO, - STDIN_FILENO, - STDOUT_FILENO, -}; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 2458df9b5adf2..1a326682d9ff3 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -146,7 +146,7 @@ s! { pub ipv6mr_interface: c_uint, } - #[cfg(not(target_os = "cygwin"))] + #[cfg(all(not(target_os = "cygwin"), not(target_os = "horizon")))] pub struct hostent { pub h_name: *mut c_char, pub h_aliases: *mut *mut c_char, @@ -160,6 +160,7 @@ s! { pub iov_len: size_t, } + #[cfg(not(target_os = "horizon"))] pub struct pollfd { pub fd: c_int, pub events: c_short, diff --git a/src/unix/newlib/generic.rs b/src/unix/newlib/generic.rs index ba4dfbe528b69..303de806b653f 100644 --- a/src/unix/newlib/generic.rs +++ b/src/unix/newlib/generic.rs @@ -1,16 +1,15 @@ //! Common types used by most newlib platforms -use crate::off_t; +#[allow(unused_imports)] // needed for platforms that don't use the prelude here use crate::prelude::*; s! { + #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] pub struct sigset_t { - #[cfg(target_os = "horizon")] - __val: [c_ulong; 16], - #[cfg(not(target_os = "horizon"))] __val: u32, } + #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -19,7 +18,7 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - pub st_size: off_t, + pub st_size: crate::off_t, pub st_atime: crate::time_t, pub st_spare1: c_long, pub st_mtime: crate::time_t, @@ -31,6 +30,7 @@ s! { pub st_spare4: [c_long; 2usize], } + #[cfg(not(target_os = "vita"))] pub struct dirent { pub d_ino: crate::ino_t, pub d_type: c_uchar, diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index 3958e02734ada..ac500b1c79a32 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -28,6 +28,12 @@ s! { pub h_addr_list: *mut *mut c_char, } + pub struct pollfd { + pub fd: c_int, + pub events: c_int, + pub revents: c_int, + } + pub struct sockaddr { pub sa_family: crate::sa_family_t, pub sa_data: [c_char; 26usize], @@ -141,9 +147,6 @@ pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; pub const SOL_CONFIG: c_uint = 65534; -pub const _SC_PAGESIZE: c_int = 8; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; - pub const PTHREAD_STACK_MIN: size_t = 4096; pub const WNOHANG: c_int = 1; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 6b68a06cb0624..ea325dfee8431 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -64,21 +64,6 @@ cfg_if! { } } -cfg_if! { - if #[cfg(not(target_os = "horizon"))] { - s! { - pub struct hostent { - pub h_name: *mut c_char, - pub h_aliases: *mut *mut c_char, - pub h_addrtype: c_int, - pub h_length: c_int, - pub h_addr_list: *mut *mut c_char, - pub h_addr: *mut c_char, - } - } - } -} - s! { // The order of the `ai_addr` field in this struct is crucial // for converting between the Rust and C types. @@ -108,21 +93,10 @@ s! { pub imr_interface: in_addr, } - pub struct linger { - pub l_onoff: c_int, - pub l_linger: c_int, - } - pub struct in_addr { pub s_addr: crate::in_addr_t, } - pub struct pollfd { - pub fd: c_int, - pub events: c_int, - pub revents: c_int, - } - pub struct lconv { pub decimal_point: *mut c_char, pub thousands_sep: *mut c_char, diff --git a/src/unix/newlib/rtems/mod.rs b/src/unix/newlib/rtems/mod.rs index 0e23352744149..ec4534e32a11f 100644 --- a/src/unix/newlib/rtems/mod.rs +++ b/src/unix/newlib/rtems/mod.rs @@ -73,8 +73,6 @@ pub const EAI_SERVICE: c_int = 9; pub const EAI_SYSTEM: c_int = 11; pub const EAI_OVERFLOW: c_int = 14; -pub const _SC_PAGESIZE: c_int = 8; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; pub const PTHREAD_STACK_MIN: size_t = 0; // sys/wait.h diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 2a456f47363d9..302601de96afd 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -164,8 +164,6 @@ pub const EAI_MEMORY: c_int = -10; pub const EAI_SYSTEM: c_int = -11; pub const EAI_OVERFLOW: c_int = -12; -pub const _SC_PAGESIZE: c_int = 8; -pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; pub const PTHREAD_STACK_MIN: size_t = 32 * 1024; pub const IP_HDRINCL: c_int = 2; From 1de6920c1ba9e01e8c8f1566204459a1e64c7364 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 26 Dec 2025 13:38:25 +0900 Subject: [PATCH 23/24] getitimer and setitimer for linux (backport ) (cherry picked from commit edd1b6167fd16691d371e6c5d3c4bd84b45c1f6a) --- src/unix/linux_like/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 291c2b634664b..2f1264dca48e3 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1881,6 +1881,17 @@ extern "C" { #[cfg(not(target_os = "l4re"))] pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__getitimer64")] + #[cfg_attr(musl32_time64, link_name = "__getitimer_time64")] + pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__setitimer64")] + #[cfg_attr(musl32_time64, link_name = "__setitimer_time64")] + pub fn setitimer( + which: c_int, + new_value: *const crate::itimerval, + old_value: *mut crate::itimerval, + ) -> c_int; + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; pub fn memalign(align: size_t, size: size_t) -> *mut c_void; From 1772e959b5383eeb33275c00738ab459d9e3aabb Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 21 Dec 2025 13:12:39 +0100 Subject: [PATCH 24/24] Add NAME_MAX for Linux (like) (backport ) (cherry picked from commit 9cbb6ff34cda2124fe51d388e41b34a1ca0e39ae) --- libc-test/semver/linux.txt | 1 + src/unix/linux_like/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 1670cf76c057c..f3cca5611ee4d 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -1751,6 +1751,7 @@ MS_SLAVE MS_STRICTATIME MS_SYNCHRONOUS MS_UNBINDABLE +NAME_MAX NDA_CACHEINFO NDA_DST NDA_IFINDEX diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 2f1264dca48e3..3ded4da44df91 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1001,6 +1001,7 @@ pub const LOCK_UN: c_int = 8; pub const SS_ONSTACK: c_int = 1; pub const SS_DISABLE: c_int = 2; +pub const NAME_MAX: c_int = 255; pub const PATH_MAX: c_int = 4096; pub const UIO_MAXIOV: c_int = 1024;