From 2cb3892b9869cb1532e9531bcd485b788a618601 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 3 Apr 2025 07:30:24 +0000 Subject: [PATCH 01/36] ci: Add a job to ensure documentation succeeds This is a cherry pick of 1b08efd83ae0 ("Increase the recursion limit to fix docs.rs `ctest`") but we don't need the ctest bit, only the docs build. So, in essence: (backport ) (cherry picked from commit 1b08efd83ae0493ff140ed89de3bc483494141e8) --- .github/workflows/ci.yaml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4014d75b0780..d818df745dd0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -281,6 +281,17 @@ jobs: export PATH=$HOME/.rust_solaris/bin:$PATH ./ci/run.sh ${{ matrix.target }} + docs: + name: Ensure docs build + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@master + - name: Install Rust + run: rustup update nightly --no-self-update && rustup default nightly + - uses: Swatinem/rust-cache@v2 + - run: cargo doc --workspace --no-deps + # One job that "summarizes" the success state of this pipeline. This can then be added to branch # protection, rather than having to add each job separately. success: @@ -292,8 +303,8 @@ jobs: - test_tier2 - test_tier2_vm - verify_build - - clippy - # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency + - docs + # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. if: always() # make sure this is never "skipped" From 6b1c04c6adc251769fd66374a179af9cd4f32eca Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 15:31:07 -0600 Subject: [PATCH 02/36] cleanup: Also use `s_no_extra_traits!` for private structs (backport ) (cherry picked from commit b4cb730fde5b8eb4b3f6d094753716f0a97c1aa1) --- .../bsd/freebsdlike/freebsd/freebsd11/b32.rs | 56 ++++++------- .../bsd/freebsdlike/freebsd/freebsd11/b64.rs | 54 ++++++------- src/unix/linux_like/android/mod.rs | 55 ++++++------- src/unix/linux_like/linux/gnu/mod.rs | 47 +++++------ src/unix/linux_like/linux/musl/mod.rs | 47 +++++------ src/unix/linux_like/linux/uclibc/mod.rs | 47 +++++------ src/unix/solarish/mod.rs | 81 ++++++------------- 7 files changed, 154 insertions(+), 233 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs index dca7d6ee7998..8a8f6b4f1012 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs @@ -1,37 +1,29 @@ use crate::off_t; use crate::prelude::*; -#[repr(C)] -#[derive(Debug)] -#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))] -pub struct stat { - 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, - 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_size: off_t, - pub st_blocks: crate::blkcnt_t, - pub st_blksize: crate::blksize_t, - pub st_flags: crate::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: crate::time_t, - pub st_birthtime_nsec: c_long, - __unused: [u8; 8], -} - -impl Copy for crate::stat {} -impl Clone for crate::stat { - fn clone(&self) -> crate::stat { - *self +s! { + pub struct stat { + 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, + 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_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + __unused: [u8; 8], } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs index 1f31aac0e3d3..9e80a792a8c7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs @@ -1,36 +1,28 @@ use crate::off_t; use crate::prelude::*; -#[repr(C)] -#[derive(Debug)] -#[cfg_attr(feature = "extra_traits", derive(Eq, Hash, PartialEq))] -pub struct stat { - 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, - 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_size: off_t, - pub st_blocks: crate::blkcnt_t, - pub st_blksize: crate::blksize_t, - pub st_flags: crate::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: crate::time_t, - pub st_birthtime_nsec: c_long, -} - -impl Copy for crate::stat {} -impl Clone for crate::stat { - fn clone(&self) -> crate::stat { - *self +s! { + pub struct stat { + 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, + 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_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index e942bedfbdb1..8e50af515364 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -630,6 +630,29 @@ s_no_extra_traits! { pub ifc_len: c_int, /* Size of buffer. */ pub ifc_ifcu: __c_anonymous_ifc_ifcu, } + + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } cfg_if! { @@ -3860,38 +3883,6 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } -} - -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} - -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, -} - impl siginfo_t { unsafe fn sifields(&self) -> &sifields { &(*(self as *const siginfo_t as *const siginfo_f)).sifields diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 3aae0164cab0..61ccee3e7523 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -422,36 +422,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 793af6eb5be3..c835ddbde299 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -63,36 +63,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 4fef82ed8e16..69f1b006e1c0 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -181,36 +181,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 4f8fd105d57a..1e5fc221296c 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -668,71 +668,38 @@ cfg_if! { } } -#[repr(C)] -struct siginfo_fault { - addr: *mut c_void, - trapno: c_int, - pc: *mut crate::caddr_t, -} -impl Copy for siginfo_fault {} -impl Clone for siginfo_fault { - fn clone(&self) -> Self { - *self +s_no_extra_traits! { + struct siginfo_fault { + addr: *mut c_void, + trapno: c_int, + pc: *mut crate::caddr_t, } -} -#[repr(C)] -struct siginfo_cldval { - utime: crate::clock_t, - status: c_int, - stime: crate::clock_t, -} -impl Copy for siginfo_cldval {} -impl Clone for siginfo_cldval { - fn clone(&self) -> Self { - *self + struct siginfo_cldval { + utime: crate::clock_t, + status: c_int, + stime: crate::clock_t, } -} -#[repr(C)] -struct siginfo_killval { - uid: crate::uid_t, - value: crate::sigval, - // Pad out to match the SIGCLD value size - _pad: *mut c_void, -} -impl Copy for siginfo_killval {} -impl Clone for siginfo_killval { - fn clone(&self) -> Self { - *self + struct siginfo_killval { + uid: crate::uid_t, + value: crate::sigval, + // Pad out to match the SIGCLD value size + _pad: *mut c_void, } -} -#[repr(C)] -struct siginfo_sigcld { - pid: crate::pid_t, - val: siginfo_cldval, - ctid: crate::ctid_t, - zoneid: crate::zoneid_t, -} -impl Copy for siginfo_sigcld {} -impl Clone for siginfo_sigcld { - fn clone(&self) -> Self { - *self + struct siginfo_sigcld { + pid: crate::pid_t, + val: siginfo_cldval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, } -} -#[repr(C)] -struct siginfo_kill { - pid: crate::pid_t, - val: siginfo_killval, - ctid: crate::ctid_t, - zoneid: crate::zoneid_t, -} -impl Copy for siginfo_kill {} -impl Clone for siginfo_kill { - fn clone(&self) -> Self { - *self + struct siginfo_kill { + pid: crate::pid_t, + val: siginfo_killval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, } } From 0dd9097473077a7330d1d5e604ef29a18bb6f885 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 4 Nov 2025 01:28:20 -0600 Subject: [PATCH 03/36] ci: Make clippy a required job This was part of e09683ea3523 ("run clippy on 3 major platforms"), most of which made it to libc-0.2. However, this line was missed. --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d818df745dd0..b211fe430c62 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -304,6 +304,7 @@ jobs: - test_tier2_vm - verify_build - docs + - clippy # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. From 54e9ea65d207a77b091b2e8ac0a33a5da3c8b2a7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 00:13:15 -0400 Subject: [PATCH 04/36] ci: Add testing for NetBSD The x86-64 NetBSD target is tier 2, so we can start testing it. (backport ) (cherry picked from commit d77b8e7ff828c5de46f94c9a6997ac2e3529fe89) --- .github/workflows/ci.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b211fe430c62..81fde8d6eafc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -261,6 +261,7 @@ jobs: matrix: include: - target: x86_64-pc-solaris + - target: x86_64-unknown-netbsd timeout-minutes: 25 steps: - uses: actions/checkout@v5 @@ -281,6 +282,26 @@ jobs: export PATH=$HOME/.rust_solaris/bin:$PATH ./ci/run.sh ${{ matrix.target }} + - name: Test on NetBSD + uses: vmactions/netbsd-vm@v1 + if: contains(matrix.target, 'netbsd') + with: + release: "10.1" + usesh: true + mem: 4096 + copyback: false + prepare: | + set -x + /usr/sbin/pkg_add curl + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + --profile minimal --default-toolchain nightly -y + run: | + set -x + . "$HOME/.cargo/env" + which rustc + rustc -Vv + ./ci/run.sh ${{ matrix.target }} + docs: name: Ensure docs build runs-on: ubuntu-24.04 From 2852a124f0ee05f42515a5ac3186e9eb99f477cd Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 21:55:36 -0600 Subject: [PATCH 05/36] Add `core::cfg` to the prelude This is not always present when we are building as `rustc-dep-of-std`. (backport ) (cherry picked from commit 919d0d4653d7d5aa73e00d2cdfe6e29a8ff1ee59) --- src/macros.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/macros.rs b/src/macros.rs index eec90c7e44cc..c6001e7bc37c 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -87,6 +87,7 @@ macro_rules! prelude { pub(crate) use core::prelude::v1::derive; #[allow(unused_imports)] pub(crate) use core::{ + cfg, fmt, hash, iter, From 954f92258364a825dfdd8ad2b3aa548b0782da61 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 16:21:17 -0600 Subject: [PATCH 06/36] test: Factor out a fallible command runner This pattern is currently used by the `freebsd-version` check but will be used by more in the future. (backport ) (cherry picked from commit 91f208c61eb684c9ec5a5666f0dcd9168c7b5f2e) --- libc-test/build.rs | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c31fa7e3fb5d..22f1341c92ed 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2286,7 +2286,21 @@ fn test_freebsd(target: &str) { assert!(target.contains("freebsd")); let mut cfg = ctest_cfg(); - let freebsd_ver = which_freebsd(); + let freebsd_ver = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { + let vers = version.parse().unwrap(); + println!("cargo:warning=setting FreeBSD version to {vers}"); + Some(vers) + } else { + match &try_command_output("freebsd-version", &[]) { + Some(s) if s.starts_with("10") => Some(10), + Some(s) if s.starts_with("11") => Some(11), + Some(s) if s.starts_with("12") => Some(12), + Some(s) if s.starts_with("13") => Some(13), + Some(s) if s.starts_with("14") => Some(14), + Some(s) if s.starts_with("15") => Some(15), + Some(_) | None => None, + } + }; match freebsd_ver { Some(12) => cfg.cfg("freebsd12", None), @@ -4905,34 +4919,6 @@ fn test_linux_like_apis(target: &str) { } } -fn which_freebsd() -> Option { - if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { - let vers = version.parse().unwrap(); - println!("cargo:warning=setting FreeBSD version to {vers}"); - return Some(vers); - } - - let output = std::process::Command::new("freebsd-version") - .output() - .ok()?; - - if !output.status.success() { - return None; - } - - let stdout = String::from_utf8(output.stdout).ok()?; - - match &stdout { - s if s.starts_with("10") => Some(10), - s if s.starts_with("11") => Some(11), - s if s.starts_with("12") => Some(12), - s if s.starts_with("13") => Some(13), - s if s.starts_with("14") => Some(14), - s if s.starts_with("15") => Some(15), - _ => None, - } -} - fn test_haiku(target: &str) { assert!(target.contains("haiku")); @@ -5573,3 +5559,17 @@ fn test_aix(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } + +/// Attempt to execute a command and collect its output, If the command fails for whatever +/// reason, return `None`. +fn try_command_output(cmd: &str, args: &[&str]) -> Option { + let output = std::process::Command::new(cmd).args(args).output().ok()?; + + if !output.status.success() { + return None; + } + + let res = String::from_utf8(output.stdout) + .unwrap_or_else(|e| panic!("command {cmd} returned non-UTF-8 output: {e}")); + Some(res) +} From daa0137299e8b6f567d3b91adefd870966a1ec31 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 04:18:59 -0400 Subject: [PATCH 07/36] NetBSD: Delete items from the semver file that don't exist Some of these may have been removed. `NI_MAXHOST` is already specified in the unix semver file. (backport ) (cherry picked from commit 60d7cccb442a3c59d2d76f6305ba1784181d30ba) --- libc-test/semver/netbsd.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index bcd25eca15b9..58d581b7cb4f 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -93,7 +93,6 @@ AT_SUN_IFLUSH AT_SUN_LDELF AT_SUN_LDNAME AT_SUN_LDSHDR -AT_SUN_LPGSIZE AT_SUN_PLATFORM AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW @@ -734,7 +733,6 @@ NET_RT_OOIFLIST NET_RT_OOOIFLIST NEW_TIME NI_DGRAM -NI_MAXHOST NI_MAXSERV NI_NAMEREQD NI_NOFQDN @@ -845,7 +843,6 @@ POSIX_SPAWN_RETURNERROR POSIX_SPAWN_SETPGROUP POSIX_SPAWN_SETSCHEDPARAM POSIX_SPAWN_SETSCHEDULER -POSIX_SPAWN_SETSIGDEP POSIX_SPAWN_SETSIGMASK PROT_MPROTECT PTHREAD_CREATE_DETACHED @@ -1342,7 +1339,6 @@ futimes getbootfile getbyteorder getdiskrawname -getdistcookedname getdomainname getdtablesize getentropy @@ -1422,7 +1418,6 @@ lcong48 lgetxattr lio_listio listxattr -llistxaatr localeconv_l lockf login From cd8d023288a8d54c08fc79eb0d94e0c217faf63b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 17:20:33 -0600 Subject: [PATCH 08/36] NetBSD: riscv64: Fix the mcontext types Currently this target fails to build. (backport ) (cherry picked from commit 368df02c8d8b04f688e8de3a2a5c4338f72d8f10) --- src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 47240cb2818c..8cacb7250edd 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -1,16 +1,15 @@ -use PT_FIRSTMACH; - use crate::prelude::*; +use crate::PT_FIRSTMACH; pub type __greg_t = u64; pub type __cpu_simple_lock_nv_t = c_int; pub type __gregset = [__greg_t; _NGREG]; -pub type __fregset = [__freg; _NFREG]; +pub type __fregset = [__fpreg; _NFREG]; s! { pub struct mcontext_t { pub __gregs: __gregset, - pub __fregs: __fpregset, + pub __fregs: __fregset, __spare: [crate::__greg_t; 7], } } @@ -22,6 +21,22 @@ s_no_extra_traits! { } } +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __fpreg { + fn eq(&self, other: &Self) -> bool { + unsafe { self.u_u64 == other.u_u64 } + } + } + impl Eq for __fpreg {} + impl hash::Hash for __fpreg { + fn hash(&self, state: &mut H) { + unsafe { self.u_u64.hash(state) }; + } + } + } +} + pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; From 4d702f4dc7bd7dcbd29cdf49fa162088c5ca47e1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 20:01:26 -0400 Subject: [PATCH 09/36] NetBSD: Update test headers and skips Add headers required for the new constants we have, add skips for things we can't easily fix, and remove skips for things that now work. Additionally, check the NetBSD version via `uname` for configuring skips based on the tested version. (backport ) (cherry picked from commit 5634c88449febdd2d722bf2008bfc29503751053) --- libc-test/build.rs | 86 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 22f1341c92ed..91f726aa48f5 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1254,6 +1254,12 @@ fn test_netbsd(target: &str) { assert!(target.contains("netbsd")); let mut cfg = ctest_cfg(); + // Assume netbsd10 but check for netbsd9 for test config. + let netbsd9 = match try_command_output("uname", &["-sr"]) { + Some(s) if s.starts_with("NetBSD 9.") => true, + _ => false, + }; + cfg.flag("-Wno-deprecated-declarations"); cfg.define("_NETBSD_SOURCE", Some("1")); @@ -1280,10 +1286,12 @@ fn test_netbsd(target: &str) { "ctype.h", "dirent.h", "dlfcn.h", + "execinfo.h", "glob.h", "grp.h", "ifaddrs.h", "langinfo.h", + "lwp.h", "net/bpf.h", "net/if.h", "net/if_arp.h", @@ -1302,12 +1310,14 @@ fn test_netbsd(target: &str) { "sched.h", "semaphore.h", "signal.h", + "spawn.h", "string.h", "sys/endian.h", "sys/exec_elf.h", "sys/xattr.h", "sys/extattr.h", "sys/file.h", + (!netbsd9, "sys/futex.h"), "sys/ioctl.h", "sys/ioctl_compat.h", "sys/ipc.h", @@ -1315,12 +1325,15 @@ fn test_netbsd(target: &str) { "sys/mman.h", "sys/mount.h", "sys/ptrace.h", + (!netbsd9, "sys/random.h"), "sys/resource.h", + "sys/sched.h", "sys/shm.h", "sys/socket.h", "sys/statvfs.h", "sys/sysctl.h", "sys/time.h", + (!netbsd9, "sys/timerfd.h"), "sys/times.h", "sys/timex.h", "sys/ucontext.h", @@ -1343,6 +1356,8 @@ fn test_netbsd(target: &str) { "sys/reboot.h", "sys/shm.h", "iconv.h", + "utmp.h", + "utmpx.h", ); cfg.rename_type(move |ty| { @@ -1375,10 +1390,14 @@ fn test_netbsd(target: &str) { } }); + cfg.alias_is_c_enum(|ty| ty == "fae_action"); + cfg.skip_alias(move |ty| { match ty.ident() { // FIXME(netbsd): sighandler_t is crazy across platforms "sighandler_t" => true, + // Incomplete type in C + "cpuset_t" => true, _ => false, } }); @@ -1390,6 +1409,10 @@ fn test_netbsd(target: &str) { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. "termios2" => true, + // Anon struct + "__exit_status" => true, + // FIXME(netbsd): Should be importable but aren't for some reason. + "Aux32Info" | "Aux64Info" => true, _ => false, } }); @@ -1415,6 +1438,10 @@ fn test_netbsd(target: &str) { "BOTHER" => true, "GRND_RANDOM" | "GRND_INSECURE" | "GRND_NONBLOCK" => true, // netbsd 10 minimum + // Due to the NetBSD `__BIT` macro this turns out to be an `unsigned long`, but + // the futex syscall takes `int` ops. + "FUTEX_CMD_MASK" => true, + _ => false, } }); @@ -1422,14 +1449,10 @@ fn test_netbsd(target: &str) { cfg.skip_fn(move |func| { #[expect(clippy::wildcard_in_or_patterns)] match func.ident() { - // FIXME(netbsd): netbsd 10 minimum // FIXME(netbsd): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - "getentropy" | "getrandom" => true, - - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg + // FIXME(netbsd): Look into setting `_POSIX_C_SOURCE` to enable this + "qsort_r" => true, _ => false, } @@ -1453,10 +1476,61 @@ fn test_netbsd(target: &str) { ("Elf64_Phdr", "p_type") => true, // pthread_spin_t is a volatile uchar ("pthread_spinlock_t", "pts_spin") => true, + + // `tcp_snd_wscale` and `tcp_rcv_wscale` are bitfields + ("tcp_info", "tcp_snd_wscale") => true, + ("tcp_info", "tcp_rcv_wscale") => true, + + // Anonymous unions + ("ifconf", "ifc_ifcu") => true, + ("utmpx", "ut_exit") => true, + ("posix_spawn_file_actions_entry_t", "fae_data") => true, + _ => false, } }); + // Unless otherwise noted, everything in this block was an addition in NetBS 10. + if netbsd9 { + cfg.skip_const(move |constant| match constant.ident() { + "EOWNERDEAD" + | "ENOTRECOVERABLE" + | "F_GETPATH" + | "MNT_NFS4ACLS" + | "MNT_POSIX1EACLS" + | "MNT_ACLS" + | "EVFILT_USER" + | "EVFILT_EMPTY" + | "REG_ILLSEQ" + | "PT_SET_SIGPASS" + | "PT_GET_SIGPASS" + | "EXTATTR_NAMESPACE_EMPTY" => true, + x if x.starts_with("FUTEX") => true, + x if x.starts_with("NOTE_") => true, + x if x.starts_with("PT_LWP") => true, + x if x.starts_with("TFD_") => true, + "ELAST" => true, // not version-stable + _ => false, + }); + + cfg.skip_struct(move |struct_| match struct_.ident() { + x if x.starts_with("ptrace_lwp") => true, + _ => false, + }); + + cfg.skip_fn(move |func| match func.ident() { + "reallocarray" | "getentropy" | "ppoll" | "getrandom" => true, + x if x.starts_with("timerfd_") => true, + _ => false, + }); + + cfg.skip_struct_field(|struct_, field| match (struct_.ident(), field.ident()) { + ("statvfs", "f_mntfromlabel") => true, // added field + ("kevent", "udata") => true, // changed type (ABI-compatible) + _ => false, + }); + } + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } From 7ef85c23754868d00c01003ca0ddfc09f27864ef Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 19:27:16 -0600 Subject: [PATCH 10/36] NetBSD: Skip tests on 9.x for network structs with alignment mismatches These were previously packed, but this was changed in NetBSD10. Link: https://github.com/NetBSD/src/commit/1ca39e872702d4539e8844aff15593cf4c18a1cb (backport ) (cherry picked from commit 277c0c55786e85cd966d94ffa65ce172f97c54f1) --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 91f726aa48f5..4246d86874a1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1515,6 +1515,8 @@ fn test_netbsd(target: &str) { cfg.skip_struct(move |struct_| match struct_.ident() { x if x.starts_with("ptrace_lwp") => true, + // These were packed before NetBSD 10 + "arphdr" | "in_addr" | "ip_mreq" | "sockaddr_in" => true, _ => false, }); From 19aa077eb3f22b2c2dc0d20b1ca83df3e13a5106 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 20:25:22 -0400 Subject: [PATCH 11/36] NetBSD: Remove IFF_NOTRAILERS Upstream commit: https://github.com/NetBSD/src/commit/091e15265dbe2bb314cd3f15830a81f296d03f40 (backport ) (cherry picked from commit 35d5592a1f9e712220203ddff65a5dc63e95c1ba) --- libc-test/semver/netbsd.txt | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 58d581b7cb4f..af57ee5ea4d8 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -416,7 +416,6 @@ IFF_LINK2 IFF_LOOPBACK IFF_MULTICAST IFF_NOARP -IFF_NOTRAILERS IFF_OACTIVE IFF_POINTOPOINT IFF_PROMISC diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 2a360ca28af7..4a164cd023e8 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1118,7 +1118,6 @@ pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link -pub const IFF_NOTRAILERS: c_int = 0x0020; // avoid use of trailers pub const IFF_RUNNING: c_int = 0x0040; // resources allocated pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol pub const IFF_PROMISC: c_int = 0x0100; // receive all packets From d8ceb4fc07aa97505eabddef0b34adf82e3a4876 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 22:50:55 -0400 Subject: [PATCH 12/36] NetBSD: Remove `*_MAXID` constants and `AT_SUN_LDPGSIZE` These assorted constants may have existed at some point but I can't find any reference to them in the source repo. Remove them now. (backport ) (cherry picked from commit 17727db4414aa32f7ff2bf7465a5d154682cad16) --- libc-test/semver/netbsd.txt | 3 --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 4 ---- 2 files changed, 7 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index af57ee5ea4d8..ab4a8b1dbda1 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -179,7 +179,6 @@ CTL_HW CTL_IPPROTO_IPSEC CTL_KERN CTL_MACHDEP -CTL_MAXID CTL_MAXNAME CTL_MMAP CTL_NET @@ -532,7 +531,6 @@ KERN_LOGSIGEXIT KERN_LWP KERN_MAPPED_FILES KERN_MAXFILES -KERN_MAXID KERN_MAXPARTITIONS KERN_MAXPHYS KERN_MAXPROC @@ -726,7 +724,6 @@ NANOSECOND NET_RT_DUMP NET_RT_FLAGS NET_RT_IFLIST -NET_RT_MAXID NET_RT_OIFLIST NET_RT_OOIFLIST NET_RT_OOOIFLIST diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 4a164cd023e8..e3829bf81d95 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -977,7 +977,6 @@ pub const AT_RGID: c_int = 2003; pub const AT_SUN_LDELF: c_int = 2004; pub const AT_SUN_LDSHDR: c_int = 2005; pub const AT_SUN_LDNAME: c_int = 2006; -pub const AT_SUN_LDPGSIZE: c_int = 2007; pub const AT_SUN_PLATFORM: c_int = 2008; pub const AT_SUN_HWCAP: c_int = 2009; pub const AT_SUN_IFLUSH: c_int = 2010; @@ -1219,7 +1218,6 @@ pub const NET_RT_OOOIFLIST: c_int = 3; pub const NET_RT_OOIFLIST: c_int = 4; pub const NET_RT_OIFLIST: c_int = 5; pub const NET_RT_IFLIST: c_int = 6; -pub const NET_RT_MAXID: c_int = 7; pub const PF_OROUTE: c_int = AF_OROUTE; pub const PF_ARP: c_int = AF_ARP; @@ -1701,7 +1699,6 @@ pub const CTL_PROC: c_int = 10; pub const CTL_VENDOR: c_int = 11; pub const CTL_EMUL: c_int = 12; pub const CTL_SECURITY: c_int = 13; -pub const CTL_MAXID: c_int = 14; pub const KERN_OSTYPE: c_int = 1; pub const KERN_OSRELEASE: c_int = 2; pub const KERN_OSREV: c_int = 3; @@ -1786,7 +1783,6 @@ pub const KERN_ARND: c_int = 81; pub const KERN_SYSVIPC: c_int = 82; pub const KERN_BOOTTIME: c_int = 83; pub const KERN_EVCNT: c_int = 84; -pub const KERN_MAXID: c_int = 85; pub const KERN_PROC_ALL: c_int = 0; pub const KERN_PROC_PID: c_int = 1; pub const KERN_PROC_PGRP: c_int = 2; From 213f4b043410e4cd73356ca54afa2903187a5fe0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:40:25 -0400 Subject: [PATCH 13/36] NetBSD: Remove `vm_size_t` As noted, this has been deprecated a long time and is no longer present on x86_64. Remove the typedef. (backport ) (cherry picked from commit 11d36ae0efd967e52c9346778ae6ab70b505beae) --- libc-test/semver/netbsd.txt | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index ab4a8b1dbda1..c02af7ccf5e2 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1647,6 +1647,5 @@ utmpxname utpname utrace uucred -vm_size_t wait4 waitid diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index e3829bf81d95..54f2c2b45652 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -13,7 +13,6 @@ pub type fsfilcnt_t = u64; pub type idtype_t = c_int; pub type mqd_t = c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; -pub type vm_size_t = crate::uintptr_t; // FIXME(deprecated): deprecated since long time pub type lwpid_t = c_uint; pub type shmatt_t = c_uint; pub type cpuid_t = c_ulong; From ba7b8100cd1317e6285033ee043864f1a1a4b817 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 21:29:36 -0400 Subject: [PATCH 14/36] NetBSD: Remove BPF constants These are currently incorrect, so remove them for now. If desired, they can be added back in the future using the `_IO*` functions. (backport ) (cherry picked from commit 7de84bf0842561b85752acc29fa49803c190c745) --- libc-test/semver/netbsd.txt | 18 ---------------- src/unix/bsd/mod.rs | 31 ++++++++++++++++----------- src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 ------ 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index c02af7ccf5e2..97c39c24f8cc 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -103,23 +103,6 @@ B460800 B7200 B76800 B921600 -BIOCFLUSH -BIOCGBLEN -BIOCGDLT -BIOCGETIF -BIOCGHDRCMPLT -BIOCGRSIG -BIOCGSEESENT -BIOCGSTATS -BIOCIMMEDIATE -BIOCPROMISC -BIOCSBLEN -BIOCSDLT -BIOCSETIF -BIOCSHDRCMPLT -BIOCSRSIG -BIOCSSEESENT -BIOCVERSION BOOT_TIME BUFSIZ BUS_ADRALN @@ -990,7 +973,6 @@ SIGINFO SIGIO SIGNATURE SIGSTKSZ -SIOCGIFADDR SOCKCREDSIZE SOCK_CLOEXEC SOCK_CONN_DGRAM diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 2916d821a4d6..9b203f96eddc 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -398,19 +398,24 @@ pub const POLLWRNORM: c_short = 0x004; pub const POLLRDBAND: c_short = 0x080; pub const POLLWRBAND: c_short = 0x100; -pub const BIOCGBLEN: c_ulong = 0x40044266; -pub const BIOCSBLEN: c_ulong = 0xc0044266; -pub const BIOCFLUSH: c_uint = 0x20004268; -pub const BIOCPROMISC: c_uint = 0x20004269; -pub const BIOCGDLT: c_ulong = 0x4004426a; -pub const BIOCGETIF: c_ulong = 0x4020426b; -pub const BIOCSETIF: c_ulong = 0x8020426c; -pub const BIOCGSTATS: c_ulong = 0x4008426f; -pub const BIOCIMMEDIATE: c_ulong = 0x80044270; -pub const BIOCVERSION: c_ulong = 0x40044271; -pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; -pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; -pub const SIOCGIFADDR: c_ulong = 0xc0206921; +cfg_if! { + // Not yet implemented on NetBSD + if #[cfg(not(any(target_os = "netbsd")))] { + pub const BIOCGBLEN: c_ulong = 0x40044266; + pub const BIOCSBLEN: c_ulong = 0xc0044266; + pub const BIOCFLUSH: c_uint = 0x20004268; + pub const BIOCPROMISC: c_uint = 0x20004269; + pub const BIOCGDLT: c_ulong = 0x4004426a; + pub const BIOCGETIF: c_ulong = 0x4020426b; + pub const BIOCSETIF: c_ulong = 0x8020426c; + pub const BIOCGSTATS: c_ulong = 0x4008426f; + pub const BIOCIMMEDIATE: c_ulong = 0x80044270; + pub const BIOCVERSION: c_ulong = 0x40044271; + pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; + pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; + pub const SIOCGIFADDR: c_ulong = 0xc0206921; + } +} pub const REG_BASIC: c_int = 0o0000; pub const REG_EXTENDED: c_int = 0o0001; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 54f2c2b45652..445dffb44af7 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1403,12 +1403,6 @@ pub const FD_SETSIZE: usize = 0x100; pub const ST_NOSUID: c_ulong = 8; -pub const BIOCGRSIG: c_ulong = 0x40044272; -pub const BIOCSRSIG: c_ulong = 0x80044273; -pub const BIOCSDLT: c_ulong = 0x80044278; -pub const BIOCGSEESENT: c_ulong = 0x40044276; -pub const BIOCSSEESENT: c_ulong = 0x80044277; - // pub const MNT_UNION: c_int = 0x00000020; pub const MNT_NOCOREDUMP: c_int = 0x00008000; From d1143f5918ee2913a47df9fe69d33f65c460394d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 20:31:28 -0400 Subject: [PATCH 15/36] NetBSD: Replace REG_ENOSYS with REG_ILLSEQ Upstream commit: https://github.com/NetBSD/src/commit/cc8bab3745d49df3be13e903212f10c5fbee6c75 (backport ) (cherry picked from commit b038f178e2aad9ed4cbf2f2dda6b4b4ae926916a) --- libc-test/semver/netbsd.txt | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 97c39c24f8cc..1f2a04c67863 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -884,7 +884,6 @@ REG_ECOLLATE REG_ECTYPE REG_EESCAPE REG_EMPTY -REG_ENOSYS REG_EPAREN REG_ERANGE REG_ESPACE diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 445dffb44af7..b626dd1da894 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1882,7 +1882,7 @@ pub const FIBMAP: c_ulong = 0xc008667a; pub const SIGSTKSZ: size_t = 40960; -pub const REG_ENOSYS: c_int = 17; +pub const REG_ILLSEQ: c_int = 17; pub const PT_DUMPCORE: c_int = 12; pub const PT_LWPINFO: c_int = 13; From 84c1b75fb23f81e0ada69bd3f58c5e740e8d4609 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:05:52 -0400 Subject: [PATCH 16/36] NetBSD: Fix `uucred.cr_ngroups` from `int` to `short` Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/ucred.h#L52 (backport ) (cherry picked from commit 3bb84ebc5566637ddb2c03b90f13d5af91066ab8) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index b626dd1da894..54f2cc740fc9 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -395,7 +395,7 @@ s! { pub cr_unused: c_ushort, pub cr_uid: crate::uid_t, pub cr_gid: crate::gid_t, - pub cr_ngroups: c_int, + pub cr_ngroups: c_short, pub cr_groups: [crate::gid_t; NGROUPS_MAX as usize], } From 04cd0d2d9a6d3734a598503fe9bff1031f025308 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:28:15 -0400 Subject: [PATCH 17/36] NetBSD: Fix the type of `kevent.udata` This changed in 10.0. The change is ABI-compatible so we can make it now. This is a minor break, but should allow users to remove some special casing on NetBSD since this brings it in line with other BSDs. Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/event.h#L72 (backport ) (cherry picked from commit 14f2bc5a1cfff354871167468d802f6fe2ca53a8) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 54f2cc740fc9..3c6415a78bf9 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -300,8 +300,7 @@ s! { pub flags: u32, pub fflags: u32, pub data: i64, - // FIXME(netbsd): NetBSD 10.0 will finally have same layout as other BSD - pub udata: intptr_t, + pub udata: *mut c_void, } pub struct dqblk { From 423d634768271c385d1d0700db9c319a0ddce0fc Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 22:21:00 -0400 Subject: [PATCH 18/36] NetBSD: Fix the value of `PT_SUSPEND` Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/ptrace.h#L62 (backport ) (cherry picked from commit 5e47663bc529af1c1aac82f5362ce284310d696b) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 3c6415a78bf9..29c1ebc46391 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1893,7 +1893,7 @@ pub const PT_GET_PROCESS_STATE: c_int = 18; pub const PT_SET_SIGINFO: c_int = 19; pub const PT_GET_SIGINFO: c_int = 20; pub const PT_RESUME: c_int = 21; -pub const PT_SUSPEND: c_int = 23; +pub const PT_SUSPEND: c_int = 22; pub const PT_STOP: c_int = 23; pub const PT_LWPSTATUS: c_int = 24; pub const PT_LWPNEXT: c_int = 25; From e5958b812588167b113b9efcf81dc750013e10dd Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 16:44:16 -0400 Subject: [PATCH 19/36] NetBSD: Fix the values of FNM_* constants Link: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/fnmatch.h#L43-L48 (backport ) (cherry picked from commit cfb674c59dec21a10533c267b63859a45ef2eb92) --- src/unix/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 0de47f4e92b8..2d3dbaa5f7f6 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -351,7 +351,11 @@ cfg_if! { pub const FNM_NOMATCH: c_int = 1; cfg_if! { - if #[cfg(any(target_os = "illumos", target_os = "solaris",))] { + if #[cfg(any( + target_os = "illumos", + target_os = "solaris", + target_os = "netbsd" + ))] { pub const FNM_CASEFOLD: c_int = 1 << 3; } else if #[cfg(not(target_os = "aix"))] { pub const FNM_CASEFOLD: c_int = 1 << 4; @@ -365,6 +369,7 @@ cfg_if! { target_os = "android", target_os = "openbsd", target_os = "cygwin", + target_os = "netbsd", ))] { pub const FNM_PATHNAME: c_int = 1 << 1; } else { @@ -378,6 +383,7 @@ cfg_if! { target_os = "freebsd", target_os = "android", target_os = "openbsd", + target_os = "netbsd", ))] { pub const FNM_NOESCAPE: c_int = 1 << 0; } else if #[cfg(target_os = "nto")] { From 9f3474954f23011da8b84e68ad5f21b9673d842d Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:23:29 -0400 Subject: [PATCH 20/36] NetBSD: Fix the type of `mcontext_t.__fpregs` Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/arch/amd64/include/mcontext.h#L59-L65 (backport ) (cherry picked from commit a47db5328b888658adc97b263d4572863b5df7f0) --- src/unix/bsd/netbsdlike/netbsd/x86_64.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index 77daa4b1e9eb..801b326b70fa 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -4,11 +4,14 @@ use crate::PT_FIRSTMACH; pub type c___greg_t = u64; pub type __cpu_simple_lock_nv_t = c_uchar; +// FIXME(alignment): Type is `__aligned(8)` +type __fpregset_t = [c_char; 512]; + s! { pub struct mcontext_t { pub __gregs: [c___greg_t; 26], pub _mc_tlsbase: c___greg_t, - pub __fpregs: [[c_char; 32]; 16], + pub __fpregs: __fpregset_t, } pub struct ucontext_t { From 8490147c44a54bc9831fb1f731857993732fb9e2 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:09:54 -0400 Subject: [PATCH 21/36] NetBSD: Increase the size of `sockaddr_dl.sdl_data` from 12 to 24 Upstream commit: https://github.com/NetBSD/src/commit/a3d9e0f54ed964e4da9d6ef05c15f769c7bc2bc9 (backport ) (cherry picked from commit 8ff5e7e896f7608e60c1d71867d11017c09aeea6) --- libc-test/build.rs | 1 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4246d86874a1..e0f7fb2797dc 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1514,6 +1514,7 @@ fn test_netbsd(target: &str) { }); cfg.skip_struct(move |struct_| match struct_.ident() { + "sockaddr_dl" => true, // Last field increased size in 10 x if x.starts_with("ptrace_lwp") => true, // These were packed before NetBSD 10 "arphdr" | "in_addr" | "ip_mreq" | "sockaddr_in" => true, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 29c1ebc46391..8c3fe96ce3b4 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -412,7 +412,7 @@ s! { pub sdl_nlen: u8, pub sdl_alen: u8, pub sdl_slen: u8, - pub sdl_data: [c_char; 12], + pub sdl_data: [c_char; 24], } pub struct __exit_status { From ac8cd4177b330625b47b0a4ccffe4f7eaa5b735c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:35:46 -0400 Subject: [PATCH 22/36] NetBSD: Make `_cpuset` an extern type Our definition was correct for how it is defined internally, but in the header where it is included it is an incomplete definition. Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/sched.h#L99 (backport ) (cherry picked from commit 95e5cdbb0771dac53c0fe384180fa68a7339d4cd) --- src/unix/bsd/netbsdlike/netbsd/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 8c3fe96ce3b4..499d7bf71ce3 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -49,6 +49,10 @@ e! { } } +extern_ty! { + pub enum _cpuset {} +} + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -520,10 +524,6 @@ s! { pub dlpi_tls_data: *mut c_void, } - pub struct _cpuset { - bits: [u32; 0], - } - pub struct accept_filter_arg { pub af_name: [c_char; 16], af_arg: [c_char; 256 - 16], From 980cd403c5c29d5c2371da44de07dc598fdc4159 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 20:46:56 -0400 Subject: [PATCH 23/36] NetBSD: Account for upstream changes to ptrace with LWP Deprecate the PT_LWPINFO and PL_EVENT* constants, as well as `ptrace_lwpinfo`. Upstream commit: https://github.com/NetBSD/src/commit/4f79a484704c25ba5c21ab92911b2c71cf56a9dd (backport ) (cherry picked from commit c4a86e0c19a48b0df2eba4fc186e6bd919c813b8) --- libc-test/build.rs | 5 +++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index e0f7fb2797dc..5a20faa0a6d1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1413,6 +1413,8 @@ fn test_netbsd(target: &str) { "__exit_status" => true, // FIXME(netbsd): Should be importable but aren't for some reason. "Aux32Info" | "Aux64Info" => true, + // deprecated, obsolete upstream + "ptrace_lwpinfo" => true, _ => false, } }); @@ -1432,6 +1434,9 @@ fn test_netbsd(target: &str) { "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness "SIGUNUSED" => true, // removed in glibc 2.26 + // deprecated, obsolete upstream + "PT_LWPINFO" | "PL_EVENT_NONE" | "PL_EVENT_SIGNAL" | "PL_EVENT_SUSPENDED" => true, + // weird signed extension or something like that? "MS_NOUSER" => true, "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 499d7bf71ce3..a8b5d573a21e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -711,6 +711,7 @@ s! { pub fae: *mut posix_spawn_file_actions_entry_t, } + #[deprecated(since = "0.2.178", note = "obsolete upstream")] pub struct ptrace_lwpinfo { pub pl_lwpid: lwpid_t, pub pl_event: c_int, @@ -1502,8 +1503,11 @@ pub const TIME_ERROR: c_int = 5; pub const LITTLE_ENDIAN: c_int = 1234; pub const BIG_ENDIAN: c_int = 4321; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_NONE: c_int = 0; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_SIGNAL: c_int = 1; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_SUSPENDED: c_int = 2; cfg_if! { @@ -1884,6 +1888,7 @@ pub const SIGSTKSZ: size_t = 40960; pub const REG_ILLSEQ: c_int = 17; pub const PT_DUMPCORE: c_int = 12; +#[deprecated(note = "obsolete operation")] pub const PT_LWPINFO: c_int = 13; pub const PT_SYSCALL: c_int = 14; pub const PT_SYSCALLEMU: c_int = 15; From 18ec7317057e6036d1ed678533aa72e9c220ce07 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 20:03:10 -0400 Subject: [PATCH 24/36] NetBSD: Introduce `statvfs.rs` Move statvfs types to the `new` module. Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/statvfs.h#L66-L101 (backport ) (cherry picked from commit c4731a0c308288626d83c6403a778c4c9328a59b) --- src/new/mod.rs | 2 ++ src/new/netbsd/mod.rs | 3 ++ src/new/netbsd/sys/mod.rs | 5 +++ src/new/netbsd/sys/statvfs.rs | 44 +++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 36 +--------------------- src/unix/mod.rs | 4 +-- 6 files changed, 57 insertions(+), 37 deletions(-) create mode 100644 src/new/netbsd/sys/mod.rs create mode 100644 src/new/netbsd/sys/statvfs.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 1846ada479fb..dded532dc800 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -182,6 +182,8 @@ cfg_if! { pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { pub use signal::*; + } else if #[cfg(target_os = "netbsd")] { + pub use sys::statvfs::*; } } diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs index b43e7aeb088d..73bdb8292d6e 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -1,5 +1,8 @@ //! NetBSD libc. //! +//! * Headers: +//! * Sys headers: //! * Manual pages: +pub(crate) mod sys; pub(crate) mod unistd; diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs new file mode 100644 index 000000000000..0ac2d2e2d876 --- /dev/null +++ b/src/new/netbsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/NetBSD/src/tree/trunk/sys/sys + +pub(crate) mod statvfs; diff --git a/src/new/netbsd/sys/statvfs.rs b/src/new/netbsd/sys/statvfs.rs new file mode 100644 index 000000000000..640f42a33b21 --- /dev/null +++ b/src/new/netbsd/sys/statvfs.rs @@ -0,0 +1,44 @@ +//! Header: `sys/statvfs.h` +//! +//! + +use crate::prelude::*; + +const _VFS_NAMELEN: usize = 32; +const _VFS_MNAMELEN: usize = 1024; + +s! { + pub struct statvfs { + pub f_flag: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_iosize: c_ulong, + + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_bresvd: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fresvd: crate::fsfilcnt_t, + + pub f_syncreads: u64, + pub f_syncwrites: u64, + + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + + pub f_fsidx: crate::fsid_t, + pub f_fsid: c_ulong, + pub f_namemax: c_ulong, + pub f_owner: crate::uid_t, + + pub f_spare: [u32; 4], + + pub f_fstypename: [c_char; _VFS_NAMELEN], + pub f_mntonname: [c_char; _VFS_MNAMELEN], + pub f_mntfromname: [c_char; _VFS_MNAMELEN], + } +} diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a8b5d573a21e..a3082e7d53cb 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -852,40 +852,6 @@ s! { pub d_name: [c_char; 512], } - pub struct statvfs { - pub f_flag: c_ulong, - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_iosize: c_ulong, - - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_bresvd: crate::fsblkcnt_t, - - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fresvd: crate::fsfilcnt_t, - - pub f_syncreads: u64, - pub f_syncwrites: u64, - - pub f_asyncreads: u64, - pub f_asyncwrites: u64, - - pub f_fsidx: crate::fsid_t, - pub f_fsid: c_ulong, - pub f_namemax: c_ulong, - pub f_owner: crate::uid_t, - - pub f_spare: [u32; 4], - - pub f_fstypename: [c_char; 32], - pub f_mntonname: [c_char; 1024], - pub f_mntfromname: [c_char; 1024], - } - pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, @@ -2460,7 +2426,7 @@ extern "C" { ) -> c_int; #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; - pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int; + pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int; // Added in `NetBSD` 10.0 pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 2d3dbaa5f7f6..c9cf903a0d3a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1543,9 +1543,9 @@ extern "C" { pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] - pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] - pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; + pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] pub fn sigemptyset(set: *mut sigset_t) -> c_int; From 381d494150ea2bb34794f05a2d841a8bf966292b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 27 Oct 2025 22:14:20 -0400 Subject: [PATCH 25/36] NetBSD: Make `statvfs.f_spare` non-public With NetBSD10 the type changes and fields get adjusted. Make the field nonpublic now to prepare for this change in the future. This is a minor breaking change but means that the NetBSD10 updates will not be breaking. Link: https://github.com/NetBSD/src/blob/6017cb90fd7d83ed6e45d93129b12d525978c2fa/sys/sys/statvfs.h#L94 (backport ) (cherry picked from commit d5f4354cf28a965d46876a1cf50e2896fbe1352d) --- src/new/netbsd/sys/statvfs.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/new/netbsd/sys/statvfs.rs b/src/new/netbsd/sys/statvfs.rs index 640f42a33b21..eee3766300ce 100644 --- a/src/new/netbsd/sys/statvfs.rs +++ b/src/new/netbsd/sys/statvfs.rs @@ -35,10 +35,13 @@ s! { pub f_namemax: c_ulong, pub f_owner: crate::uid_t, - pub f_spare: [u32; 4], + // This type is updated in a future version + f_spare: [u32; 4], pub f_fstypename: [c_char; _VFS_NAMELEN], pub f_mntonname: [c_char; _VFS_MNAMELEN], pub f_mntfromname: [c_char; _VFS_MNAMELEN], + // Added in NetBSD10 + // pub f_mntfromlabel: [c_char; _VFS_MNAMELEN], } } From 4c668976577d7d8e5b058b405f59be14568d801b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 19:02:28 -0600 Subject: [PATCH 26/36] NetBSD: Skip tests for structvfs on NetBSD10 This went through an ABI change with a symbol version in NetBSD10. Our version still works but tests don't pass. Link: https://github.com/NetBSD/src/commit/02cdd248ec8b17634bab40aa4f2e161a756d7fce (backport ) (cherry picked from commit bf0f52cccfbc716cff00931062cf8b6059486b2e) --- libc-test/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 5a20faa0a6d1..f1317446282f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1415,6 +1415,8 @@ fn test_netbsd(target: &str) { "Aux32Info" | "Aux64Info" => true, // deprecated, obsolete upstream "ptrace_lwpinfo" => true, + // ABI change in NetBSD10, with symbol versioning. + "statvfs" if !netbsd9 => true, _ => false, } }); From ea09f1528f092980caf5a30bbf1686edd8fad315 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 20:24:30 -0400 Subject: [PATCH 27/36] NetBSD: Correct `ipc_perm`, split from OpenBSD as `ipc.rs` The field ordering is incorrect on NetBSD. Move it to the `new` module for NetBSD and OpenBSD and fix the mismatch on NetBSD. Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/ipc.h#L54-L68 Link: https://github.com/openbsd/src/blob/9abc5df53d8ad6b65dbd35b89ed94f73e2fc58da/sys/sys/ipc.h#L53-L61 (backport ) (cherry picked from commit 066e702ac0a9e87f1cd46399122f4c64b6359faa) --- src/new/mod.rs | 3 +++ src/new/netbsd/sys/ipc.rs | 17 +++++++++++++++++ src/new/netbsd/sys/mod.rs | 1 + src/new/openbsd/mod.rs | 1 + src/new/openbsd/sys/ipc.rs | 17 +++++++++++++++++ src/new/openbsd/sys/mod.rs | 5 +++++ src/unix/bsd/netbsdlike/mod.rs | 16 ---------------- 7 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 src/new/netbsd/sys/ipc.rs create mode 100644 src/new/openbsd/sys/ipc.rs create mode 100644 src/new/openbsd/sys/mod.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index dded532dc800..9cb6e5b969fe 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -183,7 +183,10 @@ cfg_if! { } else if #[cfg(target_vendor = "apple")] { pub use signal::*; } else if #[cfg(target_os = "netbsd")] { + pub use sys::ipc::*; pub use sys::statvfs::*; + } else if #[cfg(target_os = "openbsd")] { + pub use sys::ipc::*; } } diff --git a/src/new/netbsd/sys/ipc.rs b/src/new/netbsd/sys/ipc.rs new file mode 100644 index 000000000000..49a1c84d7429 --- /dev/null +++ b/src/new/netbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub _seq: c_ushort, + pub _key: crate::key_t, + } +} diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs index 0ac2d2e2d876..7fab41736273 100644 --- a/src/new/netbsd/sys/mod.rs +++ b/src/new/netbsd/sys/mod.rs @@ -2,4 +2,5 @@ //! //! https://github.com/NetBSD/src/tree/trunk/sys/sys +pub(crate) mod ipc; pub(crate) mod statvfs; diff --git a/src/new/openbsd/mod.rs b/src/new/openbsd/mod.rs index d5debb80f392..25fa784b2b00 100644 --- a/src/new/openbsd/mod.rs +++ b/src/new/openbsd/mod.rs @@ -3,4 +3,5 @@ //! * Headers: //! * Manual pages: +pub(crate) mod sys; pub(crate) mod unistd; diff --git a/src/new/openbsd/sys/ipc.rs b/src/new/openbsd/sys/ipc.rs new file mode 100644 index 000000000000..59774405bcdd --- /dev/null +++ b/src/new/openbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mode: crate::mode_t, + pub seq: c_ushort, + pub key: crate::key_t, + } +} diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs new file mode 100644 index 000000000000..7ba77c537356 --- /dev/null +++ b/src/new/openbsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/openbsd/src/tree/trunk/sys/sys + +pub(crate) mod ipc; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index dc5e4528cf29..948e8d30248a 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -61,22 +61,6 @@ s! { pub l_whence: c_short, } - pub struct ipc_perm { - pub cuid: crate::uid_t, - pub cgid: crate::gid_t, - pub uid: crate::uid_t, - pub gid: crate::gid_t, - pub mode: mode_t, - #[cfg(target_os = "openbsd")] - pub seq: c_ushort, - #[cfg(target_os = "netbsd")] - pub _seq: c_ushort, - #[cfg(target_os = "openbsd")] - pub key: crate::key_t, - #[cfg(target_os = "netbsd")] - pub _key: crate::key_t, - } - pub struct ptrace_io_desc { pub piod_op: c_int, pub piod_offs: *mut c_void, From e8ba00e4fcdf650f7b14a29d268a35d2ec36cc42 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 20:43:58 -0400 Subject: [PATCH 28/36] NetBSD: Introduce `utmp_.rs`, correct the definition of `lastlog` The field order was incorrect. Update this and move it to `new`, along with the rest of `utmp`. As part of this, correct an incorrectly spelled `utpname` to `utmpname`. Fixes: 42289eb64f63 "Implement utmp for NetBSD" (backport ) (cherry picked from commit 6a01e2f2c2ef65fc41b1e9db27213eefa2dbe54b) --- libc-test/semver/netbsd.txt | 2 +- src/new/mod.rs | 1 + src/new/netbsd/mod.rs | 1 + src/new/netbsd/utmp_.rs | 32 +++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 27 +++------------------- 5 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 src/new/netbsd/utmp_.rs diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 1f2a04c67863..982f610a4f3a 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1623,9 +1623,9 @@ updwtmpx useconds_t utimensat utmp +utmpname utmpx utmpxname -utpname utrace uucred wait4 diff --git a/src/new/mod.rs b/src/new/mod.rs index 9cb6e5b969fe..e68f32724253 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -185,6 +185,7 @@ cfg_if! { } else if #[cfg(target_os = "netbsd")] { pub use sys::ipc::*; pub use sys::statvfs::*; + pub use utmp_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; } diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs index 73bdb8292d6e..337f9018c848 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -6,3 +6,4 @@ pub(crate) mod sys; pub(crate) mod unistd; +pub(crate) mod utmp_; diff --git a/src/new/netbsd/utmp_.rs b/src/new/netbsd/utmp_.rs new file mode 100644 index 000000000000..6179a7924f42 --- /dev/null +++ b/src/new/netbsd/utmp_.rs @@ -0,0 +1,32 @@ +//! Header: `utmp.h` +//! +//! + +use crate::prelude::*; + +pub const UT_NAMESIZE: usize = 8; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + +s! { + pub struct lastlog { + pub ll_time: crate::time_t, + pub ll_line: [c_char; UT_LINESIZE], + pub ll_host: [c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [c_char; UT_LINESIZE], + pub ut_name: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_time: crate::time_t, + } +} + +#[link(name = "util")] +extern "C" { + pub fn utmpname(file: *const c_char) -> c_int; + pub fn setutent(); + pub fn getutent() -> *mut utmp; + pub fn endutent(); +} diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a3082e7d53cb..ef389d032134 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -436,19 +436,6 @@ s! { _shm_internal: *mut c_void, } - pub struct utmp { - pub ut_line: [c_char; UT_LINESIZE], - pub ut_name: [c_char; UT_NAMESIZE], - pub ut_host: [c_char; UT_HOSTSIZE], - pub ut_time: crate::time_t, - } - - pub struct lastlog { - pub ll_line: [c_char; UT_LINESIZE], - pub ll_host: [c_char; UT_HOSTSIZE], - pub ll_time: crate::time_t, - } - pub struct timex { pub modes: c_uint, pub offset: c_long, @@ -1816,9 +1803,6 @@ pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDT // pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; // pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; // pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; -pub const UT_NAMESIZE: usize = 8; -pub const UT_LINESIZE: usize = 8; -pub const UT_HOSTSIZE: usize = 16; pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 40; @@ -2497,13 +2481,8 @@ extern "C" { pub fn setutxent(); pub fn endutxent(); - pub fn getutmp(ux: *const utmpx, u: *mut utmp); - pub fn getutmpx(u: *const utmp, ux: *mut utmpx); - - pub fn utpname(file: *const c_char) -> c_int; - pub fn setutent(); - pub fn endutent(); - pub fn getutent() -> *mut utmp; + pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); + pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE; pub fn emalloc(n: size_t) -> *mut c_void; @@ -2566,7 +2545,7 @@ extern "C" { precision: size_t, ) -> *mut c_char; #[link_name = "__login50"] - pub fn login(ut: *const utmp); + pub fn login(ut: *const crate::utmp); #[link_name = "__loginx50"] pub fn loginx(ut: *const utmpx); pub fn logout(line: *const c_char); From a9c8fc9124155bd9b37d05a4c29ccf31b43fdd99 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 22:17:32 -0400 Subject: [PATCH 29/36] NetBSD: Introduce `utmpx_.rs`, correct utmpx definitions Create a new module for `utmpx` and move definitions there, then correct `_UTX_PADSIZE`. We can also just use `s!`, there is no need to manually implement the traits. NetBSD defines `_UTX_PADSIZE` manually but includes this comment in their source: /* * This should be: * 40 - (sizeof(struct timeval) - sizeof(struct { long s; long u; }))) * but g++ does not like it, to retain size compatibility with v1.00, * so we do it manually. */ #ifdef _LP64 #define _UTX_PADSIZE 36 #else #define _UTX_PADSIZE 40 #endif I tried using the expression here: 40 - (size_of::() - size_of::<(c_long, c_long)>()); But this returns a value of 8 which doesn't match the expected 36. So, keep with their source and hardcode the values. Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/include/utmpx.h#L91-L101 (backport ) (cherry picked from commit 4055637d36dc795c71cea037066a42224eead2be) --- src/new/mod.rs | 1 + src/new/netbsd/mod.rs | 1 + src/new/netbsd/utmpx_.rs | 82 +++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 65 +-------------------- 4 files changed, 85 insertions(+), 64 deletions(-) create mode 100644 src/new/netbsd/utmpx_.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index e68f32724253..8bbcaba4f589 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -186,6 +186,7 @@ cfg_if! { pub use sys::ipc::*; pub use sys::statvfs::*; pub use utmp_::*; + pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; } diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs index 337f9018c848..070a544dae81 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -7,3 +7,4 @@ pub(crate) mod sys; pub(crate) mod unistd; pub(crate) mod utmp_; +pub(crate) mod utmpx_; diff --git a/src/new/netbsd/utmpx_.rs b/src/new/netbsd/utmpx_.rs new file mode 100644 index 000000000000..6b0762056de5 --- /dev/null +++ b/src/new/netbsd/utmpx_.rs @@ -0,0 +1,82 @@ +//! Header: `utmpx.h` +//! +//! + +use crate::prelude::*; + +// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; + +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + +// Expression based on the comment in NetBSD source. +pub const _UTX_PADSIZE: usize = if cfg!(target_pointer_width = "64") { + 36 +} else { + 40 +}; + +s! { + pub struct utmpx { + pub ut_name: [c_char; _UTX_USERSIZE], + pub ut_id: [c_char; _UTX_IDSIZE], + pub ut_line: [c_char; _UTX_LINESIZE], + pub ut_host: [c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: crate::pid_t, + pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported + pub ut_ss: crate::sockaddr_storage, + pub ut_tv: crate::timeval, + ut_pad: [u8; _UTX_PADSIZE], + } + + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + + pub struct lastlogx { + pub ll_tv: crate::timeval, + pub ll_line: [c_char; _UTX_LINESIZE], + pub ll_host: [c_char; _UTX_HOSTSIZE], + pub ll_ss: crate::sockaddr_storage, + } +} + +#[link(name = "util")] +extern "C" { + pub fn setutxent(); + pub fn endutxent(); + + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + + pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; + pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) + -> *mut lastlogx; + pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; + pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); + pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); + pub fn utmpxname(file: *const c_char) -> c_int; +} diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index ef389d032134..a8840bf628a1 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -419,11 +419,6 @@ s! { pub sdl_data: [c_char; 24], } - pub struct __exit_status { - pub e_termination: u16, - pub e_exit: u16, - } - pub struct shmid_ds { pub shm_perm: crate::ipc_perm, pub shm_segsz: size_t, @@ -780,27 +775,6 @@ s! { pub __tcpi_pad: [u32; 26], } - pub struct utmpx { - pub ut_name: [c_char; _UTX_USERSIZE], - pub ut_id: [c_char; _UTX_IDSIZE], - pub ut_line: [c_char; _UTX_LINESIZE], - pub ut_host: [c_char; _UTX_HOSTSIZE], - pub ut_session: u16, - pub ut_type: u16, - pub ut_pid: crate::pid_t, - pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported - pub ut_ss: sockaddr_storage, - pub ut_tv: crate::timeval, - pub ut_pad: [u8; _UTX_PADSIZE], - } - - pub struct lastlogx { - pub ll_tv: crate::timeval, - pub ll_line: [c_char; _UTX_LINESIZE], - pub ll_host: [c_char; _UTX_HOSTSIZE], - pub ll_ss: sockaddr_storage, - } - pub struct in_pktinfo { pub ipi_addr: crate::in_addr, pub ipi_ifindex: c_uint, @@ -1799,28 +1773,6 @@ pub const ONLRET: crate::tcflag_t = 0x40; pub const CDTRCTS: crate::tcflag_t = 0x00020000; pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDTRCTS; -// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; -// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; -// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; -// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; -pub const _UTX_USERSIZE: usize = 32; -pub const _UTX_LINESIZE: usize = 32; -pub const _UTX_PADSIZE: usize = 40; -pub const _UTX_IDSIZE: usize = 4; -pub const _UTX_HOSTSIZE: usize = 256; -pub const EMPTY: u16 = 0; -pub const RUN_LVL: u16 = 1; -pub const BOOT_TIME: u16 = 2; -pub const OLD_TIME: u16 = 3; -pub const NEW_TIME: u16 = 4; -pub const INIT_PROCESS: u16 = 5; -pub const LOGIN_PROCESS: u16 = 6; -pub const USER_PROCESS: u16 = 7; -pub const DEAD_PROCESS: u16 = 8; -pub const ACCOUNTING: u16 = 9; -pub const SIGNATURE: u16 = 10; -pub const DOWN_TIME: u16 = 11; - pub const SOCK_CLOEXEC: c_int = 0x10000000; pub const SOCK_NONBLOCK: c_int = 0x20000000; @@ -2469,21 +2421,6 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; - pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; - pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) - -> *mut lastlogx; - pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; - pub fn utmpxname(file: *const c_char) -> c_int; - pub fn getutxent() -> *mut utmpx; - pub fn getutxid(ut: *const utmpx) -> *mut utmpx; - pub fn getutxline(ut: *const utmpx) -> *mut utmpx; - pub fn pututxline(ut: *const utmpx) -> *mut utmpx; - pub fn setutxent(); - pub fn endutxent(); - - pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); - pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); - pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE; pub fn emalloc(n: size_t) -> *mut c_void; pub fn ecalloc(n: size_t, c: size_t) -> *mut c_void; @@ -2547,7 +2484,7 @@ extern "C" { #[link_name = "__login50"] pub fn login(ut: *const crate::utmp); #[link_name = "__loginx50"] - pub fn loginx(ut: *const utmpx); + pub fn loginx(ut: *const crate::utmpx); pub fn logout(line: *const c_char); pub fn logoutx(line: *const c_char, status: c_int, tpe: c_int); pub fn logwtmp(line: *const c_char, name: *const c_char, host: *const c_char); From 4ad79701f3582adf781c44c1bca04645471c5cf5 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 20:57:44 -0400 Subject: [PATCH 30/36] NetBSD: Introduce `types.rs`, correct the definition of `lwpid_t` This is currently defined as an `unsigned int` but should be `int32_t`. Also move some related definitions `new`. Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/types.h#L200 (backport ) (cherry picked from commit 29464834a1aecefcd1aa14b0a89f4c23d7ee4922) --- src/new/mod.rs | 1 + src/new/netbsd/sys/mod.rs | 1 + src/new/netbsd/sys/types.rs | 16 ++++++++++++++++ src/unix/bsd/netbsdlike/mod.rs | 3 ++- src/unix/bsd/netbsdlike/netbsd/mod.rs | 9 ++------- src/unix/mod.rs | 2 +- 6 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 src/new/netbsd/sys/types.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 8bbcaba4f589..41dcdea56bdc 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -185,6 +185,7 @@ cfg_if! { } else if #[cfg(target_os = "netbsd")] { pub use sys::ipc::*; pub use sys::statvfs::*; + pub use sys::types::*; pub use utmp_::*; pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs index 7fab41736273..46031de9eb4c 100644 --- a/src/new/netbsd/sys/mod.rs +++ b/src/new/netbsd/sys/mod.rs @@ -4,3 +4,4 @@ pub(crate) mod ipc; pub(crate) mod statvfs; +pub(crate) mod types; diff --git a/src/new/netbsd/sys/types.rs b/src/new/netbsd/sys/types.rs new file mode 100644 index 000000000000..8dfc04942617 --- /dev/null +++ b/src/new/netbsd/sys/types.rs @@ -0,0 +1,16 @@ +//! Header: `sys/types.h` +//! +//! + +use crate::prelude::*; + +pub type dev_t = u64; + +pub type lwpid_t = i32; + +pub type mqd_t = c_int; +pub type cpuid_t = c_ulong; + +pub type clock_t = c_uint; +pub type timer_t = c_int; +pub type suseconds_t = c_int; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 948e8d30248a..ee5371f4963e 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -704,7 +704,8 @@ extern "C" { pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) + -> c_int; pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a8840bf628a1..ef020a9fc092 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,24 +1,19 @@ use crate::prelude::*; use crate::{ cmsghdr, + cpuid_t, + lwpid_t, off_t, }; -pub type clock_t = c_uint; -pub type suseconds_t = c_int; -pub type dev_t = u64; pub type blksize_t = i32; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; pub type idtype_t = c_int; -pub type mqd_t = c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; -pub type lwpid_t = c_uint; pub type shmatt_t = c_uint; -pub type cpuid_t = c_ulong; pub type cpuset_t = _cpuset; pub type pthread_spin_t = c_uchar; -pub type timer_t = c_int; // elf.h diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c9cf903a0d3a..3e54201f1e19 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -60,7 +60,7 @@ s! { pub struct timeval { pub tv_sec: time_t, #[cfg(not(gnu_time_bits64))] - pub tv_usec: suseconds_t, + pub tv_usec: crate::suseconds_t, // For 64 bit time on 32 bit linux glibc, suseconds_t is still // a 32 bit type. Use __suseconds64_t instead #[cfg(gnu_time_bits64)] From 00a0290f1472b74b83ec08aa2dd904db4dad6241 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 21:44:59 -0400 Subject: [PATCH 31/36] NetBSD: Introduce `timex.rs` Move `timex.h` types to the `new/` module. (backport ) (cherry picked from commit fb74b6f9cafdc60afebcbf7016e34daf839d99c4) --- src/new/mod.rs | 1 + src/new/netbsd/sys/mod.rs | 1 + src/new/netbsd/sys/timex.rs | 94 +++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 80 ----------------------- 4 files changed, 96 insertions(+), 80 deletions(-) create mode 100644 src/new/netbsd/sys/timex.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 41dcdea56bdc..31a224cb67bf 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -185,6 +185,7 @@ cfg_if! { } else if #[cfg(target_os = "netbsd")] { pub use sys::ipc::*; pub use sys::statvfs::*; + pub use sys::timex::*; pub use sys::types::*; pub use utmp_::*; pub use utmpx_::*; diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs index 46031de9eb4c..395b82ebd680 100644 --- a/src/new/netbsd/sys/mod.rs +++ b/src/new/netbsd/sys/mod.rs @@ -4,4 +4,5 @@ pub(crate) mod ipc; pub(crate) mod statvfs; +pub(crate) mod timex; pub(crate) mod types; diff --git a/src/new/netbsd/sys/timex.rs b/src/new/netbsd/sys/timex.rs new file mode 100644 index 000000000000..d3c279726c39 --- /dev/null +++ b/src/new/netbsd/sys/timex.rs @@ -0,0 +1,94 @@ +//! Header: `sys/timex.h` +//! +//! + +use crate::prelude::*; + +pub const MAXPHASE: c_long = 500000000; +pub const MAXFREQ: c_long = 500000; +pub const MINSEC: c_int = 256; +pub const MAXSEC: c_int = 2048; +pub const NANOSECOND: c_long = 1000000000; +pub const SCALE_PPM: c_int = 65; +pub const MAXTC: c_int = 10; + +pub const MOD_OFFSET: c_uint = 0x0001; +pub const MOD_FREQUENCY: c_uint = 0x0002; +pub const MOD_MAXERROR: c_uint = 0x0004; +pub const MOD_ESTERROR: c_uint = 0x0008; +pub const MOD_STATUS: c_uint = 0x0010; +pub const MOD_TIMECONST: c_uint = 0x0020; +pub const MOD_PPSMAX: c_uint = 0x0040; +pub const MOD_TAI: c_uint = 0x0080; +pub const MOD_MICRO: c_uint = 0x1000; +pub const MOD_NANO: c_uint = 0x2000; +pub const MOD_CLKB: c_uint = 0x4000; +pub const MOD_CLKA: c_uint = 0x8000; + +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; + +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; + +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; + +s! { + pub struct ntptimeval { + pub time: crate::timespec, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub time_state: c_int, + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + } +} + +extern "C" { + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + pub fn ntp_adjtime(buf: *mut timex) -> c_int; +} diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index ef020a9fc092..a1163d8f0eab 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -426,34 +426,6 @@ s! { _shm_internal: *mut c_void, } - pub struct timex { - pub modes: c_uint, - pub offset: c_long, - pub freq: c_long, - pub maxerror: c_long, - pub esterror: c_long, - pub status: c_int, - pub constant: c_long, - pub precision: c_long, - pub tolerance: c_long, - pub ppsfreq: c_long, - pub jitter: c_long, - pub shift: c_int, - pub stabil: c_long, - pub jitcnt: c_long, - pub calcnt: c_long, - pub errcnt: c_long, - pub stbcnt: c_long, - } - - pub struct ntptimeval { - pub time: crate::timespec, - pub maxerror: c_long, - pub esterror: c_long, - pub tai: c_long, - pub time_state: c_int, - } - // elf.h pub struct Elf32_Phdr { @@ -1368,59 +1340,9 @@ pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> | (num) } -// pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; pub const NTP_API: c_int = 4; -pub const MAXPHASE: c_long = 500000000; -pub const MAXFREQ: c_long = 500000; -pub const MINSEC: c_int = 256; -pub const MAXSEC: c_int = 2048; -pub const NANOSECOND: c_long = 1000000000; -pub const SCALE_PPM: c_int = 65; -pub const MAXTC: c_int = 10; -pub const MOD_OFFSET: c_uint = 0x0001; -pub const MOD_FREQUENCY: c_uint = 0x0002; -pub const MOD_MAXERROR: c_uint = 0x0004; -pub const MOD_ESTERROR: c_uint = 0x0008; -pub const MOD_STATUS: c_uint = 0x0010; -pub const MOD_TIMECONST: c_uint = 0x0020; -pub const MOD_PPSMAX: c_uint = 0x0040; -pub const MOD_TAI: c_uint = 0x0080; -pub const MOD_MICRO: c_uint = 0x1000; -pub const MOD_NANO: c_uint = 0x2000; -pub const MOD_CLKB: c_uint = 0x4000; -pub const MOD_CLKA: c_uint = 0x8000; -pub const STA_PLL: c_int = 0x0001; -pub const STA_PPSFREQ: c_int = 0x0002; -pub const STA_PPSTIME: c_int = 0x0004; -pub const STA_FLL: c_int = 0x0008; -pub const STA_INS: c_int = 0x0010; -pub const STA_DEL: c_int = 0x0020; -pub const STA_UNSYNC: c_int = 0x0040; -pub const STA_FREQHOLD: c_int = 0x0080; -pub const STA_PPSSIGNAL: c_int = 0x0100; -pub const STA_PPSJITTER: c_int = 0x0200; -pub const STA_PPSWANDER: c_int = 0x0400; -pub const STA_PPSERROR: c_int = 0x0800; -pub const STA_CLOCKERR: c_int = 0x1000; -pub const STA_NANO: c_int = 0x2000; -pub const STA_MODE: c_int = 0x4000; -pub const STA_CLK: c_int = 0x8000; -pub const STA_RONLY: c_int = STA_PPSSIGNAL - | STA_PPSJITTER - | STA_PPSWANDER - | STA_PPSERROR - | STA_CLOCKERR - | STA_NANO - | STA_MODE - | STA_CLK; -pub const TIME_OK: c_int = 0; -pub const TIME_INS: c_int = 1; -pub const TIME_DEL: c_int = 2; -pub const TIME_OOP: c_int = 3; -pub const TIME_WAIT: c_int = 4; -pub const TIME_ERROR: c_int = 5; pub const LITTLE_ENDIAN: c_int = 1234; pub const BIG_ENDIAN: c_int = 4321; @@ -2001,8 +1923,6 @@ safe_f! { } extern "C" { - pub fn ntp_adjtime(buf: *mut timex) -> c_int; - pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; pub fn clock_nanosleep( clk_id: crate::clockid_t, flags: c_int, From b3d3fa131608752897cc70089c26f9a9acc9eef4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 28 Oct 2025 21:57:11 -0400 Subject: [PATCH 32/36] NetBSD: Introduce `time.rs`, fix the values of `CLOCK_*_CPUTIME_ID` Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/time.h#L305-L306 (backport ) (cherry picked from commit 57213d424db1eefa76750a99a99fef57e1667caf) --- src/new/mod.rs | 1 + src/new/netbsd/sys/mod.rs | 1 + src/new/netbsd/sys/time.rs | 13 +++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 13 +++---------- 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 src/new/netbsd/sys/time.rs diff --git a/src/new/mod.rs b/src/new/mod.rs index 31a224cb67bf..8d8644a7dae9 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -185,6 +185,7 @@ cfg_if! { } else if #[cfg(target_os = "netbsd")] { pub use sys::ipc::*; pub use sys::statvfs::*; + pub use sys::time::*; pub use sys::timex::*; pub use sys::types::*; pub use utmp_::*; diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs index 395b82ebd680..185c1f1c2cba 100644 --- a/src/new/netbsd/sys/mod.rs +++ b/src/new/netbsd/sys/mod.rs @@ -4,5 +4,6 @@ pub(crate) mod ipc; pub(crate) mod statvfs; +pub(crate) mod time; pub(crate) mod timex; pub(crate) mod types; diff --git a/src/new/netbsd/sys/time.rs b/src/new/netbsd/sys/time.rs new file mode 100644 index 000000000000..5f2d39d347e6 --- /dev/null +++ b/src/new/netbsd/sys/time.rs @@ -0,0 +1,13 @@ +//! Header: `sys/time.h` +//! +//! + +s! { + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } +} + +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 0x20000000; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 0x40000000; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a1163d8f0eab..7912df861b85 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -167,11 +167,6 @@ s! { pub mq_curmsgs: c_long, } - pub struct itimerspec { - pub it_interval: crate::timespec, - pub it_value: crate::timespec, - } - pub struct sigset_t { __bits: [u32; 4], } @@ -1340,8 +1335,6 @@ pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> | (num) } -pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; -pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; pub const NTP_API: c_int = 4; pub const LITTLE_ENDIAN: c_int = 1234; @@ -2281,12 +2274,12 @@ extern "C" { // Added in `NetBSD` 10.0 pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; - pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; pub fn timerfd_settime( fd: c_int, flags: c_int, - new_value: *const itimerspec, - old_value: *mut itimerspec, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, ) -> c_int; pub fn qsort_r( From 0eb105b73443fec3a0141510b39445e139870ae7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 29 Oct 2025 00:23:36 -0500 Subject: [PATCH 33/36] NetBSD: Introduce `if_.rs`, fix the definition of `ifreq` The definition of `struct ifreq` didn't match up. Make a new module for `net/if.h` and fix it there. Note that this drops some trait implementations since the correct API involves unions. (backport ) (cherry picked from commit 8cb1db91b85ac9cd041d471a388d0a5cb90c4e1e) --- libc-test/build.rs | 1 + src/new/mod.rs | 1 + src/new/netbsd/mod.rs | 4 ++ src/new/netbsd/net/if_.rs | 96 +++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 76 --------------------- 5 files changed, 102 insertions(+), 76 deletions(-) create mode 100644 src/new/netbsd/net/if_.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index f1317446282f..e8e847e43d8f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1490,6 +1490,7 @@ fn test_netbsd(target: &str) { // Anonymous unions ("ifconf", "ifc_ifcu") => true, + ("ifreq", "ifr_ifru") => true, ("utmpx", "ut_exit") => true, ("posix_spawn_file_actions_entry_t", "fae_data") => true, diff --git a/src/new/mod.rs b/src/new/mod.rs index 8d8644a7dae9..38a0759afb65 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -183,6 +183,7 @@ cfg_if! { } else if #[cfg(target_vendor = "apple")] { pub use signal::*; } else if #[cfg(target_os = "netbsd")] { + pub use net::if_::*; pub use sys::ipc::*; pub use sys::statvfs::*; pub use sys::time::*; diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs index 070a544dae81..5db71760c4de 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -4,6 +4,10 @@ //! * Sys headers: //! * Manual pages: +pub(crate) mod net { + pub(crate) mod if_; +} + pub(crate) mod sys; pub(crate) mod unistd; pub(crate) mod utmp_; diff --git a/src/new/netbsd/net/if_.rs b/src/new/netbsd/net/if_.rs new file mode 100644 index 000000000000..7cceadfc2b3d --- /dev/null +++ b/src/new/netbsd/net/if_.rs @@ -0,0 +1,96 @@ +//! Header: `net/if.h` +//! +//! + +use crate::prelude::*; +use crate::IFNAMSIZ; + +s! { + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_link_state: c_int, + pub ifi_mtu: u64, + pub ifi_metric: u64, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_noproto: u64, + pub ifi_lastchange: crate::timespec, + } +} + +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 +pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link +pub const IFF_RUNNING: c_int = 0x0040; // resources allocated +pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +s! { + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_data: if_data, + } +} + +s_no_extra_traits! { + pub struct ifreq { + pub ifr_name: [c_char; IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub space: crate::sockaddr_storage, + pub ifru_flags: c_short, + pub ifru_addrflags: c_int, + pub ifru_metrics: c_int, + pub ifru_mtu: c_int, + pub ifru_dlt: c_int, + pub ifru_value: c_uint, + pub ifru_data: *mut c_void, + // buf and buflen are deprecated but they contribute to union size + ifru_b: __c_anonymous_ifr_ifru_ifru_b, + } + + struct __c_anonymous_ifr_ifru_ifru_b { + b_buflen: u32, + b_buf: *mut c_void, + } + + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_void, + pub ifcu_req: *mut ifreq, + } +} diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 7912df861b85..22c8cb745377 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -342,38 +342,6 @@ s! { pub int_n_sign_posn: c_char, } - pub struct if_data { - pub ifi_type: c_uchar, - pub ifi_addrlen: c_uchar, - pub ifi_hdrlen: c_uchar, - pub ifi_link_state: c_int, - pub ifi_mtu: u64, - pub ifi_metric: u64, - pub ifi_baudrate: u64, - pub ifi_ipackets: u64, - pub ifi_ierrors: u64, - pub ifi_opackets: u64, - pub ifi_oerrors: u64, - pub ifi_collisions: u64, - pub ifi_ibytes: u64, - pub ifi_obytes: u64, - pub ifi_imcasts: u64, - pub ifi_omcasts: u64, - pub ifi_iqdrops: u64, - pub ifi_noproto: u64, - pub ifi_lastchange: crate::timespec, - } - - pub struct if_msghdr { - pub ifm_msglen: c_ushort, - pub ifm_version: c_uchar, - pub ifm_type: c_uchar, - pub ifm_addrs: c_int, - pub ifm_flags: c_int, - pub ifm_index: c_ushort, - pub ifm_data: if_data, - } - pub struct sockcred { pub sc_pid: crate::pid_t, pub sc_uid: crate::uid_t, @@ -685,15 +653,6 @@ s! { pub descr_str: [c_char; 1], } - pub struct ifreq { - pub _priv: [[c_char; 6]; 24], - } - - pub struct ifconf { - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } - pub struct tcp_info { pub tcpi_state: u8, pub __tcpi_ca_state: u8, @@ -797,11 +756,6 @@ s_no_extra_traits! { pub open: __c_anonymous_posix_spawn_fae_open, pub dup2: __c_anonymous_posix_spawn_fae_dup2, } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: *mut c_void, - pub ifcu_req: *mut ifreq, - } } cfg_if! { @@ -820,21 +774,6 @@ cfg_if! { } } } - - impl Eq for __c_anonymous_ifc_ifcu {} - impl PartialEq for __c_anonymous_ifc_ifcu { - fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { - unsafe { self.ifcu_buf == other.ifcu_buf || self.ifcu_req == other.ifcu_req } - } - } - impl hash::Hash for __c_anonymous_ifc_ifcu { - fn hash(&self, state: &mut H) { - unsafe { - self.ifcu_buf.hash(state); - self.ifcu_req.hash(state); - } - } - } } } @@ -1000,21 +939,6 @@ pub const LOCAL_PEEREID: c_int = 0x0003; // get peer identification pub const LOCAL_CREDS: c_int = 0x0004; // pass credentials to receiver // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373 -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 -pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net -pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link -pub const IFF_RUNNING: c_int = 0x0040; // resources allocated -pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol -pub const IFF_PROMISC: c_int = 0x0100; // receive all packets -pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets -pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress -pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions -pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit -pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast // sys/netinet/in.h // Protocols (RFC 1700) From 0e964d8db25919c4dff9e7523bfce6bd098a0d86 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 29 Oct 2025 01:44:02 -0500 Subject: [PATCH 34/36] NetBSD: Correct a number of symbol link names Relevant source: * `devname`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/stdlib.h#L296 * `getutent`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/utmp.h#L70 * `ntp_gettime`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/timex.h#L257 * `sched_rr_get_interval`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/sched.h#L50-L51 * `shmctl`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/shm.h#L2011 * `sig{action,suspend}`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/signal.h#L85-L95 * `{get,set}itimer`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/time.h#L331-L335 * `timer_{get,set}time`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/time.h#L158-L160 * `utmpx` symbols: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/include/utmpx.h#L135-L150 * `wait4`: https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/wait.h#L209 Excluded are `__statvfs90`, `__fstatvfs90`, `__sigaction_siginfo`, `__getmntinfo90`, `__getvfsstat90`which are only present in 10.0+ (the symbol version seems to be N-1). Source: * https://github.com/NetBSD/src/blob/908770859a5d5141adc63c7844190d01db8a18a4/sys/sys/statvfs.h#L160-L168 There is also a deprecated aliases that used to be needed and is removed here. * `__getmntinfo13`: https://github.com/NetBSD/src/blob/62c785e59d064070166dab5d2a4492055effba89/lib/libc/compat/gen/compat___getmntinfo13.c#L49-L50 (backport ) (cherry picked from commit 1816f606144e0263fc2b1ed05b2f6f0e214536f2) --- libc-test/build.rs | 9 +++++++++ src/new/netbsd/sys/timex.rs | 1 + src/new/netbsd/utmp_.rs | 1 + src/new/netbsd/utmpx_.rs | 10 ++++++++++ src/unix/bsd/mod.rs | 5 +++++ src/unix/bsd/netbsdlike/mod.rs | 1 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 ++++-- src/unix/mod.rs | 1 + 8 files changed, 32 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e8e847e43d8f..5725a9c8607f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1465,6 +1465,15 @@ fn test_netbsd(target: &str) { } }); + cfg.skip_fn_ptrcheck(move |func| { + match func { + // New symbol version present in NetBSD10, but we keep the old versions for NetBSD9 + // compatibility. + "getmntinfo" | "statvfs" | "fstatvfs" | "getvfsstat" | "sigaction" => true, + _ => false, + } + }); + cfg.skip_struct_field_type(move |struct_, field| { // This is a weird union, don't check the type. (struct_.ident() == "ifaddrs" && field.ident() == "ifa_ifu") || diff --git a/src/new/netbsd/sys/timex.rs b/src/new/netbsd/sys/timex.rs index d3c279726c39..82844bf0e732 100644 --- a/src/new/netbsd/sys/timex.rs +++ b/src/new/netbsd/sys/timex.rs @@ -89,6 +89,7 @@ s! { } extern "C" { + #[link_name = "__ntp_gettime50"] pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; pub fn ntp_adjtime(buf: *mut timex) -> c_int; } diff --git a/src/new/netbsd/utmp_.rs b/src/new/netbsd/utmp_.rs index 6179a7924f42..2047449053ce 100644 --- a/src/new/netbsd/utmp_.rs +++ b/src/new/netbsd/utmp_.rs @@ -27,6 +27,7 @@ s! { extern "C" { pub fn utmpname(file: *const c_char) -> c_int; pub fn setutent(); + #[link_name = "__getutent50"] pub fn getutent() -> *mut utmp; pub fn endutent(); } diff --git a/src/new/netbsd/utmpx_.rs b/src/new/netbsd/utmpx_.rs index 6b0762056de5..813c8fb69712 100644 --- a/src/new/netbsd/utmpx_.rs +++ b/src/new/netbsd/utmpx_.rs @@ -67,16 +67,26 @@ extern "C" { pub fn setutxent(); pub fn endutxent(); + #[link_name = "__getutxent50"] pub fn getutxent() -> *mut utmpx; + #[link_name = "__getutxid50"] pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__getutxline50"] pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__pututxline50"] pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__updwtmpx50"] pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; + #[link_name = "__getlastlogx50"] pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> *mut lastlogx; + + #[link_name = "__updlastlogx50"] pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; + #[link_name = "__getutmp50"] pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); + #[link_name = "__getutmpx50"] pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); pub fn utmpxname(file: *const c_char) -> c_int; } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 9b203f96eddc..8ab3632968c9 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -730,6 +730,7 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")] pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; pub fn sem_close(sem: *mut sem_t) -> c_int; pub fn getdtablesize() -> c_int; @@ -804,6 +805,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), link_name = "wait4@FBSD_1.0" )] + #[cfg_attr(target_os = "netbsd", link_name = "__wait450")] pub fn wait4( pid: crate::pid_t, status: *mut c_int, @@ -814,11 +816,13 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "getitimer$UNIX2003" )] + #[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")] pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "setitimer$UNIX2003" )] + #[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")] pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -879,6 +883,7 @@ extern "C" { locale: crate::locale_t, ) -> size_t; + #[cfg_attr(target_os = "netbsd", link_name = "__devname50")] pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; pub fn issetugid() -> c_int; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index ee5371f4963e..e1edcf9ffdc0 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -749,6 +749,7 @@ extern "C" { pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")] pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; // DIFF(main): changed to `*const *mut` in e77f551de9 diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 22c8cb745377..56563ddc386e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2124,7 +2124,9 @@ extern "C" { ) -> c_int; pub fn timer_delete(timerid: crate::timer_t) -> c_int; pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + #[link_name = "__timer_gettime50"] pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + #[link_name = "__timer_settime50"] pub fn timer_settime( timerid: crate::timer_t, flags: c_int, @@ -2150,6 +2152,7 @@ extern "C" { flags: c_int, ) -> *mut c_void; + #[link_name = "__sched_rr_get_interval50"] pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; @@ -2192,7 +2195,6 @@ extern "C" { ntargets: size_t, hint: *const c_void, ) -> c_int; - #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int; @@ -2239,7 +2241,7 @@ extern "C" { #[link(name = "util")] extern "C" { - #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[link_name = "__getpwent_r50"] pub fn getpwent_r( pwd: *mut crate::passwd, buf: *mut c_char, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 3e54201f1e19..677788e9fc9a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1646,6 +1646,7 @@ cfg_if! { target_os = "aix", )))] { extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")] #[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; } From 83f3c3859ceff7fd3490d6e759585ef059b0ed8e Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 3 Nov 2025 15:09:44 -0800 Subject: [PATCH 35/36] Add missing constants from `unistd.h` (backport ) (cherry picked from commit e654f3a8f08ea01ca7bb69c4ad8c962252b1807c) --- src/new/newlib/unistd.rs | 152 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/src/new/newlib/unistd.rs b/src/new/newlib/unistd.rs index 8d55ee582331..6b240be9b769 100644 --- a/src/new/newlib/unistd.rs +++ b/src/new/newlib/unistd.rs @@ -5,3 +5,155 @@ pub use crate::new::common::posix::unistd::{ STDIN_FILENO, STDOUT_FILENO, }; +use crate::prelude::*; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_JOB_CONTROL: c_int = 5; +pub const _SC_SAVED_IDS: c_int = 6; +pub const _SC_VERSION: c_int = 7; +pub const _SC_PAGESIZE: c_int = 8; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: c_int = 9; +pub const _SC_NPROCESSORS_ONLN: c_int = 10; +pub const _SC_PHYS_PAGES: c_int = 11; +pub const _SC_AVPHYS_PAGES: c_int = 12; +pub const _SC_MQ_OPEN_MAX: c_int = 13; +pub const _SC_MQ_PRIO_MAX: c_int = 14; +pub const _SC_RTSIG_MAX: c_int = 15; +pub const _SC_SEM_NSEMS_MAX: c_int = 16; +pub const _SC_SEM_VALUE_MAX: c_int = 17; +pub const _SC_SIGQUEUE_MAX: c_int = 18; +pub const _SC_TIMER_MAX: c_int = 19; +pub const _SC_TZNAME_MAX: c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: c_int = 21; +pub const _SC_FSYNC: c_int = 22; +pub const _SC_MAPPED_FILES: c_int = 23; +pub const _SC_MEMLOCK: c_int = 24; +pub const _SC_MEMLOCK_RANGE: c_int = 25; +pub const _SC_MEMORY_PROTECTION: c_int = 26; +pub const _SC_MESSAGE_PASSING: c_int = 27; +pub const _SC_PRIORITIZED_IO: c_int = 28; +pub const _SC_REALTIME_SIGNALS: c_int = 29; +pub const _SC_SEMAPHORES: c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 31; +pub const _SC_SYNCHRONIZED_IO: c_int = 32; +pub const _SC_TIMERS: c_int = 33; +pub const _SC_AIO_LISTIO_MAX: c_int = 34; +pub const _SC_AIO_MAX: c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 36; +pub const _SC_DELAYTIMER_MAX: c_int = 37; +pub const _SC_THREAD_KEYS_MAX: c_int = 38; +pub const _SC_THREAD_STACK_MIN: c_int = 39; +pub const _SC_THREAD_THREADS_MAX: c_int = 40; +pub const _SC_TTY_NAME_MAX: c_int = 41; +pub const _SC_THREADS: c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; +pub const _SC_LOGIN_NAME_MAX: c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 53; +pub const _SC_ADVISORY_INFO: c_int = 54; +pub const _SC_ATEXIT_MAX: c_int = 55; +pub const _SC_BARRIERS: c_int = 56; +pub const _SC_BC_BASE_MAX: c_int = 57; +pub const _SC_BC_DIM_MAX: c_int = 58; +pub const _SC_BC_SCALE_MAX: c_int = 59; +pub const _SC_BC_STRING_MAX: c_int = 60; +pub const _SC_CLOCK_SELECTION: c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 62; +pub const _SC_CPUTIME: c_int = 63; +pub const _SC_EXPR_NEST_MAX: c_int = 64; +pub const _SC_HOST_NAME_MAX: c_int = 65; +pub const _SC_IOV_MAX: c_int = 66; +pub const _SC_IPV6: c_int = 67; +pub const _SC_LINE_MAX: c_int = 68; +pub const _SC_MONOTONIC_CLOCK: c_int = 69; +pub const _SC_RAW_SOCKETS: c_int = 70; +pub const _SC_READER_WRITER_LOCKS: c_int = 71; +pub const _SC_REGEXP: c_int = 72; +pub const _SC_RE_DUP_MAX: c_int = 73; +pub const _SC_SHELL: c_int = 74; +pub const _SC_SPAWN: c_int = 75; +pub const _SC_SPIN_LOCKS: c_int = 76; +pub const _SC_SPORADIC_SERVER: c_int = 77; +pub const _SC_SS_REPL_MAX: c_int = 78; +pub const _SC_SYMLOOP_MAX: c_int = 79; +pub const _SC_THREAD_CPUTIME: c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 81; +pub const _SC_TIMEOUTS: c_int = 82; +pub const _SC_TRACE: c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 85; +pub const _SC_TRACE_INHERIT: c_int = 86; +pub const _SC_TRACE_LOG: c_int = 87; +pub const _SC_TRACE_NAME_MAX: c_int = 88; +pub const _SC_TRACE_SYS_MAX: c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 91; +pub const _SC_V7_ILP32_OFF32: c_int = 92; +pub const _SC_V6_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: c_int = 94; +pub const _SC_V6_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: c_int = 96; +pub const _SC_XOPEN_ENH_I18N: c_int = 97; +pub const _SC_XOPEN_LEGACY: c_int = 98; +pub const _SC_XOPEN_REALTIME: c_int = 99; +pub const _SC_STREAM_MAX: c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 102; +pub const _SC_XOPEN_SHM: c_int = 103; +pub const _SC_XOPEN_STREAMS: c_int = 104; +pub const _SC_XOPEN_UNIX: c_int = 105; +pub const _SC_XOPEN_VERSION: c_int = 106; +pub const _SC_2_CHAR_TERM: c_int = 107; +pub const _SC_2_C_BIND: c_int = 108; +pub const _SC_2_C_DEV: c_int = 109; +pub const _SC_2_FORT_DEV: c_int = 110; +pub const _SC_2_FORT_RUN: c_int = 111; +pub const _SC_2_LOCALEDEF: c_int = 112; +pub const _SC_2_PBS: c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: c_int = 115; +pub const _SC_2_PBS_LOCATE: c_int = 116; +pub const _SC_2_PBS_MESSAGE: c_int = 117; +pub const _SC_2_PBS_TRACK: c_int = 118; +pub const _SC_2_SW_DEV: c_int = 119; +pub const _SC_2_UPE: c_int = 120; +pub const _SC_2_VERSION: c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 139; From 893d41799295ca7129d5fa4f8235abafdd28ecb3 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 3 Nov 2025 21:15:45 -0600 Subject: [PATCH 36/36] ci: Check process output in create-artifacts Add `check=True` to catch nonzero exit codes, and address one other lint for unneeded collection to `list`. Additionally, add some print statements in an attempt to help debug the CI failure on Windows. (backport ) (cherry picked from commit 83bd32f8ac10bf20bba9509b06de5f242ca7c6ad) --- ci/create-artifacts.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/create-artifacts.py b/ci/create-artifacts.py index 2854daa56315..bd5656fd040b 100755 --- a/ci/create-artifacts.py +++ b/ci/create-artifacts.py @@ -30,7 +30,11 @@ def main(): archive_name = f"archive-{now}" archive_path = f"{archive_name}.tar.gz" - sp.run(["tar", "czvf", archive_path, "-C", build_dir, "-T-"], input=file_list) + sp.run( + ["tar", "czvf", archive_path, "-C", build_dir, "-T-"], + input=file_list, + check=True, + ) # If we are in GHA, set these env vars for future use gh_env = os.getenv("GITHUB_ENV") @@ -42,6 +46,7 @@ def main(): if __name__ == "__main__": + print("Starting script...") # For debugging CI failures # FIXME(ci): remove after the bump to windoes-2025 GHA images # Python <= 3.9 does not support the very helpful `root_dir` argument, # and that is the version used by the Windows GHA images. Rather than @@ -55,10 +60,12 @@ def main(): sys.exit(1) # Find the next 3.1x Python version - dirs = sorted(list(Path(r"C:\hostedtoolcache\windows\Python").iterdir())) + dirs = sorted(Path(r"C:\hostedtoolcache\windows\Python").iterdir()) usepy = next(x for x in dirs if r"\3.1" in str(x)) py = usepy.joinpath(r"x64\python.exe") print(f"relaunching with {py}") os.execvp(py, [__file__] + sys.argv) main() +else: + print("not invoked as main, exiting") # For debugging CI failures