From 8e32f815a1cdd857a6aac81174e5bb1e1783b9b3 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 27 Jul 2025 14:57:27 +0100 Subject: [PATCH 01/22] haiku adding accept4 posix call [ref](https://github.com/haiku/haiku/commit/6beff0d1633e7e60dce1ec31ce7023fd84e1d638) (backport ) (cherry picked from commit 5fd26264d89c95e301fe83f6e0333711035760ad) --- src/unix/haiku/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 71eb890d30452..124024e207d5c 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1261,6 +1261,8 @@ pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; pub const SOCK_RAW: c_int = 3; pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_NONBLOCK: c_int = 0x00040000; +pub const SOCK_CLOEXEC: c_int = 0x00080000; pub const SOL_SOCKET: c_int = -1; pub const SO_ACCEPTCONN: c_int = 0x00000001; @@ -1789,6 +1791,13 @@ extern "C" { address_len: crate::socklen_t, ) -> c_int; + pub fn accept4( + socket: c_int, + address: *mut crate::sockaddr, + addressLength: *mut crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn writev(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t; pub fn readv(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t; From 9c759331ac9e598756d42890efee253f2078c28e Mon Sep 17 00:00:00 2001 From: mbyx Date: Mon, 11 Aug 2025 10:03:26 +0500 Subject: [PATCH 02/22] libc: add padding struct (backport ) (cherry picked from commit bbafd450b7b03f0a0248efbae99b563b04bdb10a) --- libc-test/test/check_style.rs | 2 +- src/macros.rs | 8 ++++++++ src/types.rs | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/types.rs diff --git a/libc-test/test/check_style.rs b/libc-test/test/check_style.rs index 24f793e4feb86..d1d7fdf4aa150 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/test/check_style.rs @@ -20,7 +20,7 @@ use style::{Result, StyleChecker}; const SKIP_PREFIXES: &[&str] = &[ // Don't run the style checker on the reorganized portion of the crate while we figure // out what style we want. - "new/", + "new/", "types.rs", ]; #[test] diff --git a/src/macros.rs b/src/macros.rs index d0a55fa2fca29..b8286db2812b7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -64,6 +64,8 @@ macro_rules! cfg_if { /// Create an internal crate prelude with `core` reexports and common types. macro_rules! prelude { () => { + mod types; + /// Frequently-used types that are available on all platforms /// /// We need to reexport the core types so this works with `rust-dep-of-std`. @@ -72,14 +74,20 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use ::core::clone::Clone; #[allow(unused_imports)] + pub(crate) use ::core::default::Default; + #[allow(unused_imports)] pub(crate) use ::core::marker::{Copy, Send, Sync}; #[allow(unused_imports)] pub(crate) use ::core::option::Option; #[allow(unused_imports)] + pub(crate) use ::core::prelude::v1::derive; + #[allow(unused_imports)] pub(crate) use ::core::{fmt, hash, iter, mem}; #[allow(unused_imports)] pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; + #[allow(unused_imports)] + pub(crate) use crate::types::Padding; // Commonly used types defined in this crate #[allow(unused_imports)] pub(crate) use crate::{ diff --git a/src/types.rs b/src/types.rs new file mode 100644 index 0000000000000..d972d2390c9cd --- /dev/null +++ b/src/types.rs @@ -0,0 +1,18 @@ +//! Platform-agnostic support types. + +use core::mem::MaybeUninit; + +use crate::prelude::*; + +/// A transparent wrapper over `MaybeUninit` to represent uninitialized padding +/// while providing `Default`. +#[allow(unused)] +#[repr(transparent)] +#[derive(Clone, Copy)] +pub(crate) struct Padding(MaybeUninit); + +impl Default for Padding { + fn default() -> Self { + Self(MaybeUninit::zeroed()) + } +} From cb284a994252873c7b31a9a1f0f19d9e83156f87 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Mon, 15 Sep 2025 15:18:27 +0800 Subject: [PATCH 03/22] Move deprecated attribute from `extern "C"` block to functions Fixes `useless_deprecated` error. --- src/unix/bsd/apple/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 0535336e34511..a4e0a4c7c9424 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -6199,10 +6199,11 @@ cfg_if! { // These require a dependency on `libiconv`, and including this when built as // part of `std` means every Rust program gets it. Ideally we would have a link // modifier to only include these if they are used, but we do not. -#[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] #[cfg_attr(not(feature = "rustc-dep-of-std"), link(name = "iconv"))] extern "C" { + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] pub fn iconv( cd: iconv_t, inbuf: *mut *mut c_char, @@ -6210,6 +6211,7 @@ extern "C" { outbuf: *mut *mut c_char, outbytesleft: *mut size_t, ) -> size_t; + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] pub fn iconv_close(cd: iconv_t) -> c_int; } From f28b860993548c7f9e3f4593c90b0e626027af7a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 19 Sep 2025 00:47:40 -0500 Subject: [PATCH 04/22] test: Add basic configuration to use ctest-next Set up a Cargo dependency on ctest-next, which is now published as a beta version of ctest. Includes a backport of only the libc-test portions of d8cc87845f84 ("ctest-next: miscellaneous filtering bug fixes") to reduce conflicts with future cherry picks. Co-authored-by: mbyx --- Cargo.lock | 115 +++++++++++++++++++++++++++++++++-- libc-test/Cargo.toml | 7 +++ libc-test/build.rs | 13 ++++ libc-test/test/ctest_next.rs | 5 ++ 4 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 libc-test/test/ctest_next.rs diff --git a/Cargo.lock b/Cargo.lock index f53314d8d3ba2..26e312b8408ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,57 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +[[package]] +name = "askama" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4" +dependencies = [ + "askama_derive", + "itoa", + "percent-encoding", + "serde", + "serde_json", +] + +[[package]] +name = "askama_derive" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f" +dependencies = [ + "askama_parser", + "basic-toml", + "memchr", + "proc-macro2", + "quote", + "rustc-hash", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "askama_parser" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" +dependencies = [ + "memchr", + "serde", + "serde_derive", + "winnow", +] + +[[package]] +name = "basic-toml" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -64,6 +115,20 @@ checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" name = "ctest" version = "0.1.0" +[[package]] +name = "ctest" +version = "0.5.0-beta.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3dc06650f831a3845f2493213c01ebe1dc1cd7bea271d26766a38dc6e72a3f" +dependencies = [ + "askama", + "cc", + "proc-macro2", + "quote", + "syn", + "thiserror 2.0.16", +] + [[package]] name = "ctest-next" version = "0.1.0" @@ -180,6 +245,7 @@ dependencies = [ "annotate-snippets", "cc", "cfg-if 1.0.1", + "ctest 0.5.0-beta.0", "ctest2", "glob", "libc 0.2.175", @@ -210,11 +276,17 @@ version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + [[package]] name = "proc-macro2" -version = "1.0.96" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beef09f85ae72cea1ef96ba6870c51e6382ebfa4f0e85b643459331f3daa5be0" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] @@ -236,7 +308,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -268,6 +340,12 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + [[package]] name = "rustc-std-workspace-core" version = "1.0.1" @@ -360,7 +438,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +dependencies = [ + "thiserror-impl 2.0.16", ] [[package]] @@ -374,6 +461,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "unicode-ident" version = "1.0.18" @@ -419,3 +517,12 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winnow" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +dependencies = [ + "memchr", +] diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 32d98257e335e..0021b2a6b0326 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -22,6 +22,8 @@ annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } cc = "1.2.29" # FIXME: Use fork ctest until the maintainer gets back. ctest2 = "0.4.3" +# Use the in-tree `ctest` from the `main` branch via crates.io +ctest_next = { version = "0.5.0-beta.0", package = "ctest" } regex = "1.11.1" [features] @@ -35,6 +37,11 @@ name = "ctest" path = "test/ctest.rs" harness = false +[[test]] +name = "ctest_next" +path = "test/ctest_next.rs" +harness = false + [[test]] name = "linux-fcntl" path = "test/linux_fcntl.rs" diff --git a/libc-test/build.rs b/libc-test/build.rs index 8cb82e8a8d833..ac6c6d3f1add5 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -84,6 +84,11 @@ fn ctest_cfg() -> ctest::TestGenerator { cfg } +#[expect(unused)] +fn ctest_next_cfg() -> ctest_next::TestGenerator { + ctest_next::TestGenerator::new() +} + fn do_semver() { let mut out = PathBuf::from(env::var("OUT_DIR").unwrap()); out.push("semver.rs"); @@ -171,6 +176,14 @@ fn main() { let re = regex::bytes::Regex::new(r"(?-u:\b)crate::").unwrap(); copy_dir_hotfix(Path::new("../src"), &hotfix_dir, &re, b"::"); + // FIXME(ctest): Only needed until ctest-next supports all tests. + // Provide a default for targets that don't yet use `ctest-next`. + std::fs::write( + format!("{}/main_next.rs", std::env::var("OUT_DIR").unwrap()), + "\nfn main() { println!(\"test result: ok\"); }\n", + ) + .unwrap(); + do_cc(); do_ctest(); do_semver(); diff --git a/libc-test/test/ctest_next.rs b/libc-test/test/ctest_next.rs new file mode 100644 index 0000000000000..68ff7c619e635 --- /dev/null +++ b/libc-test/test/ctest_next.rs @@ -0,0 +1,5 @@ +#[allow(deprecated)] +#[allow(unused_imports)] +use libc::*; + +include!(concat!(env!("OUT_DIR"), "/main_next.rs")); From cac1be8246cdbe51574499fe4b463440db2e4fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Mon, 11 Aug 2025 18:11:52 +0200 Subject: [PATCH 05/22] freebsd15: Mark kinfo_proc as non-exhaustive struct kinfo_proc may be extended again in the future. Add #[non_exhaustive] to let the compiler and other tooling know. (backport ) (cherry picked from commit 9ee2d2a0f6180e092ada3f9a5960a31b290fa755) --- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 97912bdebcdb2..778c5ee018e34 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -50,6 +50,7 @@ s! { _priv: [c_ulong; 8], } + #[non_exhaustive] pub struct kinfo_proc { /// Size of this structure. pub ki_structsize: c_int, From b8171189e91655aaf20f62f7315f0332a1597080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Mon, 11 Aug 2025 20:41:55 +0200 Subject: [PATCH 06/22] freebsd: Limit P_IDLEPROC to FreeBSD 15 `P_IDLEPROC` was introduced in FreeBSD 15, in commit 33be1632047c ("racct: Fix accounting of CPU time for the system idle process"). https://github.com/freebsd/freebsd-src/commit/33be1632047c05dbfcc139476e05f49c3a86d560 (backport ) (cherry picked from commit ac0e2b6578ecc0fa9749dbd25a30f60762a74d78) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index f64d079fd04c5..aac1eaef7b16b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4241,6 +4241,7 @@ pub const P_CONTROLT: c_int = 0x00000002; pub const P_KPROC: c_int = 0x00000004; #[deprecated(since = "1.0", note = "Replaced in FreeBSD 15 by P_IDLEPROC")] pub const P_UNUSED3: c_int = 0x00000008; +#[cfg(freebsd15)] pub const P_IDLEPROC: c_int = 0x00000008; pub const P_PPWAIT: c_int = 0x00000010; pub const P_PROFIL: c_int = 0x00000020; From 096579c6cc365014fd0d7f9f73dbf42f3ca449c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Mon, 11 Aug 2025 20:42:57 +0200 Subject: [PATCH 07/22] freebsd: Limit mcontext_t::mc_tlsbase to FreeBSD 15 mcontext_t::mc_tlsbase was introduced in FreeBSD 15, in commit eea3e4dd9703 ("amd64: add mc_tlsbase member to mcontext"). https://github.com/freebsd/freebsd-src/commit/eea3e4dd9703a252509d75814049aa8da5007ebb (backport ) (cherry picked from commit 3d93bf5894136d6baf66ccecf6ecf5275908f082) --- src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fa85f11ce2812..29f11b039b080 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -98,6 +98,7 @@ s_no_extra_traits! { } #[repr(align(16))] + #[non_exhaustive] pub struct mcontext_t { pub mc_onstack: register_t, pub mc_rdi: register_t, @@ -136,7 +137,11 @@ s_no_extra_traits! { pub mc_gsbase: register_t, pub mc_xfpustate: register_t, pub mc_xfpustate_len: register_t, + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub mc_spare: [c_long; 4], + #[cfg(freebsd15)] pub mc_tlsbase: register_t, + #[cfg(freebsd15)] pub mc_spare: [c_long; 3], } } From 1ffd97da8501d915ef93da9db2bac5dadb556c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Mon, 11 Aug 2025 10:08:21 +0200 Subject: [PATCH 08/22] Fix a few typos They were found with `codespell`. (backport ) (cherry picked from commit 33b0290967ac8de914ee4602ddb93650b4c8c20f) [ drop changes to ctest-next that don't apply - Trevor ] --- src/unix/linux_like/linux/musl/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 8d4a5ce90b93d..2c0cc87444d63 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -925,7 +925,7 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; - // Addded in `musl` 1.1.20 + // Added in `musl` 1.1.20 pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; // Added in `musl` 1.1.24 From dac1b4d27a3f6dad2f9fceaa1297590590c26adf Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Mon, 11 Aug 2025 12:49:23 -0400 Subject: [PATCH 09/22] fix: simplify epoll_event packed check (backport ) (cherry picked from commit 8bd31d7b0996fa4678364a15de7c90834c7033dc) --- src/unix/linux_like/mod.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index b044caf109ee1..2beec93b91777 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -278,14 +278,7 @@ cfg_if! { s_no_extra_traits! { #[cfg_attr( - any( - all( - target_arch = "x86", - not(target_env = "musl"), - not(target_os = "android") - ), - target_arch = "x86_64" - ), + any(target_arch = "x86_64", all(target_arch = "x86", target_env = "gnu")), repr(packed) )] pub struct epoll_event { From ec1573c61d981246d5f55f69962318e256663967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Mon, 11 Aug 2025 09:52:12 +0200 Subject: [PATCH 10/22] triagebot.toml: Fix src/new/linux_uapi path Commit 3356f1217 ("Begin source reorganization with `linux/can.h`") introduced a new directory structure for reorganizing the source code. It is called `src/new/` everywhere but in triagebot.toml, likely because `src/reorg/` is an older name used during development. (backport ) (cherry picked from commit 627a530db467db4d7278fbfaea8cb22864cf47ac) --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 54d848f8f9cd3..6a6dfccd18e21 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -63,7 +63,7 @@ trigger_files = ["src/unix/solarish/illumos.rs"] [autolabel."O-linux"] trigger_files = [ "src/unix/linux_like/linux", - "src/reorg/linux_uapi", + "src/new/linux_uapi", ] [autolabel."O-linux-like"] From 8516849f67c15615eb396cb653941df443fd3630 Mon Sep 17 00:00:00 2001 From: mbyx Date: Tue, 12 Aug 2025 15:13:55 +0500 Subject: [PATCH 11/22] libc: port windows to use ctest-next (backport ) (cherry picked from commit acd869f309083c3ca2d6095722b2ff19b157973b) --- libc-test/Cargo.toml | 5 --- libc-test/build.rs | 81 +++++++++++++++--------------------- libc-test/test/ctest.rs | 3 +- libc-test/test/ctest_next.rs | 5 --- 4 files changed, 36 insertions(+), 58 deletions(-) delete mode 100644 libc-test/test/ctest_next.rs diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 0021b2a6b0326..a2c5062e8c55b 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -37,11 +37,6 @@ name = "ctest" path = "test/ctest.rs" harness = false -[[test]] -name = "ctest_next" -path = "test/ctest_next.rs" -harness = false - [[test]] name = "linux-fcntl" path = "test/linux_fcntl.rs" diff --git a/libc-test/build.rs b/libc-test/build.rs index ac6c6d3f1add5..556228001ffbf 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -84,7 +84,6 @@ fn ctest_cfg() -> ctest::TestGenerator { cfg } -#[expect(unused)] fn ctest_next_cfg() -> ctest_next::TestGenerator { ctest_next::TestGenerator::new() } @@ -176,14 +175,6 @@ fn main() { let re = regex::bytes::Regex::new(r"(?-u:\b)crate::").unwrap(); copy_dir_hotfix(Path::new("../src"), &hotfix_dir, &re, b"::"); - // FIXME(ctest): Only needed until ctest-next supports all tests. - // Provide a default for targets that don't yet use `ctest-next`. - std::fs::write( - format!("{}/main_next.rs", std::env::var("OUT_DIR").unwrap()), - "\nfn main() { println!(\"test result: ok\"); }\n", - ) - .unwrap(); - do_cc(); do_ctest(); do_semver(); @@ -887,7 +878,8 @@ fn test_windows(target: &str) { let gnu = target.contains("gnu"); let i686 = target.contains("i686"); - let mut cfg = ctest_cfg(); + let mut cfg = ctest_next_cfg(); + cfg.skip_private(true); if target.contains("msvc") { cfg.flag("/wd4324"); } @@ -915,41 +907,37 @@ fn test_windows(target: &str) { [!gnu]: "Winsock2.h", } - cfg.type_name(move |ty, is_struct, is_union| { + cfg.rename_struct_ty(|ty| { match ty { // Just pass all these through, no need for a "struct" prefix - "FILE" | "DIR" | "Dl_info" => ty.to_string(), - + "FILE" | "DIR" | "Dl_info" => ty.to_string().into(), + t if t.ends_with("_t") => t.to_string().into(), + // Windows uppercase structs don't have `struct` in fr.into()ont: + t if ty.chars().next().unwrap().is_uppercase() => t.to_string().into(), + "stat" => "struct __stat64".to_string().into(), + "utimbuf" => "struct __utimbuf64".to_string().into(), + _ => None, + } + }); + cfg.rename_type(move |ty| { + match ty { // FIXME(windows): these don't exist: - "time64_t" => "__time64_t".to_string(), - "ssize_t" => "SSIZE_T".to_string(), - - "sighandler_t" if !gnu => "_crt_signal_t".to_string(), - "sighandler_t" if gnu => "__p_sig_fn_t".to_string(), - - t if is_union => format!("union {t}"), - t if t.ends_with("_t") => t.to_string(), + "time64_t" => "__time64_t".to_string().into(), + "ssize_t" => "SSIZE_T".to_string().into(), - // Windows uppercase structs don't have `struct` in front: - t if is_struct => { - if ty.chars().next().unwrap().is_uppercase() { - t.to_string() - } else if t == "stat" { - "struct __stat64".to_string() - } else if t == "utimbuf" { - "struct __utimbuf64".to_string() - } else { - // put `struct` in front of all structs: - format!("struct {t}") - } - } - t => t.to_string(), + "sighandler_t" if !gnu => "_crt_signal_t".to_string().into(), + "sighandler_t" if gnu => "__p_sig_fn_t".to_string().into(), + _ => None, } }); - cfg.fn_cname(move |name, cname| cname.unwrap_or(name).to_string()); + cfg.rename_fn(move |func| { + func.link_name() + .map(|l| l.to_string()) + .or(func.ident().to_string().into()) + }); - cfg.skip_type(move |name| match name { + cfg.skip_alias(move |alias| match alias.ident() { "SSIZE_T" if !gnu => true, "ssize_t" if !gnu => true, // FIXME(windows): The size and alignment of this type are incorrect @@ -957,7 +945,8 @@ fn test_windows(target: &str) { _ => false, }); - cfg.skip_struct(move |ty| { + cfg.skip_struct(move |struct_| { + let ty = struct_.ident(); if ty.starts_with("__c_anonymous_") { return true; } @@ -967,9 +956,10 @@ fn test_windows(target: &str) { _ => false, } }); + cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_const(move |name| { - match name { + cfg.skip_const(move |constant| { + match constant.ident() { // FIXME(windows): API error: // SIG_ERR type is "void (*)(int)", not "int" "SIG_ERR" | @@ -981,10 +971,7 @@ fn test_windows(target: &str) { } }); - cfg.skip_field(move |s, field| match s { - "CONTEXT" if field == "Fp" => true, - _ => false, - }); + cfg.skip_struct_field(move |s, field| s.ident() == "CONTEXT" && field.ident() == "Fp"); // FIXME(windows): All functions point to the wrong addresses? cfg.skip_fn_ptrcheck(|_| true); @@ -999,8 +986,8 @@ fn test_windows(target: &str) { } }); - cfg.skip_fn(move |name| { - match name { + cfg.skip_fn(move |func| { + match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "execvpe" => true, @@ -1008,7 +995,7 @@ fn test_windows(target: &str) { } }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + ctest_next::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_redox(target: &str) { diff --git a/libc-test/test/ctest.rs b/libc-test/test/ctest.rs index 0b48c4af2975e..cc6da549e7cae 100644 --- a/libc-test/test/ctest.rs +++ b/libc-test/test/ctest.rs @@ -1,5 +1,6 @@ -#![allow(bad_style, improper_ctypes, deprecated)] +#![allow(deprecated)] +#[allow(unused_imports)] use libc::*; include!(concat!(env!("OUT_DIR"), "/ctest_output.rs")); diff --git a/libc-test/test/ctest_next.rs b/libc-test/test/ctest_next.rs deleted file mode 100644 index 68ff7c619e635..0000000000000 --- a/libc-test/test/ctest_next.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[allow(deprecated)] -#[allow(unused_imports)] -use libc::*; - -include!(concat!(env!("OUT_DIR"), "/main_next.rs")); From 8a8c68ec94cb13a88d3fb4db2c68b8f44c2d192c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Tue, 12 Aug 2025 09:50:03 +0200 Subject: [PATCH 12/22] CI: Upgrade to FreeBSD 14.3 FreeBSD 14.3 was released on June 10, 2025: https://www.freebsd.org/releases/14.3R/announce/ (backport ) (cherry picked from commit d54af1798f91137f754b74377a4290ad28620456) --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 7985cb854bbe3..fb627124e5b67 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -18,7 +18,7 @@ task: image_family: freebsd-13-4 - name: nightly freebsd-14 x86_64 freebsd_instance: - image: freebsd-14-2-release-amd64-ufs + image: freebsd-14-3-release-amd64-ufs - name: nightly freebsd-15 x86_64 freebsd_instance: image_family: freebsd-15-0-snap From f0bedee8bfbf92b4569b0ac27a7c37ffcdd59065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Neusch=C3=A4fer?= Date: Tue, 12 Aug 2025 10:41:38 +0200 Subject: [PATCH 13/22] freebsd14: Add st_fileref to struct stat st_fileref was backported to FreeBSD 14 with the 14.3 release. https://github.com/freebsd/freebsd-src/commit/86e95bb26ad8f357ddc6aef655b56d695b01fa7e (backport ) (cherry picked from commit dc3bf0adbb18e1b8ba8595a0ccee0896d2987407) --- src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index de1001b26fab9..4a65d59d5f3b1 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -234,6 +234,7 @@ s! { pub ki_tdflags: c_long, } + #[non_exhaustive] pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -265,7 +266,8 @@ s! { pub st_blksize: crate::blksize_t, pub st_flags: crate::fflags_t, pub st_gen: u64, - pub st_spare: [u64; 10], + pub st_filerev: u64, + pub st_spare: [u64; 9], } } From e79dc9ead1f9928345ed4179121ed784d0cdc841 Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Sun, 10 Aug 2025 02:39:38 -0400 Subject: [PATCH 14/22] Enable strftime, mkostemp[s] on Redox Redox's relibc supports: * mkostemp * mkostemps * strftime (backport ) (cherry picked from commit 8380bad96de3d2ffbc1b1070213fbfc9d31f62dd) --- libc-test/semver/redox.txt | 3 +++ src/unix/redox/mod.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 3c3c52eabb4f0..3c0bd87f686d4 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -224,6 +224,8 @@ lockf login_tty madvise memalign +mkostemp +mkostemps nice open_memstream open_wmemstream @@ -240,6 +242,7 @@ sigtimedwait sigwait strcasecmp strcasestr +strftime strlcat strlcpy strncasecmp diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 7420fba229912..4446473a3ab3a 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1207,6 +1207,8 @@ extern "C" { tokens: *const *mut c_char, valuep: *mut *mut c_char, ) -> c_int; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; // string.h @@ -1276,6 +1278,12 @@ extern "C" { // time.h pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn strftime( + s: *mut c_char, + max: size_t, + format: *const c_char, + tm: *const crate::tm, + ) -> size_t; // utmp.h pub fn login_tty(fd: c_int) -> c_int; From fa2f421c6573fbc44089dbdcc38addacdab8b024 Mon Sep 17 00:00:00 2001 From: mbyx Date: Wed, 13 Aug 2025 11:11:18 +0500 Subject: [PATCH 15/22] libc: port freebsd to use ctest-next (backport ) (cherry picked from commit 673b10eb7aa2d437aae67295f8cefa26ed366973) --- libc-test/build.rs | 77 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 556228001ffbf..f669ed6f86c48 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -85,7 +85,9 @@ fn ctest_cfg() -> ctest::TestGenerator { } fn ctest_next_cfg() -> ctest_next::TestGenerator { - ctest_next::TestGenerator::new() + let mut cfg = ctest_next::TestGenerator::new(); + cfg.skip_private(true); + cfg } fn do_semver() { @@ -2397,7 +2399,7 @@ fn test_android(target: &str) { fn test_freebsd(target: &str) { assert!(target.contains("freebsd")); - let mut cfg = ctest_cfg(); + let mut cfg = ctest_next_cfg(); let freebsd_ver = which_freebsd(); @@ -2539,7 +2541,13 @@ fn test_freebsd(target: &str) { "wchar.h", } - cfg.type_name(move |ty, is_struct, is_union| { + cfg.rename_type(|ty| match ty { + // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 + "sighandler_t" => Some("sig_t".to_string()), + _ => None, + }); + + cfg.rename_struct_ty(|ty| { match ty { // Just pass all these through, no need for a "struct" prefix "FILE" @@ -2554,27 +2562,20 @@ fn test_freebsd(target: &str) { | "devstat_support_flags" | "devstat_type_flags" | "devstat_match_flags" - | "devstat_priority" => ty.to_string(), - - // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 - "sighandler_t" => "sig_t".to_string(), - - t if is_union => format!("union {t}"), - - t if t.ends_with("_t") => t.to_string(), + | "devstat_priority" => Some(ty.to_string()), // sigval is a struct in Rust, but a union in C: - "sigval" => "union sigval".to_string(), + "sigval" => Some("union sigval".to_string()), - // put `struct` in front of all structs:. - t if is_struct => format!("struct {t}"), + t if t.ends_with("_t") => Some(t.to_string()), - t => t.to_string(), + _ => None, } }); - cfg.field_name(move |struct_, field| { - match field { + cfg.rename_struct_field(|struct_, field_| { + let struct_ = struct_.ident(); + let replacement = match field_.ident() { // Our stat *_nsec fields normally don't actually exist but are part // of a timeval struct s if s.ends_with("_nsec") && struct_.starts_with("stat") => { @@ -2588,12 +2589,13 @@ fn test_freebsd(target: &str) { "type_" if struct_ == "input_event" => "type".to_string(), // Field is named `gennum` in Rust because `gen` is a keyword "gennum" if struct_ == "xktls_session_onedir" => "gen".to_string(), - s => s.to_string(), - } + _ => return None, + }; + Some(replacement) }); - cfg.skip_const(move |name| { - match name { + cfg.skip_const(move |constant| { + match constant.ident() { // These constants were introduced in FreeBSD 13: "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" @@ -2873,8 +2875,8 @@ fn test_freebsd(target: &str) { } }); - cfg.skip_type(move |ty| { - match ty { + cfg.skip_alias(move |ty| { + match ty.ident() { // the struct "__kvm" is quite tricky to bind so since we only use a pointer to it // for now, it doesn't matter too much... "kvm_t" => true, @@ -2885,7 +2887,9 @@ fn test_freebsd(target: &str) { } }); - cfg.skip_struct(move |ty| { + cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(move |struct_| { + let ty = struct_.ident(); if ty.starts_with("__c_anonymous_") { return true; } @@ -2930,9 +2934,9 @@ fn test_freebsd(target: &str) { } }); - cfg.skip_fn(move |name| { + cfg.skip_fn(move |func| { // skip those that are manually verified - match name { + match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 // Also, `execvpe` is introduced in FreeBSD 14.1 "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, @@ -2993,18 +2997,12 @@ fn test_freebsd(target: &str) { } }); - cfg.volatile_item(|i| { - use ctest::VolatileItemKind::*; - match i { - // aio_buf is a volatile void** but since we cannot express that in - // Rust types, we have to explicitly tell the checker about it here: - StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true, - _ => false, - } - }); + // aio_buf is a volatile void* but since we cannot express that in + // Rust types, we have to explicitly tell the checker about it here: + cfg.volatile_struct_field(|s, f| s.ident() == "aiocb" && f.ident() == "aio_buf"); - cfg.skip_field(move |struct_, field| { - match (struct_, field) { + cfg.skip_struct_field(move |struct_, field| { + match (struct_.ident(), field.ident()) { // FIXME(freebsd): `sa_sigaction` has type `sighandler_t` but that type is // incorrect, see: https://github.com/rust-lang/libc/issues/1359 ("sigaction", "sa_sigaction") => true, @@ -3079,7 +3077,10 @@ fn test_freebsd(target: &str) { }); } - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + // FIXME(ctest): The original ctest bypassed this requirement somehow. + cfg.rename_type(move |ty| (ty == "dot3Vendors").then_some(format!("enum {ty}"))); + + ctest_next::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_emscripten(target: &str) { From f3e1b6809bc42f4a82ad449962340b900c464b31 Mon Sep 17 00:00:00 2001 From: mbyx Date: Tue, 12 Aug 2025 16:32:37 +0500 Subject: [PATCH 16/22] libc: port apple to use ctest-next (backport ) (cherry picked from commit 1e8377c628619a53b20cea7fd87a15c5c424c183) --- libc-test/build.rs | 94 ++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f669ed6f86c48..1d9bdae51fc45 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -226,7 +226,8 @@ fn test_apple(target: &str) { let x86_64 = target.contains("x86_64"); let i686 = target.contains("i686"); - let mut cfg = ctest_cfg(); + let mut cfg = ctest_next_cfg(); + cfg.flag("-Wno-deprecated-declarations"); cfg.define("__APPLE_USE_RFC_3542", None); @@ -347,14 +348,14 @@ fn test_apple(target: &str) { [x86_64]: "crt_externs.h", } - cfg.skip_struct(move |ty| { - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + // Skip anonymous unions/structs. + cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); + + cfg.skip_struct(|s| { + match s.ident() { // FIXME(union): actually a union "sigval" => true, - // FIXME(macos): The size is changed in recent macOSes. "malloc_zone_t" => true, // it is a moving target, changing through versions @@ -362,16 +363,13 @@ fn test_apple(target: &str) { "tcp_connection_info" => true, // FIXME(macos): The size is changed in recent macOSes. "malloc_introspection_t" => true, - _ => false, } }); - cfg.skip_type(move |ty| { - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); + cfg.skip_alias(|ty| { + match ty.ident() { // FIXME(macos): Requires the macOS 14.4 SDK. "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, @@ -382,12 +380,10 @@ fn test_apple(target: &str) { } }); - cfg.skip_const(move |name| { - // They're declared via `deprecated_mach` and we don't support it anymore. - if name.starts_with("VM_FLAGS_") { - return true; - } - match name { + cfg.skip_const(move |constant| { + match constant.ident() { + // They're declared via `deprecated_mach` and we don't support it anymore. + x if x.starts_with("VM_FLAGS_") => true, // These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, @@ -407,12 +403,11 @@ fn test_apple(target: &str) { } }); - cfg.skip_fn(move |name| { + cfg.skip_fn(move |func| { // skip those that are manually verified - match name { + match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - // close calls the close_nocancel system call "close" => true, @@ -441,8 +436,8 @@ fn test_apple(target: &str) { } }); - cfg.skip_field(move |struct_, field| { - match (struct_, field) { + cfg.skip_struct_field(move |struct_, field| { + match (struct_.ident(), field.ident()) { // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]). ("statfs", "f_reserved") => true, ("__darwin_arm_neon_state64", "__v") => true, @@ -459,47 +454,39 @@ fn test_apple(target: &str) { } }); - cfg.skip_field_type(move |struct_, field| { - match (struct_, field) { + cfg.skip_struct_field_type(move |struct_, field| { + match (struct_.ident(), field.ident()) { // FIXME(union): actually a union ("sigevent", "sigev_value") => true, _ => false, } }); - cfg.volatile_item(|i| { - use ctest::VolatileItemKind::*; - match i { - StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true, - _ => false, - } + cfg.volatile_struct_field(|s, f| s.ident() == "aiocb" && f.ident() == "aio_buf"); + + cfg.rename_struct_ty(move |ty| { + // Just pass all these through, no need for a "struct" prefix + ["FILE", "DIR", "Dl_info"] + .contains(&ty) + .then_some(ty.to_string()) }); - cfg.type_name(move |ty, is_struct, is_union| { - match ty { - // Just pass all these through, no need for a "struct" prefix - "FILE" | "DIR" | "Dl_info" => ty.to_string(), + // OSX calls this something else + cfg.rename_type(|ty| (ty == "sighandler_t").then_some("sig_t".to_string())); - // OSX calls this something else - "sighandler_t" => "sig_t".to_string(), + cfg.rename_struct_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); + cfg.rename_union_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); - t if is_union => format!("union {t}"), - t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {t}"), - t => t.to_string(), - } - }); - - cfg.field_name(move |struct_, field| { - match field { - s if s.ends_with("_nsec") && struct_.starts_with("stat") => { - s.replace("e_nsec", "espec.tv_nsec") + cfg.rename_struct_field(|s, f| { + match f.ident() { + n if n.ends_with("_nsec") && s.ident().starts_with("stat") => { + Some(n.replace("e_nsec", "espec.tv_nsec")) } // FIXME(macos): sigaction actually contains a union with two variants: // a sa_sigaction with type: (*)(int, struct __siginfo *, void *) // a sa_handler with type sig_t - "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), - s => s.to_string(), + "sa_sigaction" if s.ident() == "sigaction" => Some("sa_handler".to_string()), + _ => None, } }); @@ -510,7 +497,8 @@ fn test_apple(target: &str) { "uuid_t" | "vol_capabilities_set_t" => true, _ => false, }); - cfg.generate(src_hotfix_dir().join("lib.rs"), "ctest_output.rs"); + + ctest_next::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } fn test_openbsd(target: &str) { @@ -881,7 +869,7 @@ fn test_windows(target: &str) { let i686 = target.contains("i686"); let mut cfg = ctest_next_cfg(); - cfg.skip_private(true); + if target.contains("msvc") { cfg.flag("/wd4324"); } From 8d6d258c9dffc327d23c2f32d42376a5e16aea83 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Thu, 14 Aug 2025 15:10:30 -0400 Subject: [PATCH 17/22] Fix the type of the 4th arguement of getgrnam_r(). (backport ) (cherry picked from commit 8236b564f86744ec040343704e75af814d6244ad) --- src/unix/aix/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a4e975ad8030e..f9c5a2bf1b78a 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2927,7 +2927,7 @@ extern "C" { name: *const c_char, grp: *mut crate::group, buf: *mut c_char, - buflen: c_int, + buflen: size_t, result: *mut *mut crate::group, ) -> c_int; pub fn getgrset(user: *const c_char) -> *mut c_char; From 60e3670457e3dad62f97c69fef65393237c68024 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:11:43 +0000 Subject: [PATCH 18/22] build(deps): bump actions/checkout from 4 to 5 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit c5552f6f2bd5d94cb6ac82eb1ce8b00e17ddfa85) --- .github/workflows/ci.yaml | 12 ++++++------ .github/workflows/publish_0.2.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e9c1306af438b..a1906564ad141 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Rust toolchain run: ./ci/install-rust.sh && rustup component add rustfmt - name: Check style @@ -38,7 +38,7 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - run: rustup update stable --no-self-update - uses: Swatinem/rust-cache@v2 # Here we use the latest stable Rust toolchain already installed by GitHub @@ -61,7 +61,7 @@ jobs: env: TOOLCHAIN: ${{ matrix.toolchain }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Rust toolchain run: ./ci/install-rust.sh @@ -131,7 +131,7 @@ jobs: env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Rust toolchain run: ./ci/install-rust.sh - uses: Swatinem/rust-cache@v2 @@ -240,7 +240,7 @@ jobs: env: TARGET: ${{ matrix.target }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup Rust toolchain run: ./ci/install-rust.sh - uses: Swatinem/rust-cache@v2 @@ -279,7 +279,7 @@ jobs: - x86_64-pc-solaris timeout-minutes: 25 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: test on Solaris uses: vmactions/solaris-vm@v1.1.4 with: diff --git a/.github/workflows/publish_0.2.yml b/.github/workflows/publish_0.2.yml index 768fbcac7d3cc..5ad1e97e1c1dc 100644 --- a/.github/workflows/publish_0.2.yml +++ b/.github/workflows/publish_0.2.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install Rust (rustup) From daa56c735815348571f579a933bc969ff134b08d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 20:27:32 +0000 Subject: [PATCH 19/22] build(deps): bump vmactions/solaris-vm from 1.1.4 to 1.1.5 Bumps [vmactions/solaris-vm](https://github.com/vmactions/solaris-vm) from 1.1.4 to 1.1.5. - [Release notes](https://github.com/vmactions/solaris-vm/releases) - [Commits](https://github.com/vmactions/solaris-vm/compare/v1.1.4...v1.1.5) --- updated-dependencies: - dependency-name: vmactions/solaris-vm dependency-version: 1.1.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] (backport ) (cherry picked from commit 10d68a4c2dfa3a08fdf7e4d81f305ea833663dba) --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a1906564ad141..81842e5e6d9da 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -281,7 +281,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: test on Solaris - uses: vmactions/solaris-vm@v1.1.4 + uses: vmactions/solaris-vm@v1.1.5 with: release: "11.4-gcc" usesh: true From 0cc3156822bce01e2898bc4b8e95c9bdaf5a2330 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 18 Sep 2025 23:39:30 -0500 Subject: [PATCH 20/22] ci: Upgrade Ubuntu docker images to 25.04 24.10 is EOL so we need to bump the images. (backport ) (cherry picked from commit 65da4e4e914a81e610f4862978488b123ae37176) --- ci/docker/aarch64-linux-android/Dockerfile | 2 +- ci/docker/aarch64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/aarch64-unknown-linux-musl/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 2 +- ci/docker/asmjs-unknown-emscripten/Dockerfile | 2 +- ci/docker/i686-linux-android/Dockerfile | 2 +- ci/docker/loongarch64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/loongarch64-unknown-linux-musl/Dockerfile | 2 +- ci/docker/powerpc64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/powerpc64le-unknown-linux-musl/Dockerfile | 2 +- ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/s390x-unknown-linux-musl/Dockerfile | 2 +- ci/docker/sparc64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/wasm32-unknown-emscripten/Dockerfile | 2 +- ci/docker/wasm32-wasip1/Dockerfile | 2 +- ci/docker/wasm32-wasip2/Dockerfile | 2 +- ci/docker/x86_64-linux-android/Dockerfile | 2 +- ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 2 +- ci/docker/x86_64-unknown-linux-gnux32/Dockerfile | 2 +- ci/docker/x86_64-unknown-linux-musl/Dockerfile | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index dfd63718a9d0d..8ed15a5234d1e 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN dpkg --add-architecture i386 RUN apt-get update diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 00569ddf22c9b..a4faeb4a8b96b 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev ca-certificates \ diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index 053ed837b2e7c..f57c5fa6055c2 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index 82f89f48e915c..e81623f7bf0e7 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN dpkg --add-architecture i386 RUN apt-get update diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index 085e45ff35ee6..c8fb40cc3d3c0 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 # This is a workaround to avoid the interaction with tzdata. ENV DEBIAN_FRONTEND=noninteractive diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index 8a159cd0502b5..24d15872efd07 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN dpkg --add-architecture i386 RUN apt-get update diff --git a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile index 16b4cf4bfd34e..138b9a195adb8 100644 --- a/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile index 0b3ff4da34ba0..ec632c33f7af3 100644 --- a/ci/docker/loongarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/loongarch64-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl gcc gcc-14-loongarch64-linux-gnu git libc6-dev \ diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index 76d8471a63aac..a8a9dd8c92263 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile index c4c6af25b8684..0d6110f39149f 100644 --- a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile index b25f284eddf7a..40a661149f7d8 100644 --- a/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ diff --git a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile index 0624e2c102055..43138af5da234 100644 --- a/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index dde2ef24254fc..aa3490228c4db 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ diff --git a/ci/docker/s390x-unknown-linux-musl/Dockerfile b/ci/docker/s390x-unknown-linux-musl/Dockerfile index 2d4ea759c5fbf..0dfad20fb7a1d 100644 --- a/ci/docker/s390x-unknown-linux-musl/Dockerfile +++ b/ci/docker/s390x-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index 645cc3362ab93..a91ec3dd25f27 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && apt-get install -y --no-install-recommends \ curl ca-certificates \ diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 0f9cb85dc30e8..969a0ffca0be3 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 # This is a workaround to avoid the interaction with tzdata. ENV DEBIAN_FRONTEND=noninteractive diff --git a/ci/docker/wasm32-wasip1/Dockerfile b/ci/docker/wasm32-wasip1/Dockerfile index e85b27ff82099..419159a0b1380 100644 --- a/ci/docker/wasm32-wasip1/Dockerfile +++ b/ci/docker/wasm32-wasip1/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 COPY wasi.sh / RUN /wasi.sh diff --git a/ci/docker/wasm32-wasip2/Dockerfile b/ci/docker/wasm32-wasip2/Dockerfile index be6bff3a843c5..8d819b36e5c15 100644 --- a/ci/docker/wasm32-wasip2/Dockerfile +++ b/ci/docker/wasm32-wasip2/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 COPY wasi.sh / RUN /wasi.sh diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 3bf350820019f..950c2a9fdc612 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index b6ad33ebc7cb5..3e94948095024 100644 --- a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ diff --git a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile index f50af741db564..92a92b1dfe98d 100644 --- a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 5c1b4b177880c..194a6e7847f55 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:24.10 +FROM ubuntu:25.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ From 2b5dd79353289ccd9f6e88d1bff450d42cc0eb70 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Thu, 18 Sep 2025 22:19:42 -0500 Subject: [PATCH 21/22] Resolve `clippy::zero_ptr` Recent versions of Clippy now lint against `0 as *(const|mut) T` rather than using `null`/`null_mut`. Make the updates required for this to pass. (backport ) (cherry picked from commit c4eefd5d933d3f6f92b926ab95dce84599a4b8a9) --- src/fuchsia/mod.rs | 4 ++-- src/macros.rs | 2 +- src/unix/bsd/freebsdlike/mod.rs | 8 ++++---- src/unix/bsd/netbsdlike/mod.rs | 2 +- src/unix/bsd/netbsdlike/openbsd/mod.rs | 6 +++--- src/unix/cygwin/mod.rs | 2 +- src/unix/haiku/mod.rs | 2 +- src/unix/hurd/mod.rs | 4 ++-- src/unix/linux_like/android/b64/mod.rs | 2 +- src/unix/linux_like/android/mod.rs | 2 +- src/unix/linux_like/emscripten/mod.rs | 4 ++-- src/unix/linux_like/linux/mod.rs | 4 ++-- src/unix/newlib/horizon/mod.rs | 2 +- src/unix/newlib/vita/mod.rs | 2 +- src/unix/nuttx/mod.rs | 2 +- src/unix/redox/mod.rs | 2 +- src/vxworks/mod.rs | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index a019ebb1f04cf..3cd7f7cc31332 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -2308,7 +2308,7 @@ pub const ST_NOATIME: c_ulong = 1024; pub const ST_NODIRATIME: c_ulong = 2048; pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NODELETE: c_int = 0x1000; pub const RTLD_NOW: c_int = 0x2; @@ -2452,7 +2452,7 @@ pub const EFD_SEMAPHORE: c_int = 0x1; pub const LOG_NFACILITIES: c_int = 24; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32; pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32; diff --git a/src/macros.rs b/src/macros.rs index b8286db2812b7..1bd547f07a28e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -82,7 +82,7 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use ::core::prelude::v1::derive; #[allow(unused_imports)] - pub(crate) use ::core::{fmt, hash, iter, mem}; + pub(crate) use ::core::{fmt, hash, iter, mem, ptr}; #[allow(unused_imports)] pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 6d32a1dc95a48..d093847f8983e 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1197,9 +1197,9 @@ pub const _SC_RAW_SOCKETS: c_int = 119; pub const _SC_SYMLOOP_MAX: c_int = 120; pub const _SC_PHYS_PAGES: c_int = 121; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; pub const PTHREAD_MUTEX_NORMAL: c_int = 3; @@ -1331,7 +1331,7 @@ pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const CRTSCTS: crate::tcflag_t = 0x00030000; pub const CCTS_OFLOW: crate::tcflag_t = 0x00010000; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index b9c35fe7f41f3..8bfeef9d25017 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -651,7 +651,7 @@ pub const B230400: speed_t = 230400; pub const EXTA: speed_t = 19200; pub const EXTB: speed_t = 38400; -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const CRTSCTS: crate::tcflag_t = 0x00010000; pub const CRTS_IFLOW: crate::tcflag_t = CRTSCTS; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 5ee6bc0ca04f3..74648feff585d 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1328,9 +1328,9 @@ pub const SCHED_RR: c_int = 3; pub const ST_NOSUID: c_ulong = 2; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index fde2c18936e71..4263d92671dd2 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1018,7 +1018,7 @@ pub const NGROUPS_MAX: c_int = 1024; pub const FORK_RELOAD: c_int = 1; pub const FORK_NO_RELOAD: c_int = 0; -pub const RTLD_DEFAULT: *mut c_void = 0isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_LOCAL: c_int = 0; pub const RTLD_LAZY: c_int = 1; pub const RTLD_NOW: c_int = 2; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 124024e207d5c..6673e96c32971 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1060,7 +1060,7 @@ pub const FD_SETSIZE: usize = 1024; pub const RTLD_LOCAL: c_int = 0x0; pub const RTLD_NOW: c_int = 0x1; pub const RTLD_GLOBAL: c_int = 0x2; -pub const RTLD_DEFAULT: *mut c_void = 0isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const BUFSIZ: c_uint = 8192; pub const FILENAME_MAX: c_uint = 256; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 1f7276eb36f1c..a818fc5772cde 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1791,7 +1791,7 @@ pub const RB_DEBUGGER: c_int = 0x1000; // semaphore.h pub const __SIZEOF_SEM_T: usize = 20; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); // termios.h pub const IGNBRK: crate::tcflag_t = 1; @@ -1962,7 +1962,7 @@ pub const CTIME: u8 = 0; pub const CBRK: u8 = 0u8; // dlfcn.h -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; pub const RTLD_LAZY: c_int = 1; pub const RTLD_NOW: c_int = 2; diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index e16c251a6d519..46ceed4c6dcba 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -225,7 +225,7 @@ pub const SA_SIGINFO: c_int = 0x00000004; pub const RTLD_GLOBAL: c_int = 0x00100; pub const RTLD_NOW: c_int = 2; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index df901a36635a8..bb08e9ab5f420 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1551,7 +1551,7 @@ pub const ST_RELATIME: c_ulong = 4096; pub const RTLD_NOLOAD: c_int = 0x4; pub const RTLD_NODELETE: c_int = 0x1000; -pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); pub const AI_PASSIVE: c_int = 0x00000001; pub const AI_CANONNAME: c_int = 0x00000002; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 7a43670536e4f..10b0893565a03 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -772,7 +772,7 @@ pub const ST_NOATIME: c_ulong = 1024; pub const ST_NODIRATIME: c_ulong = 2048; pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NODELETE: c_int = 0x1000; pub const RTLD_NOW: c_int = 0x2; @@ -842,7 +842,7 @@ pub const SHM_NORESERVE: c_int = 0o10000; pub const LOG_NFACILITIES: c_int = 24; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); pub const AI_PASSIVE: c_int = 0x0001; pub const AI_CANONNAME: c_int = 0x0002; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 182889574eadd..3e093f93e6af7 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2711,7 +2711,7 @@ pub const ST_NOATIME: c_ulong = 1024; pub const ST_NODIRATIME: c_ulong = 2048; pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const RTLD_NODELETE: c_int = 0x1000; pub const RTLD_NOW: c_int = 0x2; @@ -2835,7 +2835,7 @@ pub const EFD_SEMAPHORE: c_int = 0x1; pub const LOG_NFACILITIES: c_int = 24; -pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32; pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32; diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs index e98a4c53ccfff..ee325a0247241 100644 --- a/src/unix/newlib/horizon/mod.rs +++ b/src/unix/newlib/horizon/mod.rs @@ -173,7 +173,7 @@ pub const AF_INET6: c_int = 23; pub const FIONBIO: c_ulong = 1; -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // For pthread get/setschedparam pub const SCHED_FIFO: c_int = 1; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs index 822b61989d479..62cd300e1d6f0 100644 --- a/src/unix/newlib/vita/mod.rs +++ b/src/unix/newlib/vita/mod.rs @@ -108,7 +108,7 @@ pub const POLLERR: c_short = 0x0008; pub const POLLHUP: c_short = 0x0010; pub const POLLNVAL: c_short = 0x0020; -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const SOL_SOCKET: c_int = 0xffff; pub const SO_NONBLOCK: c_int = 0x1100; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 69732d845b400..b71d3f61670bc 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -274,7 +274,7 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { }; // dlfcn.h -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // stdlib.h pub const EXIT_SUCCESS: i32 = 0; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 4446473a3ab3a..e87806e8109cc 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -353,7 +353,7 @@ pub const F_TLOCK: c_int = 2; pub const F_TEST: c_int = 3; // FIXME(redox): relibc { -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // } // dlfcn.h diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index f28e5ee7229ba..b03e8d6112e15 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -508,7 +508,7 @@ pub const EAI_SYSTEM: c_int = 11; // FIXME(vxworks): This is not defined in vxWorks, but we have to define it here // to make the building pass for getrandom and std -pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); //Clock Lib Stuff pub const CLOCK_REALTIME: c_int = 0x0; From b54fc43aa07d8624c1aa1b6877c22119ac07c582 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 19 Sep 2025 01:34:40 -0500 Subject: [PATCH 22/22] FreeBSD: update gating of `mcontext_t.mc_tlsbase` freebsd11 wasn't covered, meaning test failures on the 0.2 branch. Add freebsd11 to the pattern, and use `cfg(not(...))` rather than `cfg(freebsd15)`. (Ideally this would instead be encoded as something like `cfg(freebsd_least_15)`.) Fixes: 3d93bf589413 ("freebsd: Limit mcontext_t::mc_tlsbase to FreeBSD 15") (backport ) (cherry picked from commit d8b90d6aeba1f196c1fabf0983e5c5a9d4f5cf62) --- src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 29f11b039b080..a488f61adcf00 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -98,7 +98,7 @@ s_no_extra_traits! { } #[repr(align(16))] - #[non_exhaustive] + #[cfg_attr(not(any(freebsd11, freebsd12, freebsd13, freebsd14)), non_exhaustive)] pub struct mcontext_t { pub mc_onstack: register_t, pub mc_rdi: register_t, @@ -137,11 +137,13 @@ s_no_extra_traits! { pub mc_gsbase: register_t, pub mc_xfpustate: register_t, pub mc_xfpustate_len: register_t, - #[cfg(any(freebsd12, freebsd13, freebsd14))] + // freebsd < 15 + #[cfg(any(freebsd11, freebsd12, freebsd13, freebsd14))] pub mc_spare: [c_long; 4], - #[cfg(freebsd15)] + // freebsd >= 15 + #[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))] pub mc_tlsbase: register_t, - #[cfg(freebsd15)] + #[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))] pub mc_spare: [c_long; 3], } }