From 00d08b79844905811a0fbe7c01efc94ffa2f0fd1 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Thu, 7 Aug 2025 19:05:26 +0100 Subject: [PATCH 1/9] Add `sigqueue` (backport ) (cherry picked from commit 8c2810ab9fb53a6ee35b6b2eab643fba6dcf3af4) --- libc-test/semver/aix.txt | 1 + libc-test/semver/android.txt | 1 + libc-test/semver/cygwin.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/linux.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/redox.txt | 1 + libc-test/semver/solarish.txt | 1 + src/unix/mod.rs | 14 ++++++++++++++ 9 files changed, 22 insertions(+) diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index c8e0fe1c0d3e7..ac82c5576f34c 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -2473,6 +2473,7 @@ sigismember signal sigpending sigprocmask +sigqueue sigset_t sigsuspend sigtimedwait diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 96c77cb43c5ef..53ab742cf2a6a 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3985,6 +3985,7 @@ signalfd signalfd_siginfo sigpending sigprocmask +sigqueue sigset64_t sigset_t sigsuspend diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index 99e822ca62d18..a978f7312d9c3 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -844,6 +844,7 @@ settimeofday sigaltstack sigevent siginfo_t +sigqueue sigsuspend sigtimedwait sigwait diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 8150c6ae66913..e473b710231c4 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2376,6 +2376,7 @@ shmid_ds sigaltstack sigevent siginfo_t +sigqueue sigsuspend sigtimedwait sigwait diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index b82f33365a3d5..318cca51b482e 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -4298,6 +4298,7 @@ sigevent siginfo_t signalfd signalfd_siginfo +sigqueue sigsuspend sigtimedwait sigwait diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 3f7fb66c2efc8..07d9ead87c763 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1599,6 +1599,7 @@ shmid_ds sigaltstack sigevent siginfo_t +sigqueue sigsuspend sigtimedwait sigwait diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 3e09870a7a76a..eeba3a35a54ce 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -307,6 +307,7 @@ setgrent setpwent setrlimit setservent +sigqueue sigtimedwait sigwait strcasecmp diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt index cee5977fc35ee..9b1931c5a24f4 100644 --- a/libc-test/semver/solarish.txt +++ b/libc-test/semver/solarish.txt @@ -75,5 +75,6 @@ posix_spawnattr_setsigmask posix_spawnp recvmsg sendmsg +sigqueue strftime strftime_l diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 941f2faa99217..104758944317b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1661,6 +1661,20 @@ cfg_if! { } } +cfg_if! { + if #[cfg(not(any( + target_os = "dragonfly", + target_os = "emscripten", + target_os = "hurd", + target_os = "macos", + target_os = "openbsd", + )))] { + extern "C" { + pub fn sigqueue(pid: pid_t, sig: c_int, value: crate::sigval) -> c_int; + } + } +} + cfg_if! { if #[cfg(not(target_os = "android"))] { extern "C" { From f931fda5b1299c1674def4e7b881d333824b5a89 Mon Sep 17 00:00:00 2001 From: mbyx Date: Mon, 1 Sep 2025 20:38:08 +0500 Subject: [PATCH 2/9] libc: uncomment items that were commented due to old ctest (backport ) (cherry picked from commit 61b722e2517775cea98428702710ee9ef00f02a0) [ resolution needed for primitives - Trevor ] --- src/new/linux_uapi/linux/can.rs | 3 -- src/primitives.rs | 64 --------------------------------- src/unix/linux_like/mod.rs | 11 +++--- 3 files changed, 4 insertions(+), 74 deletions(-) diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 8e48b4a869bb8..b9479a63bacea 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -1,9 +1,6 @@ //! Header: `uapi/linux/can.h` -// FIXME(ctest): we shouldn't have to specify the path but garando doesn't find modules otherwise -#[path = "can/j1939.rs"] pub(crate) mod j1939; -#[path = "can/raw.rs"] pub(crate) mod raw; pub use j1939::*; diff --git a/src/primitives.rs b/src/primitives.rs index 307a5dafaa9cb..cec4f96f86eed 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -90,35 +90,6 @@ pub type uint64_t = u64; cfg_if! { if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { - // This introduces partial support for FFI with __int128 and - // equivalent types on platforms where Rust's definition is validated - // to match the standard C ABI of that platform. - // - // Rust does not guarantee u128/i128 are sound for FFI, and its - // definitions are in fact known to be incompatible. [0] - // - // However these problems aren't fundamental, and are just platform - // inconsistencies. Specifically at the time of this writing: - // - // * For x64 SysV ABIs (everything but Windows), the types are underaligned. - // * For all Windows ABIs, Microsoft doesn't actually officially define __int128, - // and as a result different implementations don't actually agree on its ABI. - // - // But on the other major aarch64 platforms (android, linux, ios, macos) we have - // validated that rustc has the right ABI for these types. This is important because - // aarch64 uses these types in some fundamental OS types like user_fpsimd_struct, - // which represents saved simd registers. - // - // Any API which uses these types will need to `#[ignore(improper_ctypes)]` - // until the upstream rust issue is resolved, but this at least lets us make - // progress on platforms where this type is important. - // - // The list of supported architectures and OSes is intentionally very restricted, - // as careful work needs to be done to verify that a particular platform - // has a conformant ABI. - // - // [0]: https://github.com/rust-lang/rust/issues/54341 - /// C `__int128` (a GCC extension that's part of many ABIs) pub type __int128 = i128; /// C `unsigned __int128` (a GCC extension that's part of many ABIs) @@ -127,40 +98,5 @@ cfg_if! { pub type __int128_t = i128; /// C __uint128_t (alternate name for [__uint128][]) pub type __uint128_t = u128; - - // NOTE: if you add more platforms to here, you may need to cfg - // these consts. They should always match the platform's values - // for `sizeof(__int128)` and `_Alignof(__int128)`. - const _SIZE_128: usize = 16; - const _ALIGN_128: usize = 16; - - // FIXME(ctest): ctest doesn't handle `_` as an identifier so these tests are temporarily - // disabled. - // macro_rules! static_assert_eq { - // ($a:expr, $b:expr) => { - // const _: [(); $a] = [(); $b]; - // }; - // } - // - // // Since Rust doesn't officially guarantee that these types - // // have compatible ABIs, we const assert that these values have the - // // known size/align of the target platform's libc. If rustc ever - // // tries to regress things, it will cause a compilation error. - // // - // // This isn't a bullet-proof solution because e.g. it doesn't - // // catch the fact that llvm and gcc disagree on how x64 __int128 - // // is actually *passed* on the stack (clang underaligns it for - // // the same reason that rustc *never* properly aligns it). - // static_assert_eq!(size_of::<__int128>(), _SIZE_128); - // static_assert_eq!(align_of::<__int128>(), _ALIGN_128); - - // static_assert_eq!(size_of::<__uint128>(), _SIZE_128); - // static_assert_eq!(align_of::<__uint128>(), _ALIGN_128); - - // static_assert_eq!(size_of::<__int128_t>(), _SIZE_128); - // static_assert_eq!(align_of::<__int128_t>(), _ALIGN_128); - - // static_assert_eq!(size_of::<__uint128_t>(), _SIZE_128); - // static_assert_eq!(align_of::<__uint128_t>(), _ALIGN_128); } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 5a6dd61f53566..29f13fb37313e 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1746,13 +1746,10 @@ cfg_if! { /// Build an ioctl number, analogous to the C macro of the same name. const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> Ioctl { - // FIXME(ctest) the `garando_syntax` crate (used by ctest in the CI test suite) - // cannot currently parse these `debug_assert!`s - // - // debug_assert!(dir <= _IOC_DIRMASK); - // debug_assert!(ty <= _IOC_TYPEMASK); - // debug_assert!(nr <= _IOC_NRMASK); - // debug_assert!(size <= (_IOC_SIZEMASK as usize)); + core::debug_assert!(dir <= _IOC_DIRMASK); + core::debug_assert!(ty <= _IOC_TYPEMASK); + core::debug_assert!(nr <= _IOC_NRMASK); + core::debug_assert!(size <= (_IOC_SIZEMASK as usize)); ((dir << _IOC_DIRSHIFT) | (ty << _IOC_TYPESHIFT) From 75709054ef6009ab8f1a6d49a6c201ddb5a36b72 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 22 Sep 2025 20:35:22 -0500 Subject: [PATCH 3/9] FreeBSD: deprecate TIOCMGDTRWAIT and TIOCMSDTRWAIT These constants were removed on `main` in ec605ffa5477 ("libc: fix ctest failure on freebsd15"). Mark them as deprecated with 0.2 rather than removing directly. Effectively a backport of https://github.com/rust-lang/libc/pull/4685. --- libc-test/build.rs | 3 +++ src/unix/bsd/freebsdlike/mod.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 53c2b2ad6f549..abf5da9cee334 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2832,6 +2832,9 @@ fn test_freebsd(target: &str) { // Added in FreeBSD 14.2 "SO_SPLICE" if Some(14) > freebsd_ver => true, + // FIXME(deprecated): deprecated in 0.2, removed in main + "TIOCMGDTRWAIT" | "TIOCMSDTRWAIT" => true, + _ => false, } }); diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index d093847f8983e..713f44fabbdd8 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1238,7 +1238,15 @@ pub const TIOCGETD: c_ulong = 0x4004741a; pub const TIOCSETD: c_ulong = 0x8004741b; pub const TIOCGDRAINWAIT: c_ulong = 0x40047456; pub const TIOCSDRAINWAIT: c_ulong = 0x80047457; +#[cfg_attr( + not(target_os = "dragonfly"), + deprecated = "unused since FreeBSD 8, removed in FreeBSD 15" +)] pub const TIOCMGDTRWAIT: c_ulong = 0x4004745a; +#[cfg_attr( + not(target_os = "dragonfly"), + deprecated = "unused since FreeBSD 8, removed in FreeBSD 15" +)] pub const TIOCMSDTRWAIT: c_ulong = 0x8004745b; pub const TIOCDRAIN: c_ulong = 0x2000745e; pub const TIOCEXT: c_ulong = 0x80047460; From 5c5dca400436233c1a685278ccbc5535cb480ae0 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 12 Sep 2025 14:50:20 -0600 Subject: [PATCH 4/9] Remove some mask constants from FreeBSD These are bitmasks that are intended to be used within the kernel. New features may widen them, so their values aren't stable. They probably don't have any legitimate uses in userland. And their values have changed in FreeBSD 15, which is causing CI failures. https://github.com/freebsd/freebsd-src/commit/eea3e4dd9703a252509d75814049aa8da5007ebb https://github.com/freebsd/freebsd-src/commit/851dc7f859c23cab09a348bca03ab655534fb7e0 (backport ) (cherry picked from commit fbfa2929cf723edb5a975a9488ca3de972b10610) --- libc-test/semver/freebsd-x86_64.txt | 1 - libc-test/semver/freebsd.txt | 2 -- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 -- src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 1 - 4 files changed, 6 deletions(-) diff --git a/libc-test/semver/freebsd-x86_64.txt b/libc-test/semver/freebsd-x86_64.txt index 14ddc25a1b254..a785644bd5cd2 100644 --- a/libc-test/semver/freebsd-x86_64.txt +++ b/libc-test/semver/freebsd-x86_64.txt @@ -1,7 +1,6 @@ Elf64_Auxinfo KINFO_FILE_SIZE MAP_32BIT -_MC_FLAG_MASK _MC_FPFMT_NODEV _MC_FPFMT_XMM _MC_FPOWNED_FPU diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index e473b710231c4..01a659fa52883 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -683,8 +683,6 @@ JAIL_API_VERSION JAIL_ATTACH JAIL_CREATE JAIL_DYING -JAIL_GET_MASK -JAIL_SET_MASK JAIL_SYS_DISABLE JAIL_SYS_INHERIT JAIL_SYS_NEW diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 54a9ec5ab546f..a23eee3b8bb16 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -2950,8 +2950,6 @@ pub const JAIL_CREATE: c_int = 0x01; pub const JAIL_UPDATE: c_int = 0x02; pub const JAIL_ATTACH: c_int = 0x04; pub const JAIL_DYING: c_int = 0x08; -pub const JAIL_SET_MASK: c_int = 0x0f; -pub const JAIL_GET_MASK: c_int = 0x08; pub const JAIL_SYS_DISABLE: c_int = 0; pub const JAIL_SYS_NEW: c_int = 1; pub const JAIL_SYS_INHERIT: c_int = 2; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index a488f61adcf00..d665e3da01e87 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -334,7 +334,6 @@ pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 pub const _MC_HASSEGS: u32 = 0x1; pub const _MC_HASBASES: u32 = 0x2; pub const _MC_HASFPXSTATE: u32 = 0x4; -pub const _MC_FLAG_MASK: u32 = _MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE; pub const _MC_FPFMT_NODEV: c_long = 0x10000; pub const _MC_FPFMT_XMM: c_long = 0x10002; From f63029d4c577a353c974f4d894e8f1cfe7da5255 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 12 Sep 2025 14:34:17 -0600 Subject: [PATCH 5/9] Switch the FreeBSD 15 CI image to FreeBSD-15.0-ALPHA3 . (backport ) (cherry picked from commit d52be204dcb9957fd5fda35c6e20eab32581f4b4) --- .cirrus.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index fb627124e5b67..8caefcbb28a12 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -21,7 +21,7 @@ task: image: freebsd-14-3-release-amd64-ufs - name: nightly freebsd-15 x86_64 freebsd_instance: - image_family: freebsd-15-0-snap + image: freebsd-15-0-alpha3-amd64-ufs setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh From 103b87853d457048e7dbf44a820238098336fe72 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 13 Sep 2025 17:20:34 -0600 Subject: [PATCH 6/9] On FreeBSD, set the ELF symbol version for readdir_r This function will probably be removed in FreeBSD 16. But the old symbol will remain, for backwards-compatibility. Set the symbol version now, so that the current version of libc will still be able to compile on future versions of FreeBSD. (backport ) (cherry picked from commit 3908285c37960434ea6ffcff6624ccf20c5e57a4) --- src/unix/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 104758944317b..b3ac89e9a889e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1745,6 +1745,10 @@ cfg_if! { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "readdir_r@FBSD_1.0" )] + #[cfg_attr( + all(target_os = "freebsd", not(any(freebsd11, freebsd10))), + link_name = "readdir_r@FBSD_1.5" + )] #[allow(non_autolinks)] // FIXME(docs): `<>` breaks line length limit. /// The 64-bit libc on Solaris and illumos only has readdir_r. If a /// 32-bit Solaris or illumos target is ever created, it should use From d63e5c36274f867e50af16373f69a9bd8e066a0d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 12 Sep 2025 19:11:39 +0100 Subject: [PATCH 7/9] Fix gid_t/uid_t types for redox. ref https://github.com/rust-lang/libc/issues/4678 (backport ) (cherry picked from commit f87a548bab6606c37102dce1d18f7045c447c724) [ update link in message to be absolute - Trevor ] --- src/unix/redox/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index d9502386dcae8..42c534c949fa9 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -29,8 +29,8 @@ pub type tcflag_t = u32; pub type time_t = c_longlong; pub type id_t = c_uint; pub type pid_t = usize; -pub type uid_t = u32; -pub type gid_t = u32; +pub type uid_t = c_int; +pub type gid_t = c_int; #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} From c330ab60a94bf92d7a86bc7397760769ab63b6d7 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 11 Apr 2025 19:28:48 +0000 Subject: [PATCH 8/9] Disable release-pr for now This started failing on `libc-0.2` because the release PR doesn't work there either. I am unsure why it did work before. (cherry picked from commit d92334c0a7b9af7c05870308f2e9eaf1390e4d98) --- .github/workflows/publish_0.2.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish_0.2.yml b/.github/workflows/publish_0.2.yml index 5ad1e97e1c1dc..00d5a7792a548 100644 --- a/.github/workflows/publish_0.2.yml +++ b/.github/workflows/publish_0.2.yml @@ -27,3 +27,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + with: + # FIXME(release): release-pr is broken since we have two release tracks for + # `libc` :( + command: release From d7c88b68eb7cea0e5ab99c245925973eb530f9ec Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 28 Aug 2025 20:31:31 +0200 Subject: [PATCH 9/9] add `qsort_r` for unix, and `qsort` and `qsort_s` for windows (backport ) (cherry picked from commit ab36ccbe870804ff7fc9293e6e4264280411841b) --- libc-test/semver/apple.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/windows.txt | 2 ++ src/unix/bsd/apple/mod.rs | 8 ++++++++ src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 12 ++++++++++++ src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 9 +++++++++ src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs | 9 +++++++++ src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 8 ++++++++ src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 8 ++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 8 ++++++++ src/windows/mod.rs | 13 +++++++++++++ 12 files changed, 80 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 33f3682d36262..9301252dcc949 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2231,6 +2231,7 @@ ptrace pututxline pwritev qsort +qsort_r querylocale quotactl radvisory diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 01a659fa52883..74ea7dad541e0 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2247,6 +2247,7 @@ ptsname_r pututxline pwritev qsort +qsort_r querylocale rallocx rand diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 07d9ead87c763..4280ec02de730 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1536,6 +1536,7 @@ ptrace_siginfo pututxline pwritev qsort +qsort_r rand readdir_r readlinkat diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index 281a13bb73034..a91794bed52ef 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -275,6 +275,8 @@ putchar putenv putenv_s puts +qsort +qsort_s raise rand read diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index a4e0a4c7c9424..0729c0db1e7dd 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -6157,6 +6157,14 @@ extern "C" { search_path: *const c_char, argv: *const *mut c_char, ) -> c_int; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); } #[allow(deprecated)] diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 9705e300bd9ac..64949e5f0daeb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -424,6 +424,18 @@ extern "C" { // in FreeBSD 12 pub fn dirname(path: *const c_char) -> *mut c_char; pub fn basename(path: *const c_char) -> *mut c_char; + + // Argument order of the function pointer changed in FreeBSD 14. From 14 onwards the signature + // matches the POSIX specification by having the third argument be a mutable pointer, on + // earlier versions the first argument is the mutable pointer. + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 005b26894cc81..ab7d3fb41317e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -468,6 +468,15 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 5c40a355fb95b..ff55933938f54 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -507,6 +507,15 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); } #[link(name = "kvm")] diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 4a65d59d5f3b1..3f23f05f5907f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -509,6 +509,14 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); } #[link(name = "kvm")] diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 778c5ee018e34..cc8d895331f0c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -511,6 +511,14 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); } #[link(name = "kvm")] diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 57549d01236e9..5975cbad4f0ed 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2761,6 +2761,14 @@ extern "C" { new_value: *const itimerspec, old_value: *mut itimerspec, ) -> c_int; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); } #[link(name = "rt")] diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 5cafc855f78a0..2703729fac5bf 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -297,6 +297,19 @@ extern "C" { pub fn isblank(c: c_int) -> c_int; pub fn tolower(c: c_int) -> c_int; pub fn toupper(c: c_int) -> c_int; + pub fn qsort( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + ); + pub fn qsort_s( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; pub fn fflush(file: *mut FILE) -> c_int;