From 466516ddee87e05bcdadc09148496639d694c39b Mon Sep 17 00:00:00 2001 From: Harry Stern Date: Thu, 7 Sep 2023 00:27:49 -0400 Subject: [PATCH 01/41] Move all seccomp consts and structs into top-level mod Seccomp constants and structs were partially defined in the top-level mod.rs for linux and partially outside. This commit moves everything into the top-level mod and adds missing entries as of linux 6.4.12. Signed-off-by: Harry Stern --- libc-test/build.rs | 24 +++++++++++ libc-test/semver/linux.txt | 18 +++++++- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 11 ----- src/unix/linux_like/linux/gnu/b32/csky/mod.rs | 5 --- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 10 ----- .../linux_like/linux/gnu/b64/aarch64/mod.rs | 10 ----- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 11 ----- src/unix/linux_like/linux/mod.rs | 42 +++++++++++++++++++ 8 files changed, 82 insertions(+), 49 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e9178a0a41499..bddeb132fb15a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3520,6 +3520,19 @@ fn test_linux(target: &str) { if musl && ty.starts_with("uinput_") { return true; } + if musl && ty == "seccomp_notif" { + return true; + } + if musl && ty == "seccomp_notif_addfd" { + return true; + } + if musl && ty == "seccomp_notif_resp" { + return true; + } + if musl && ty == "seccomp_notif_sizes" { + return true; + } + // LFS64 types have been removed in musl 1.2.4+ if musl && (ty.ends_with("64") || ty.ends_with("64_t")) { return true; @@ -3648,6 +3661,17 @@ fn test_linux(target: &str) { } } if musl { + // FIXME: Requires >= 5.0 kernel headers + if name == "SECCOMP_GET_NOTIF_SIZES" + || name == "SECCOMP_FILTER_FLAG_NEW_LISTENER" + || name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH" + || name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5 + || name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9 + || name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9 + || name == "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" // requires >= 5.19 + { + return true; + } // FIXME: Requires >= 5.4.1 kernel headers if name.starts_with("J1939") || name.starts_with("RTEXT_FILTER_") diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 1957a7d657d7c..ced81a70df631 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2373,23 +2373,33 @@ SCTP_STATUS SCTP_STREAM_RESET_INCOMING SCTP_STREAM_RESET_OUTGOING SCTP_UNORDERED +SECCOMP_ADDFD_FLAG_SEND +SECCOMP_ADDFD_FLAG_SETFD SECCOMP_FILTER_FLAG_LOG +SECCOMP_FILTER_FLAG_NEW_LISTENER SECCOMP_FILTER_FLAG_SPEC_ALLOW SECCOMP_FILTER_FLAG_TSYNC +SECCOMP_FILTER_FLAG_TSYNC_ESRCH +SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV +SECCOMP_GET_ACTION_AVAIL +SECCOMP_GET_NOTIF_SIZES SECCOMP_MODE_DISABLED -SECCOMP_MODE_FILTER SECCOMP_MODE_STRICT +SECCOMP_MODE_FILTER SECCOMP_RET_ACTION SECCOMP_RET_ACTION_FULL SECCOMP_RET_ALLOW SECCOMP_RET_DATA SECCOMP_RET_ERRNO -SECCOMP_RET_KILL SECCOMP_RET_KILL_PROCESS SECCOMP_RET_KILL_THREAD +SECCOMP_RET_KILL SECCOMP_RET_LOG SECCOMP_RET_TRACE SECCOMP_RET_TRAP +SECCOMP_SET_MODE_FILTER +SECCOMP_SET_MODE_STRICT +SECCOMP_USER_NOTIF_FLAG_CONTINUE SEEK_DATA SEEK_HOLE SELFMAG @@ -3500,6 +3510,10 @@ sched_setparam sched_setscheduler sctp_assoc_t seccomp_data +seccomp_notif +seccomp_notif_addfd +seccomp_notif_resp +seccomp_notif_sizes seed48 seekdir sem_close diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 9b3a2ff861731..89c93aba8818e 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -162,12 +162,6 @@ s! { pub ss_size: ::size_t } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } - pub struct mcontext_t { pub trap_no: ::c_ulong, pub error_code: ::c_ulong, @@ -466,11 +460,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 9807cea831021..5e92e30073bee 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -415,11 +415,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index a3531c141fdb6..27f477bb48f85 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -236,11 +236,6 @@ s! { pub ss_size: ::size_t } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } } s_no_extra_traits! { @@ -1090,11 +1085,6 @@ pub const REG_EFL: ::c_int = 16; pub const REG_UESP: ::c_int = 17; pub const REG_SS: ::c_int = 18; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 206283e22f6b2..284a1788f4409 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -197,11 +197,6 @@ s! { pub ss_size: ::size_t } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } } pub const VEOF: usize = 4; @@ -513,11 +508,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 9b2aac5c2ba34..609c74429c5bc 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -260,12 +260,6 @@ s! { __unused5: u64 } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } - pub struct ptrace_rseq_configuration { pub rseq_abi_pointer: ::__u64, pub rseq_abi_size: ::__u32, @@ -803,11 +797,6 @@ pub const REG_TRAPNO: ::c_int = 20; pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 07e6e420d3532..d76dd752057f6 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -578,6 +578,34 @@ s! { pub args: [::__u64; 6], } + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } + + pub struct seccomp_notif { + pub id: ::__u64, + pub pid: ::__u32, + pub flags: ::__u32, + pub data: seccomp_data, + } + + pub struct seccomp_notif_resp { + pub id: ::__u64, + pub val: ::__s64, + pub error: ::__s32, + pub flags: ::__u32, + } + + pub struct seccomp_notif_addfd { + pub id: ::__u64, + pub flags: ::__u32, + pub srcfd: ::__u32, + pub newfd: ::__u32, + pub newfd_flags: ::__u32, + } + pub struct nlmsghdr { pub nlmsg_len: u32, pub nlmsg_type: u16, @@ -2272,13 +2300,22 @@ pub const GRND_NONBLOCK: ::c_uint = 0x0001; pub const GRND_RANDOM: ::c_uint = 0x0002; pub const GRND_INSECURE: ::c_uint = 0x0004; +// pub const SECCOMP_MODE_DISABLED: ::c_uint = 0; pub const SECCOMP_MODE_STRICT: ::c_uint = 1; pub const SECCOMP_MODE_FILTER: ::c_uint = 2; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + pub const SECCOMP_FILTER_FLAG_TSYNC: ::c_ulong = 1; pub const SECCOMP_FILTER_FLAG_LOG: ::c_ulong = 2; pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: ::c_ulong = 4; +pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: ::c_ulong = 8; +pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: ::c_ulong = 16; +pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: ::c_ulong = 32; pub const SECCOMP_RET_KILL_PROCESS: ::c_uint = 0x80000000; pub const SECCOMP_RET_KILL_THREAD: ::c_uint = 0x00000000; @@ -2293,6 +2330,11 @@ pub const SECCOMP_RET_ACTION_FULL: ::c_uint = 0xffff0000; pub const SECCOMP_RET_ACTION: ::c_uint = 0x7fff0000; pub const SECCOMP_RET_DATA: ::c_uint = 0x0000ffff; +pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: ::c_ulong = 1; + +pub const SECCOMP_ADDFD_FLAG_SETFD: ::c_ulong = 1; +pub const SECCOMP_ADDFD_FLAG_SEND: ::c_ulong = 2; + pub const ITIMER_REAL: ::c_int = 0; pub const ITIMER_VIRTUAL: ::c_int = 1; pub const ITIMER_PROF: ::c_int = 2; From 7cdb213c063c414427897b4b40618d9941d01369 Mon Sep 17 00:00:00 2001 From: Patrick Mooney Date: Wed, 9 Aug 2023 19:40:03 +0000 Subject: [PATCH 02/41] Fix libc-tests for illumos/solaris target --- libc-test/build.rs | 10 ++++++++++ src/unix/solarish/mod.rs | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 6fbaa5b6b1f63..d8f97d253a667 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1008,6 +1008,10 @@ fn test_solarish(target: &str) { "madvise" | "mprotect" if is_illumos => true, "door_call" | "door_return" | "door_create" if is_illumos => true, + // The compat functions use these "native" functions linked to their + // non-prefixed implementations in libc. + "native_getpwent_r" | "native_getgrent_r" => true, + // Not visible when build with _XOPEN_SOURCE=700 "mmapobj" | "mmap64" | "meminfo" | "getpagesizes" | "getpagesizes2" => true, @@ -1016,6 +1020,12 @@ fn test_solarish(target: &str) { // value is not useful (always 0) so we can ignore it: "setservent" | "endservent" if is_illumos => true, + // Following illumos#3729, getifaddrs was changed to a + // redefine_extname symbol in order to preserve compatibility. + // Until better symbol binding story is figured out, it must be + // excluded from the tests. + "getifaddrs" if is_illumos => true, + _ => false, } }); diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 04dde54cf3649..15faabd21ee3f 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -3203,9 +3203,9 @@ extern "C" { pub fn sync(); - fn __major(version: ::c_int, devnum: ::dev_t) -> ::major_t; - fn __minor(version: ::c_int, devnum: ::dev_t) -> ::minor_t; - fn __makedev(version: ::c_int, majdev: ::major_t, mindev: ::minor_t) -> ::dev_t; + pub fn __major(version: ::c_int, devnum: ::dev_t) -> ::major_t; + pub fn __minor(version: ::c_int, devnum: ::dev_t) -> ::minor_t; + pub fn __makedev(version: ::c_int, majdev: ::major_t, mindev: ::minor_t) -> ::dev_t; } #[link(name = "sendfile")] From a693257dd93a331e7752bab7d9abd0011f530292 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 28 Nov 2023 23:02:01 +0100 Subject: [PATCH 03/41] Do not dereference uninhabited types refs in Clone implementations A reference to an uninhabited type should never be dereferenced: this is UB. `Copy` should not be implemented on such a type, and an upcoming Clippy lint (`uninhabited_reference`) may flag such dereferences as suspicious. Since those types are not structs, they do not need to get `Copy` and `Clone` implementations. A `missing!` macro limits code duplication. --- src/macros.rs | 6 ++++++ src/unix/linux_like/linux/mod.rs | 10 +++------- src/unix/linux_like/mod.rs | 10 +++------- src/unix/mod.rs | 30 ++++++++---------------------- 4 files changed, 20 insertions(+), 36 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index fd473702f72bd..beb80024dbfa3 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -120,6 +120,12 @@ macro_rules! s_no_extra_traits { ); } +macro_rules! missing { + ($($(#[$attr:meta])* pub enum $i:ident {})*) => ($( + $(#[$attr])* #[allow(missing_copy_implementations)] pub enum $i { } + )*); +} + macro_rules! e { ($($(#[$attr:meta])* pub enum $i:ident { $($field:tt)* })*) => ($( __item! { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 186c740e7e110..b763ab6261bb9 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -53,13 +53,9 @@ pub type iconv_t = *mut ::c_void; pub type sctp_assoc_t = ::__s32; pub type eventfd_t = u64; -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos64_t {} // FIXME: fill this out with a struct -impl ::Copy for fpos64_t {} -impl ::Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum fpos64_t {} // FIXME: fill this out with a struct } s! { diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 26fd68de49c7c..35c7598c911d8 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -6,13 +6,9 @@ pub type timer_t = *mut ::c_void; pub type key_t = ::c_int; pub type id_t = ::c_uint; -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum timezone {} -impl ::Copy for timezone {} -impl ::Clone for timezone { - fn clone(&self) -> timezone { - *self - } +missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum timezone {} } s! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index fc905cfcc6589..3dca83305ad59 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -41,13 +41,9 @@ cfg_if! { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum DIR {} -impl ::Copy for DIR {} -impl ::Clone for DIR { - fn clone(&self) -> DIR { - *self - } +missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum DIR {} } pub type locale_t = *mut ::c_void; @@ -414,21 +410,11 @@ cfg_if! { } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum FILE {} -impl ::Copy for FILE {} -impl ::Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum fpos_t {} // FIXME: fill this out with a struct -impl ::Copy for fpos_t {} -impl ::Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +missing! { + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum FILE {} + #[cfg_attr(feature = "extra_traits", derive(Debug))] + pub enum fpos_t {} // FIXME: fill this out with a struct } extern "C" { From 86cc2b8cdbe2f9eada7c95c31ba43b5e4c739736 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 29 Nov 2023 12:44:02 +0000 Subject: [PATCH 04/41] adding RFSIGSHARE flag for FreeBSD's rfork --- libc-test/semver/freebsd.txt | 1 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index b9fc7a6a5773e..9f436ced22a81 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1100,6 +1100,7 @@ RFLINUXTHPN RFMEM RFNOWAIT RFPROC +RFSIGSHARE RFSPAWN RFTHREAD RFTSIGZMB diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index feaabc5b9b78b..799e3811ed44c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3891,6 +3891,7 @@ pub const RFMEM: ::c_int = 32; pub const RFNOWAIT: ::c_int = 64; pub const RFCFDG: ::c_int = 4096; pub const RFTHREAD: ::c_int = 8192; +pub const RFSIGSHARE: ::c_int = 16384; pub const RFLINUXTHPN: ::c_int = 65536; pub const RFTSIGZMB: ::c_int = 524288; pub const RFSPAWN: ::c_int = 2147483648; From ab0c1df54bafb7e1b30dd0c2b2b19c96c25111aa Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 29 Nov 2023 22:33:33 +0900 Subject: [PATCH 05/41] Update docs for contributors --- .github/PULL_REQUEST_TEMPLATE.md | 11 +++++++---- CONTRIBUTING.md | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3e49d7473fdc5..70ed1ca355300 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,14 @@ Thanks for considering submitting a PR! +We have the [contribution guide](https://github.com/rust-lang/libc/blob/main/CONTRIBUTING.md). Please read it if you're new here! + Here's a checklist for things that will be checked during review or continuous integration. -- \[ ] Edit corresponding file(s) under `libc-test/semver` when you add/remove item(s) -- \[ ] Your PR doesn't contain any *unstable* values like `*LAST` or `*MAX` (see [#3131](https://github.com/rust-lang/libc/issues/3131)) -- \[ ] If your PR increments version number, it must not contain any other changes -- \[ ] `rustc ci/style.rs && ./style src` +- \[ ] Edit corresponding file(s) under `libc-test/semver` when you add/remove item(s), e.g. edit `linux.txt` if you add an item to `src/unix/linux_like/linux/mod.rs` +- \[ ] Your PR doesn't contain any private or *unstable* values like `*LAST` or `*MAX` (see [#3131](https://github.com/rust-lang/libc/issues/3131)) +- \[ ] If your PR has a breaking change, please clarify it +- \[ ] If your PR increments version number, it must NOT contain any other changes (otherwise a release could be delayed) +- \[ ] Make sure `ci/style.sh` passes - \[ ] `cd libc-test && cargo test` - (this might fail on your env due to environment difference between your env and CI. Ignore failures if you are not sure) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c551dbdb576e..d487162a5fd5d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,7 @@ We have two automated tests running on [GitHub Actions](https://github.com/rust- - `cd libc-test && cargo test` - Use the `skip_*()` functions in `build.rs` if you really need a workaround. 2. Style checker - - `rustc ci/style.rs && ./style src` + - [`sh ci/style.sh`](https://github.com/rust-lang/libc/blob/main/ci/style.sh) ## Breaking change policy From 6fb545a7939ff6f243cceece87897893cf517333 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 25 Nov 2023 20:42:52 +0000 Subject: [PATCH 06/41] expose solarish's SFV_FD_SELF for sendfilev purpose --- src/unix/solarish/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 15faabd21ee3f..c34ff890b412a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2588,6 +2588,9 @@ const _CMSG_DATA_ALIGNMENT: usize = ::mem::size_of::<::c_int>(); const NEWDEV: ::c_int = 1; +// sys/sendfile.h +pub const SFV_FD_SELF: ::c_int = -2; + const_fn! { {const} fn _CMSG_HDR_ALIGN(p: usize) -> usize { (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) From b20ecccc48b1cec4bf038992dabc23037cb4c2f8 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Fri, 1 Dec 2023 20:56:03 +0800 Subject: [PATCH 07/41] MAP_HUGE_SHIFT & HUGETLB_FLAG_ENCODE_SHIFT for Andorid/Fuchsia --- libc-test/semver/android.txt | 2 ++ libc-test/semver/fuchsia.txt | 2 ++ src/fuchsia/mod.rs | 3 +++ src/unix/linux_like/android/mod.rs | 2 ++ 4 files changed, 9 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index b6fbc7578388d..a7c235eefb3ed 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3766,3 +3766,5 @@ dirname basename eventfd_read eventfd_write +HUGETLB_FLAG_ENCODE_SHIFT +MAP_HUGE_SHIFT diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index cf3c4a10d63e1..c876cc6a5b812 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1472,3 +1472,5 @@ utimensat vhangup vmsplice waitid +HUGETLB_FLAG_ENCODE_SHIFT +MAP_HUGE_SHIFT diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 7e76db6f1f7d5..25124e6e0fcf8 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3233,6 +3233,9 @@ pub const O_DIRECT: ::c_int = 0x00000800; pub const O_LARGEFILE: ::c_int = 0x00001000; pub const O_NOFOLLOW: ::c_int = 0x00000080; +pub const HUGETLB_FLAG_ENCODE_SHIFT: u32 = 26; +pub const MAP_HUGE_SHIFT: u32 = 26; + // intentionally not public, only used for fd_set cfg_if! { if #[cfg(target_pointer_width = "32")] { diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index c27044f0e5dde..999a15440d12c 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3320,6 +3320,8 @@ pub const NET_SCTP: ::c_int = 17; pub const NET_LLC: ::c_int = 18; pub const NET_NETFILTER: ::c_int = 19; pub const NET_DCCP: ::c_int = 20; +pub const HUGETLB_FLAG_ENCODE_SHIFT: ::c_int = 26; +pub const MAP_HUGE_SHIFT: ::c_int = HUGETLB_FLAG_ENCODE_SHIFT; // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions From a226203e58a043bcc88deeb9068064206a5816b3 Mon Sep 17 00:00:00 2001 From: Sword-Destiny Date: Wed, 6 Dec 2023 17:58:32 +0800 Subject: [PATCH 08/41] add pthread_cond_timedwait for teeos --- src/teeos/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index cffe041976573..066f81ca55e4c 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -1106,6 +1106,12 @@ extern "C" { pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const ::timespec, + ) -> ::c_int; + pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: c_int) -> c_int; pub fn pthread_create( From 70e2e5ecf571e386dd6f25670d0c978ded8916ee Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 8 Dec 2023 22:54:05 +0000 Subject: [PATCH 09/41] netbsd arm* registers and reorder per architecture. --- libc-test/semver/netbsd-aarch64.txt | 57 ++++++++++++++++++++++ libc-test/semver/netbsd-x86_64.txt | 24 +++++++++ src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 59 +++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/arm.rs | 59 +++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 27 ----------- src/unix/bsd/netbsdlike/netbsd/x86_64.rs | 27 +++++++++++ 6 files changed, 226 insertions(+), 27 deletions(-) diff --git a/libc-test/semver/netbsd-aarch64.txt b/libc-test/semver/netbsd-aarch64.txt index e48c529a96c72..e1cdec5d0af24 100644 --- a/libc-test/semver/netbsd-aarch64.txt +++ b/libc-test/semver/netbsd-aarch64.txt @@ -1,3 +1,60 @@ +_REG_CPSR +_REG_ELR +_REG_FP +_REG_LR +_REG_PC +_REG_R0 +_REG_R1 +_REG_R10 +_REG_R11 +_REG_R12 +_REG_R13 +_REG_R14 +_REG_R15 +_REG_R2 +_REG_R3 +_REG_R4 +_REG_R5 +_REG_R6 +_REG_R7 +_REG_R8 +_REG_R9 +_REG_RV +_REG_SP +_REG_SPSR +_REG_TIPDR +_REG_X0 +_REG_X1 +_REG_X2 +_REG_X3 +_REG_X4 +_REG_X5 +_REG_X6 +_REG_X7 +_REG_X8 +_REG_X9 +_REG_X10 +_REG_X11 +_REG_X12 +_REG_X13 +_REG_X14 +_REG_X15 +_REG_X16 +_REG_X17 +_REG_X18 +_REG_X19 +_REG_X20 +_REG_X21 +_REG_X22 +_REG_X23 +_REG_X24 +_REG_X25 +_REG_X26 +_REG_X27 +_REG_X28 +_REG_X29 +_REG_X30 +_REG_X31 PT_GETFPREGS PT_GETREGS PT_SETFPREGS diff --git a/libc-test/semver/netbsd-x86_64.txt b/libc-test/semver/netbsd-x86_64.txt index 573099c8bb69b..0931370eeaecd 100644 --- a/libc-test/semver/netbsd-x86_64.txt +++ b/libc-test/semver/netbsd-x86_64.txt @@ -1,4 +1,28 @@ Aux64Info +_REG_DS +_REG_ERR +_REG_ES +_REG_FS +_REG_GS +_REG_R10 +_REG_R11 +_REG_R12 +_REG_R13 +_REG_R14 +_REG_R15 +_REG_R8 +_REG_R9 +_REG_RAX +_REG_RBP +_REG_RBX +_REG_RCX +_REG_RDI +_REG_RFLAGS +_REG_RIP +_REG_RSI +_REG_RSP +_REG_SS +_REG_TRAPNO PT_GETFPREGS PT_GETREGS PT_SETFPREGS diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index 7b895f63238d0..45bca4778c20c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -101,3 +101,62 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 2; pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 3; + +pub const _REG_R0: ::c_int = 0; +pub const _REG_R1: ::c_int = 1; +pub const _REG_R2: ::c_int = 2; +pub const _REG_R3: ::c_int = 3; +pub const _REG_R4: ::c_int = 4; +pub const _REG_R5: ::c_int = 5; +pub const _REG_R6: ::c_int = 6; +pub const _REG_R7: ::c_int = 7; +pub const _REG_R8: ::c_int = 8; +pub const _REG_R9: ::c_int = 9; +pub const _REG_R10: ::c_int = 10; +pub const _REG_R11: ::c_int = 11; +pub const _REG_R12: ::c_int = 12; +pub const _REG_R13: ::c_int = 13; +pub const _REG_R14: ::c_int = 14; +pub const _REG_R15: ::c_int = 15; +pub const _REG_CPSR: ::c_int = 16; +pub const _REG_X0: ::c_int = 0; +pub const _REG_X1: ::c_int = 1; +pub const _REG_X2: ::c_int = 2; +pub const _REG_X3: ::c_int = 3; +pub const _REG_X4: ::c_int = 4; +pub const _REG_X5: ::c_int = 5; +pub const _REG_X6: ::c_int = 6; +pub const _REG_X7: ::c_int = 7; +pub const _REG_X8: ::c_int = 8; +pub const _REG_X9: ::c_int = 9; +pub const _REG_X10: ::c_int = 10; +pub const _REG_X11: ::c_int = 11; +pub const _REG_X12: ::c_int = 12; +pub const _REG_X13: ::c_int = 13; +pub const _REG_X14: ::c_int = 14; +pub const _REG_X15: ::c_int = 15; +pub const _REG_X16: ::c_int = 16; +pub const _REG_X17: ::c_int = 17; +pub const _REG_X18: ::c_int = 18; +pub const _REG_X19: ::c_int = 19; +pub const _REG_X20: ::c_int = 20; +pub const _REG_X21: ::c_int = 21; +pub const _REG_X22: ::c_int = 22; +pub const _REG_X23: ::c_int = 23; +pub const _REG_X24: ::c_int = 24; +pub const _REG_X25: ::c_int = 25; +pub const _REG_X26: ::c_int = 26; +pub const _REG_X27: ::c_int = 27; +pub const _REG_X28: ::c_int = 28; +pub const _REG_X29: ::c_int = 29; +pub const _REG_X30: ::c_int = 30; +pub const _REG_X31: ::c_int = 31; +pub const _REG_ELR: ::c_int = 32; +pub const _REG_SPSR: ::c_int = 33; +pub const _REG_TIPDR: ::c_int = 34; + +pub const _REG_RV: ::c_int = _REG_X0; +pub const _REG_FP: ::c_int = _REG_X29; +pub const _REG_LR: ::c_int = _REG_X30; +pub const _REG_SP: ::c_int = _REG_X31; +pub const _REG_PC: ::c_int = _REG_ELR; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index 4bf3ccd02b2c4..b5000d34d66fb 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -20,3 +20,62 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; + +pub const _REG_R0: ::c_int = 0; +pub const _REG_R1: ::c_int = 1; +pub const _REG_R2: ::c_int = 2; +pub const _REG_R3: ::c_int = 3; +pub const _REG_R4: ::c_int = 4; +pub const _REG_R5: ::c_int = 5; +pub const _REG_R6: ::c_int = 6; +pub const _REG_R7: ::c_int = 7; +pub const _REG_R8: ::c_int = 8; +pub const _REG_R9: ::c_int = 9; +pub const _REG_R10: ::c_int = 10; +pub const _REG_R11: ::c_int = 11; +pub const _REG_R12: ::c_int = 12; +pub const _REG_R13: ::c_int = 13; +pub const _REG_R14: ::c_int = 14; +pub const _REG_R15: ::c_int = 15; +pub const _REG_CPSR: ::c_int = 16; +pub const _REG_X0: ::c_int = 0; +pub const _REG_X1: ::c_int = 1; +pub const _REG_X2: ::c_int = 2; +pub const _REG_X3: ::c_int = 3; +pub const _REG_X4: ::c_int = 4; +pub const _REG_X5: ::c_int = 5; +pub const _REG_X6: ::c_int = 6; +pub const _REG_X7: ::c_int = 7; +pub const _REG_X8: ::c_int = 8; +pub const _REG_X9: ::c_int = 9; +pub const _REG_X10: ::c_int = 10; +pub const _REG_X11: ::c_int = 11; +pub const _REG_X12: ::c_int = 12; +pub const _REG_X13: ::c_int = 13; +pub const _REG_X14: ::c_int = 14; +pub const _REG_X15: ::c_int = 15; +pub const _REG_X16: ::c_int = 16; +pub const _REG_X17: ::c_int = 17; +pub const _REG_X18: ::c_int = 18; +pub const _REG_X19: ::c_int = 19; +pub const _REG_X20: ::c_int = 20; +pub const _REG_X21: ::c_int = 21; +pub const _REG_X22: ::c_int = 22; +pub const _REG_X23: ::c_int = 23; +pub const _REG_X24: ::c_int = 24; +pub const _REG_X25: ::c_int = 25; +pub const _REG_X26: ::c_int = 26; +pub const _REG_X27: ::c_int = 27; +pub const _REG_X28: ::c_int = 28; +pub const _REG_X29: ::c_int = 29; +pub const _REG_X30: ::c_int = 30; +pub const _REG_X31: ::c_int = 31; +pub const _REG_ELR: ::c_int = 32; +pub const _REG_SPSR: ::c_int = 33; +pub const _REG_TIPDR: ::c_int = 34; + +pub const _REG_RV: ::c_int = _REG_R0; +pub const _REG_FP: ::c_int = _REG_R11; +pub const _REG_LR: ::c_int = _REG_R13; +pub const _REG_SP: ::c_int = _REG_R14; +pub const _REG_PC: ::c_int = _REG_R15; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index a65035d348f9b..c057d31212493 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2396,33 +2396,6 @@ pub const LSZOMB: ::c_int = 5; pub const LSONPROC: ::c_int = 7; pub const LSSUSPENDED: ::c_int = 8; -pub const _REG_RDI: ::c_int = 0; -pub const _REG_RSI: ::c_int = 1; -pub const _REG_RDX: ::c_int = 2; -pub const _REG_RCX: ::c_int = 3; -pub const _REG_R8: ::c_int = 4; -pub const _REG_R9: ::c_int = 5; -pub const _REG_R10: ::c_int = 6; -pub const _REG_R11: ::c_int = 7; -pub const _REG_R12: ::c_int = 8; -pub const _REG_R13: ::c_int = 9; -pub const _REG_R14: ::c_int = 10; -pub const _REG_R15: ::c_int = 11; -pub const _REG_RBP: ::c_int = 12; -pub const _REG_RBX: ::c_int = 13; -pub const _REG_RAX: ::c_int = 14; -pub const _REG_GS: ::c_int = 15; -pub const _REG_FS: ::c_int = 16; -pub const _REG_ES: ::c_int = 17; -pub const _REG_DS: ::c_int = 18; -pub const _REG_TRAPNO: ::c_int = 19; -pub const _REG_ERR: ::c_int = 20; -pub const _REG_RIP: ::c_int = 21; -pub const _REG_CS: ::c_int = 22; -pub const _REG_RFLAGS: ::c_int = 23; -pub const _REG_RSP: ::c_int = 24; -pub const _REG_SS: ::c_int = 25; - // sys/xattr.h pub const XATTR_CREATE: ::c_int = 0x01; pub const XATTR_REPLACE: ::c_int = 0x02; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index 2f6e4454577a0..ba259074f6129 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -38,3 +38,30 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; + +pub const _REG_RDI: ::c_int = 0; +pub const _REG_RSI: ::c_int = 1; +pub const _REG_RDX: ::c_int = 2; +pub const _REG_RCX: ::c_int = 3; +pub const _REG_R8: ::c_int = 4; +pub const _REG_R9: ::c_int = 5; +pub const _REG_R10: ::c_int = 6; +pub const _REG_R11: ::c_int = 7; +pub const _REG_R12: ::c_int = 8; +pub const _REG_R13: ::c_int = 9; +pub const _REG_R14: ::c_int = 10; +pub const _REG_R15: ::c_int = 11; +pub const _REG_RBP: ::c_int = 12; +pub const _REG_RBX: ::c_int = 13; +pub const _REG_RAX: ::c_int = 14; +pub const _REG_GS: ::c_int = 15; +pub const _REG_FS: ::c_int = 16; +pub const _REG_ES: ::c_int = 17; +pub const _REG_DS: ::c_int = 18; +pub const _REG_TRAPNO: ::c_int = 19; +pub const _REG_ERR: ::c_int = 20; +pub const _REG_RIP: ::c_int = 21; +pub const _REG_CS: ::c_int = 22; +pub const _REG_RFLAGS: ::c_int = 23; +pub const _REG_RSP: ::c_int = 24; +pub const _REG_SS: ::c_int = 25; From 936887814f770a9a5b44868b616304f808c593b6 Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Sat, 9 Dec 2023 16:53:51 +0100 Subject: [PATCH 10/41] Add `if_xdp.h" structs and constants Also adds _v1 versions for backwards compatibility --- libc-test/build.rs | 53 +++++++++++++ libc-test/semver/linux-gnu.txt | 23 ++++++ libc-test/semver/linux-musl.txt | 23 ++++++ src/unix/linux_like/linux/gnu/mod.rs | 109 ++++++++++++++++++++++++++ src/unix/linux_like/linux/musl/mod.rs | 109 ++++++++++++++++++++++++++ 5 files changed, 317 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 6fbaa5b6b1f63..efba2e8bf5115 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3408,6 +3408,7 @@ fn test_linux(target: &str) { "linux/if_alg.h", "linux/if_ether.h", "linux/if_tun.h", + "linux/if_xdp.h", "linux/input.h", "linux/ipv6.h", "linux/kexec.h", @@ -3642,6 +3643,30 @@ fn test_linux(target: &str) { true } + // FIXME: Requires >= 5.3 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "xdp_options" if musl => true, + + // FIXME: Requires >= 5.4 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "xdp_umem_reg" | "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, + + // FIXME: Requires >= 5.9 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "xdp_statistics" if musl => true, + + // A new field was added in kernel 5.4, this is the old version for backwards compatibility. + // https://github.com/torvalds/linux/commit/77cd0d7b3f257fd0e3096b4fdcff1a7d38e99e10 + "xdp_ring_offset_v1" | "xdp_mmap_offsets_v1" => true, + + // Multiple new fields were added in kernel 5.9, this is the old version for backwards compatibility. + // https://github.com/torvalds/linux/commit/77cd0d7b3f257fd0e3096b4fdcff1a7d38e99e10 + "xdp_statistics_v1" => true, + + // A new field was added in kernel 5.4, this is the old version for backwards compatibility. + // https://github.com/torvalds/linux/commit/c05cd3645814724bdeb32a2b4d953b12bdea5f8c + "xdp_umem_reg_v1" => true, + _ => false, } }); @@ -3994,6 +4019,34 @@ fn test_linux(target: &str) { true } + // FIXME: Requires >= 5.3 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "XDP_OPTIONS_ZEROCOPY" | "XDP_OPTIONS" + if musl => + { + true + } + + // FIXME: Requires >= 5.4 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "XSK_UNALIGNED_BUF_OFFSET_SHIFT" + | "XSK_UNALIGNED_BUF_ADDR_MASK" + | "XDP_UMEM_UNALIGNED_CHUNK_FLAG" + | "XDP_RING_NEED_WAKEUP" + | "XDP_USE_NEED_WAKEUP" + if musl => + { + true + } + + // FIXME: Requires >= 6.6 kernel headers. + "XDP_USE_SG" + | "XDP_PKT_CONTD" + => + { + true + } + _ => false, } }); diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index ad971de731bad..4d95520d3e9de 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -486,6 +486,29 @@ UDF_SUPER_MAGIC UNAME26 USBDEVICE_SUPER_MAGIC USER_PROCESS +XDP_SHARED_UMEM +XDP_COPY +XDP_ZEROCOPY +XDP_USE_NEED_WAKEUP +XDP_USE_SG +XDP_UMEM_UNALIGNED_CHUNK_FLAG +XDP_RING_NEED_WAKEUP +XDP_MMAP_OFFSETS +XDP_RX_RING +XDP_TX_RING +XDP_UMEM_REG +XDP_UMEM_FILL_RING +XDP_UMEM_COMPLETION_RING +XDP_STATISTICS +XDP_OPTIONS +XDP_OPTIONS_ZEROCOPY +XDP_PGOFF_RX_RING +XDP_PGOFF_TX_RING +XDP_UMEM_PGOFF_FILL_RING +XDP_UMEM_PGOFF_COMPLETION_RING +XSK_UNALIGNED_BUF_OFFSET_SHIFT +XSK_UNALIGNED_BUF_ADDR_MASK +XDP_PKT_CONTD XENFS_SUPER_MAGIC XFS_SUPER_MAGIC _SC_2_C_VERSION diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 09c461350f9a5..728c8db692072 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -23,6 +23,29 @@ PF_XDP PIDFD_NONBLOCK PR_SET_VMA PR_SET_VMA_ANON_NAME +XDP_SHARED_UMEM +XDP_COPY +XDP_ZEROCOPY +XDP_USE_NEED_WAKEUP +XDP_USE_SG +XDP_UMEM_UNALIGNED_CHUNK_FLAG +XDP_RING_NEED_WAKEUP +XDP_MMAP_OFFSETS +XDP_RX_RING +XDP_TX_RING +XDP_UMEM_REG +XDP_UMEM_FILL_RING +XDP_UMEM_COMPLETION_RING +XDP_STATISTICS +XDP_OPTIONS +XDP_OPTIONS_ZEROCOPY +XDP_PGOFF_RX_RING +XDP_PGOFF_TX_RING +XDP_UMEM_PGOFF_FILL_RING +XDP_UMEM_PGOFF_COMPLETION_RING +XSK_UNALIGNED_BUF_OFFSET_SHIFT +XSK_UNALIGNED_BUF_ADDR_MASK +XDP_PKT_CONTD adjtimex aio_cancel aio_error diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 377b9f122f150..e7284fd46f096 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -355,6 +355,83 @@ s! { #[cfg(libc_union)] pub u: __c_anonymous_ptrace_syscall_info_data, } + + // linux/if_xdp.h + + pub struct sockaddr_xdp { + pub sxdp_family: ::__u16, + pub sxdp_flags: ::__u16, + pub sxdp_ifindex: ::__u32, + pub sxdp_queue_id: ::__u32, + pub sxdp_shared_umem_fd: ::__u32, + } + + pub struct xdp_ring_offset { + pub producer: ::__u64, + pub consumer: ::__u64, + pub desc: ::__u64, + pub flags: ::__u64, + } + + pub struct xdp_mmap_offsets { + pub rx: xdp_ring_offset, + pub tx: xdp_ring_offset, + pub fr: xdp_ring_offset, + pub cr: xdp_ring_offset, + } + + pub struct xdp_ring_offset_v1 { + pub producer: ::__u64, + pub consumer: ::__u64, + pub desc: ::__u64, + } + + pub struct xdp_mmap_offsets_v1 { + pub rx: xdp_ring_offset_v1, + pub tx: xdp_ring_offset_v1, + pub fr: xdp_ring_offset_v1, + pub cr: xdp_ring_offset_v1, + } + + pub struct xdp_umem_reg { + pub addr: ::__u64, + pub len: ::__u64, + pub chunk_size: ::__u32, + pub headroom: ::__u32, + pub flags: ::__u32, + } + + pub struct xdp_umem_reg_v1 { + pub addr: ::__u64, + pub len: ::__u64, + pub chunk_size: ::__u32, + pub headroom: ::__u32, + } + + pub struct xdp_statistics { + pub rx_dropped: ::__u64, + pub rx_invalid_descs: ::__u64, + pub tx_invalid_descs: ::__u64, + pub rx_ring_full: ::__u64, + pub rx_fill_ring_empty_descs: ::__u64, + pub tx_ring_empty_descs: ::__u64, + } + + pub struct xdp_statistics_v1 { + pub rx_dropped: ::__u64, + pub rx_invalid_descs: ::__u64, + pub tx_invalid_descs: ::__u64, + } + + pub struct xdp_options { + pub flags: ::__u32, + } + + pub struct xdp_desc { + pub addr: ::__u64, + pub len: ::__u32, + pub options: ::__u32, + } } impl siginfo_t { @@ -920,6 +997,38 @@ pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; +// linux/if_xdp.h +pub const XDP_SHARED_UMEM: ::__u16 = 1 << 0; +pub const XDP_COPY: ::__u16 = 1 << 1; +pub const XDP_ZEROCOPY: ::__u16 = 1 << 2; +pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3; +pub const XDP_USE_SG: ::__u16 = 1 << 4; + +pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0; + +pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0; + +pub const XDP_MMAP_OFFSETS: ::c_int = 1; +pub const XDP_RX_RING: ::c_int = 2; +pub const XDP_TX_RING: ::c_int = 3; +pub const XDP_UMEM_REG: ::c_int = 4; +pub const XDP_UMEM_FILL_RING: ::c_int = 5; +pub const XDP_UMEM_COMPLETION_RING: ::c_int = 6; +pub const XDP_STATISTICS: ::c_int = 7; +pub const XDP_OPTIONS: ::c_int = 8; + +pub const XDP_OPTIONS_ZEROCOPY: ::__u32 = 1 << 0; + +pub const XDP_PGOFF_RX_RING: ::off_t = 0; +pub const XDP_PGOFF_TX_RING: ::off_t = 0x80000000; +pub const XDP_UMEM_PGOFF_FILL_RING: ::c_ulonglong = 0x100000000; +pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000; + +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; + +pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; + // elf.h pub const NT_PRSTATUS: ::c_int = 1; pub const NT_PRFPREG: ::c_int = 2; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index b67d55e99bb53..96a3db133b2f4 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -271,6 +271,83 @@ s! { pub maxerror: ::c_long, pub esterror: ::c_long, } + + // linux/if_xdp.h + + pub struct sockaddr_xdp { + pub sxdp_family: ::__u16, + pub sxdp_flags: ::__u16, + pub sxdp_ifindex: ::__u32, + pub sxdp_queue_id: ::__u32, + pub sxdp_shared_umem_fd: ::__u32, + } + + pub struct xdp_ring_offset { + pub producer: ::__u64, + pub consumer: ::__u64, + pub desc: ::__u64, + pub flags: ::__u64, + } + + pub struct xdp_mmap_offsets { + pub rx: xdp_ring_offset, + pub tx: xdp_ring_offset, + pub fr: xdp_ring_offset, + pub cr: xdp_ring_offset, + } + + pub struct xdp_ring_offset_v1 { + pub producer: ::__u64, + pub consumer: ::__u64, + pub desc: ::__u64, + } + + pub struct xdp_mmap_offsets_v1 { + pub rx: xdp_ring_offset_v1, + pub tx: xdp_ring_offset_v1, + pub fr: xdp_ring_offset_v1, + pub cr: xdp_ring_offset_v1, + } + + pub struct xdp_umem_reg { + pub addr: ::__u64, + pub len: ::__u64, + pub chunk_size: ::__u32, + pub headroom: ::__u32, + pub flags: ::__u32, + } + + pub struct xdp_umem_reg_v1 { + pub addr: ::__u64, + pub len: ::__u64, + pub chunk_size: ::__u32, + pub headroom: ::__u32, + } + + pub struct xdp_statistics { + pub rx_dropped: ::__u64, + pub rx_invalid_descs: ::__u64, + pub tx_invalid_descs: ::__u64, + pub rx_ring_full: ::__u64, + pub rx_fill_ring_empty_descs: ::__u64, + pub tx_ring_empty_descs: ::__u64, + } + + pub struct xdp_statistics_v1 { + pub rx_dropped: ::__u64, + pub rx_invalid_descs: ::__u64, + pub tx_invalid_descs: ::__u64, + } + + pub struct xdp_options { + pub flags: ::__u32, + } + + pub struct xdp_desc { + pub addr: ::__u64, + pub len: ::__u32, + pub options: ::__u32, + } } s_no_extra_traits! { @@ -703,6 +780,38 @@ pub const TIME_ERROR: ::c_int = 5; pub const TIME_BAD: ::c_int = TIME_ERROR; pub const MAXTC: ::c_long = 6; +// linux/if_xdp.h +pub const XDP_SHARED_UMEM: ::__u16 = 1 << 0; +pub const XDP_COPY: ::__u16 = 1 << 1; +pub const XDP_ZEROCOPY: ::__u16 = 1 << 2; +pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3; +pub const XDP_USE_SG: ::__u16 = 1 << 4; + +pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0; + +pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0; + +pub const XDP_MMAP_OFFSETS: ::c_int = 1; +pub const XDP_RX_RING: ::c_int = 2; +pub const XDP_TX_RING: ::c_int = 3; +pub const XDP_UMEM_REG: ::c_int = 4; +pub const XDP_UMEM_FILL_RING: ::c_int = 5; +pub const XDP_UMEM_COMPLETION_RING: ::c_int = 6; +pub const XDP_STATISTICS: ::c_int = 7; +pub const XDP_OPTIONS: ::c_int = 8; + +pub const XDP_OPTIONS_ZEROCOPY: ::__u32 = 1 << 0; + +pub const XDP_PGOFF_RX_RING: ::off_t = 0; +pub const XDP_PGOFF_TX_RING: ::off_t = 0x80000000; +pub const XDP_UMEM_PGOFF_FILL_RING: ::c_ulonglong = 0x100000000; +pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000; + +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; + +pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: ::c_int = 6; From 5901514f6b575f74edb2d9d9ee90167f6124a0c6 Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Sat, 9 Dec 2023 16:54:00 +0100 Subject: [PATCH 11/41] Add `SOL_XDP` to linux musl --- libc-test/semver/linux-musl.txt | 1 + src/unix/linux_like/linux/musl/mod.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 728c8db692072..09a63c7294a76 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -23,6 +23,7 @@ PF_XDP PIDFD_NONBLOCK PR_SET_VMA PR_SET_VMA_ANON_NAME +SOL_XDP XDP_SHARED_UMEM XDP_COPY XDP_ZEROCOPY diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 96a3db133b2f4..97429a7f3a21a 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -780,6 +780,8 @@ pub const TIME_ERROR: ::c_int = 5; pub const TIME_BAD: ::c_int = TIME_ERROR; pub const MAXTC: ::c_long = 6; +pub const SOL_XDP: ::c_int = 283; + // linux/if_xdp.h pub const XDP_SHARED_UMEM: ::__u16 = 1 << 0; pub const XDP_COPY: ::__u16 = 1 << 1; From 0cd65a99c5d3004ed9de2845dd2d4001a52c7887 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 9 Dec 2023 18:23:06 +0000 Subject: [PATCH 12/41] openbsd riscv64 adding sigcontext --- src/unix/bsd/netbsdlike/openbsd/riscv64.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs index 99350ec8dc3d4..35f1672bbec9e 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -1,6 +1,25 @@ pub type c_long = i64; pub type c_ulong = u64; pub type c_char = u8; +pub type ucontext_t = sigcontext; + +s! { + pub struct sigcontext { + __sc_unused: ::c_int, + pub sc_mask: ::c_int, + pub sc_ra: ::c_long, + pub sc_sp: ::c_long, + pub sc_gp: ::c_long, + pub sc_tp: ::c_long, + pub sc_t: [::c_long; 7], + pub sc_s: [::c_long; 12], + pub sc_a: [::c_long; 8], + pub sc_sepc: ::c_long, + pub sc_f: [::c_long; 32], + pub sc_fcsr: ::c_long, + pub sc_cookie: ::c_long, + } +} // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { From 558acf1c8620b050c4c778eb7f0322dacafe42a3 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 10 Dec 2023 12:29:06 +0900 Subject: [PATCH 13/41] Generate `aarch64-apple-darwin` docs on docs.rs --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index b70de560209fe..123f4deb3bbae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ Raw FFI bindings to platform libraries like libc. features = ["const-extern-fn", "extra_traits"] default-target = "x86_64-unknown-linux-gnu" targets = [ + "aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-linux-android", "aarch64-pc-windows-msvc", From 36f5f133dfacedb03b418f0545e92766f37134da Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 10 Dec 2023 08:50:12 +0000 Subject: [PATCH 14/41] openbsd/netbsd MAP_TRYFIXED constant --- libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 + src/unix/bsd/netbsdlike/openbsd/mod.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 495b56cc3611a..145f02b441cf1 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -643,6 +643,7 @@ MAP_NORESERVE MAP_REMAPDUP MAP_RENAME MAP_STACK +MAP_TRYFIXED MAP_WIRED MAXFREQ MAXPHASE diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 7843f6af10c87..5b0064f72e65b 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -486,6 +486,7 @@ MAP_NOEXTEND MAP_NORESERVE MAP_RENAME MAP_STACK +MAP_TRYFIXED MCL_CURRENT MCL_FUTURE MDMBUF diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index c057d31212493..43b17e1a7ecf9 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1701,6 +1701,7 @@ pub const O_DSYNC: ::c_int = 0x10000; pub const MAP_RENAME: ::c_int = 0x20; pub const MAP_NORESERVE: ::c_int = 0x40; pub const MAP_HASSEMAPHORE: ::c_int = 0x200; +pub const MAP_TRYFIXED: ::c_int = 0x400; pub const MAP_WIRED: ::c_int = 0x800; pub const MAP_STACK: ::c_int = 0x2000; // map alignment aliases for MAP_ALIGNED diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 17dfa6571568f..08c816566166c 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1229,6 +1229,7 @@ pub const O_DSYNC: ::c_int = 128; pub const MAP_RENAME: ::c_int = 0x0000; pub const MAP_NORESERVE: ::c_int = 0x0000; pub const MAP_HASSEMAPHORE: ::c_int = 0x0000; +pub const MAP_TRYFIXED: ::c_int = 0; pub const EIPSEC: ::c_int = 82; pub const ENOMEDIUM: ::c_int = 85; From 9645281b1eae2a553ff0271a9998ea6436fe8361 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 10 Dec 2023 21:34:57 +0900 Subject: [PATCH 15/41] Prepare release for v0.2.151 --- Cargo.toml | 2 +- libc-test/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 123f4deb3bbae..dff98cfbc9796 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.150" +version = "0.2.151" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 56b53f73699a0..d09d3802ad72c 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc-test" -version = "0.2.150" +version = "0.2.151" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" build = "build.rs" @@ -12,7 +12,7 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.150" +version = "0.2.151" default-features = false [build-dependencies] From 4e42b85b60a907a17e85148569bd52a4233245c2 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 11 Dec 2023 13:09:59 -0700 Subject: [PATCH 16/41] Stop testing on FreeBSD 12 FreeBSD 12.4 will be EoL at the end of the month. Stop testing on it. Also, update the 14.0 image to the official release. --- .cirrus.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 3a42cc356c255..31f0e98f2a09a 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,17 +1,3 @@ -task: - name: nightly x86_64-unknown-freebsd-12 - freebsd_instance: - image_family: freebsd-12-4 - setup_script: - - pkg install -y libnghttp2 curl - - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh --default-toolchain nightly -y --profile=minimal - - . $HOME/.cargo/env - test_script: - - . $HOME/.cargo/env - - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd - - sh ci/run.sh x86_64-unknown-freebsd - task: name: nightly x86_64-unknown-freebsd-13 freebsd_instance: @@ -29,7 +15,7 @@ task: task: name: nightly x86_64-unknown-freebsd-14 freebsd_instance: - image: freebsd-14-0-rc1-amd64 + image: freebsd-14-0-release-amd64-ufs setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh From 1198797476ff5ba8c33b70e80503312c74533c3f Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 13 Dec 2023 19:53:35 +0000 Subject: [PATCH 17/41] iadding yser_fpxregs_struct data to linux/musl i686. close #3476 --- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 944d6e7877d48..12280851e7471 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -157,6 +157,22 @@ s! { } s_no_extra_traits! { + pub struct user_fpxregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub twd: ::c_ushort, + pub fop: ::c_ushort, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub mxcsr: ::c_long, + __reserved: ::c_long, + pub st_space: [::c_long; 32], + pub xmm_space: [::c_long; 32], + padding: [::c_long; 56], + } + pub struct ucontext_t { pub uc_flags: ::c_ulong, pub uc_link: *mut ucontext_t, @@ -169,6 +185,64 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpxregs_struct { + fn eq(&self, other: &user_fpxregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.twd == other.twd + && self.fop == other.fop + && self.fip == other.fip + && self.fcs == other.fcs + && self.foo == other.foo + && self.fos == other.fos + && self.mxcsr == other.mxcsr + // Ignore __reserved field + && self.st_space == other.st_space + && self.xmm_space == other.xmm_space + // Ignore padding field + } + } + + impl Eq for user_fpxregs_struct {} + + impl ::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("user_fpxregs_struct") + .field("cwd", &self.cwd) + .field("swd", &self.swd) + .field("twd", &self.twd) + .field("fop", &self.fop) + .field("fip", &self.fip) + .field("fcs", &self.fcs) + .field("foo", &self.foo) + .field("fos", &self.fos) + .field("mxcsr", &self.mxcsr) + // Ignore __reserved field + .field("st_space", &self.st_space) + .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl ::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.swd.hash(state); + self.twd.hash(state); + self.fop.hash(state); + self.fip.hash(state); + self.fcs.hash(state); + self.foo.hash(state); + self.fos.hash(state); + self.mxcsr.hash(state); + // Ignore __reserved field + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_flags == other.uc_flags From befe997b1e13f7886612c06fd553e51e58e61279 Mon Sep 17 00:00:00 2001 From: Sebastien Marie Date: Thu, 14 Dec 2023 09:38:05 +0000 Subject: [PATCH 18/41] openbsd: syscall() has been removed in upcoming OpenBSD 7.5 --- libc-test/build.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index cb28758ad507f..a9d04ca81cc15 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -565,6 +565,10 @@ fn test_openbsd(target: &str) { // Available for openBSD 7.3 "mimmutable" => true, + // Removed in OpenBSD 7.5 + // https://marc.info/?l=openbsd-cvs&m=170239504300386 + "syscall" => true, + _ => false, } }); From c81cc4afd39218ba968dcfb79dab06c5d965f93c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 15 Dec 2023 11:48:45 +0000 Subject: [PATCH 19/41] adding tcp_info to openbsd --- libc-test/semver/openbsd.txt | 6 ++- src/unix/bsd/netbsdlike/mod.rs | 2 + src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 - src/unix/bsd/netbsdlike/openbsd/mod.rs | 62 ++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 5b0064f72e65b..529d9f82472cf 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -808,6 +808,7 @@ ST_RDONLY S_IEXEC S_IREAD S_IWRITE +TCP_INFO TCP_MAXSEG TCP_MD5SIG TCP_NOPUSH @@ -1014,6 +1015,7 @@ backtrace backtrace_symbols backtrace_symbols_fd backtrace_symbols_fmt +basename bsearch caddr_t calloc_conceal @@ -1027,6 +1029,7 @@ cmsghdr daemon difftime dirfd +dirname dl_iterate_phdr dl_phdr_info drand48 @@ -1254,6 +1257,7 @@ strtonum sync syscall sysctl +tcp_info telldir tmpfs_args truncate @@ -1269,5 +1273,3 @@ utmp utrace wait4 xucred -dirname -basename diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 07dc39be54e36..07cdec800658f 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -650,6 +650,8 @@ pub const TIMER_ABSTIME: ::c_int = 1; pub const RB_AUTOBOOT: ::c_int = 0; +pub const TCP_INFO: ::c_int = 9; + #[link(name = "util")] extern "C" { pub fn setgrent(); diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 43b17e1a7ecf9..63957d17834f0 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1549,7 +1549,6 @@ pub const TCP_KEEPIDLE: ::c_int = 3; pub const TCP_KEEPINTVL: ::c_int = 5; pub const TCP_KEEPCNT: ::c_int = 6; pub const TCP_KEEPINIT: ::c_int = 7; -pub const TCP_INFO: ::c_int = 9; pub const TCP_MD5SIG: ::c_int = 0x10; pub const TCP_CONGCTL: ::c_int = 0x20; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 08c816566166c..1b683a4eb98b7 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -541,6 +541,68 @@ s! { #[cfg(not(libc_union))] pub ifr_ifru: ::sockaddr, } + + pub struct tcp_info { + pub tcpi_state: u8, + pub __tcpi_ca_state: u8, + pub __tcpi_retransmits: u8, + pub __tcpi_probes: u8, + pub __tcpi_backoff: u8, + pub tcpi_options: u8, + pub tcpi_snd_wscale: u8, + pub tcpi_rcv_wscale: u8, + pub tcpi_rto: u32, + pub __tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub __tcpi_unacked: u32, + pub __tcpi_sacked: u32, + pub __tcpi_lost: u32, + pub __tcpi_retrans: u32, + pub __tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub __tcpi_pmtu: u32, + pub __tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub __tcpi_advmss: u32, + pub __tcpi_reordering: u32, + pub __tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_nxt: u32, + pub tcpi_rcv_nxt: u32, + pub tcpi_toe_tid: u32, + pub tcpi_snd_rexmitpack: u32, + pub tcpi_rcv_ooopack: u32, + pub tcpi_snd_zerowin: u32, + pub tcpi_rttmin: u32, + pub tcpi_max_sndwnd: u32, + pub tcpi_rcv_adv: u32, + pub tcpi_rcv_up: u32, + pub tcpi_snd_una: u32, + pub tcpi_snd_up: u32, + pub tcpi_snd_wl1: u32, + pub tcpi_snd_wl2: u32, + pub tcpi_snd_max: u32, + pub tcpi_ts_recent: u32, + pub tcpi_ts_recent_age: u32, + pub tcpi_rfbuf_cnt: u32, + pub tcpi_rfbuf_ts: u32, + pub tcpi_so_rcv_sb_cc: u32, + pub tcpi_so_rcv_sb_hiwat: u32, + pub tcpi_so_rcv_sb_lowat: u32, + pub tcpi_so_rcv_sb_wat: u32, + pub tcpi_so_snd_sb_cc: u32, + pub tcpi_so_snd_sb_hiwat: u32, + pub tcpi_so_snd_sb_lowat: u32, + pub tcpi_so_snd_sb_wat: u32, + } } impl siginfo_t { From b20c6376f5b4eb4d8fd00927bf22e2464d591644 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 16 Dec 2023 06:38:07 +0000 Subject: [PATCH 20/41] strftime_l for Linux glibc/musl --- libc-test/semver/linux-gnu.txt | 1 + libc-test/semver/linux-musl.txt | 1 + src/unix/linux_like/linux/gnu/mod.rs | 7 +++++++ src/unix/linux_like/linux/musl/mod.rs | 7 +++++++ 4 files changed, 16 insertions(+) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 4d95520d3e9de..591b2447dbab7 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -691,6 +691,7 @@ eaccess asctime_r ctime_r strftime +strftime_l strptime dirname posix_basename diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 09a63c7294a76..2db034f813be7 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -78,6 +78,7 @@ euidaccess eaccess asctime_r strftime +strftime_l strptime dirname basename diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index e7284fd46f096..3ee3d62667956 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1462,6 +1462,13 @@ extern "C" { format: *const ::c_char, tm: *const ::tm, ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 97429a7f3a21a..a4c1f708afd50 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -889,6 +889,13 @@ extern "C" { format: *const ::c_char, tm: *const ::tm, ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; From aff5e66e547372dd29228043e450e9ebb5860257 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 16 Dec 2023 06:26:36 +0000 Subject: [PATCH 21/41] strftime* api for *BSD close #3459 --- libc-test/semver/apple.txt | 1 + libc-test/semver/dragonfly.txt | 2 ++ libc-test/semver/freebsd.txt | 2 ++ libc-test/semver/netbsd.txt | 2 ++ libc-test/semver/openbsd.txt | 2 ++ src/unix/bsd/apple/mod.rs | 6 ------ src/unix/bsd/mod.rs | 14 ++++++++++++++ 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index a3e2161ab9ee1..5a34303a157fc 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2225,6 +2225,7 @@ statfs strcasecmp strcasestr strftime +strftime_l strncasecmp strndup strptime diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index b9c8e7ee6180c..c1942853289dc 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1547,6 +1547,8 @@ stack_t statfs strcasecmp strcasestr +strftime +strftime_l strncasecmp strndup strsignal diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 9f436ced22a81..914808b08af5e 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2204,6 +2204,8 @@ statfs strcasecmp strcasestr strchrnul +strftime +strftime_l strncasecmp strndup strsignal diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 145f02b441cf1..e36d33224aa50 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1551,6 +1551,8 @@ stack_t strcasecmp strcasestr string_to_flags +strftime +strftime_l strncasecmp strndup strpct diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 529d9f82472cf..fe3d602f54eb7 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1250,6 +1250,8 @@ stack_t statfs strcasecmp strcasestr +strftime +strftime_l strncasecmp strndup strsignal diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c7169a2274769..7d27777232842 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -5604,12 +5604,6 @@ extern "C" { pub fn asctime(tm: *const ::tm) -> *mut ::c_char; pub fn ctime(clock: *const time_t) -> *mut ::c_char; pub fn getdate(datestr: *const ::c_char) -> *mut ::tm; - pub fn strftime( - buf: *mut ::c_char, - maxsize: ::size_t, - format: *const ::c_char, - timeptr: *const ::tm, - ) -> ::size_t; pub fn strptime( buf: *const ::c_char, format: *const ::c_char, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 6ce041357ebee..1dd21c7adaeb0 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -899,6 +899,20 @@ extern "C" { longopts: *const option, longindex: *mut ::c_int, ) -> ::c_int; + + pub fn strftime( + buf: *mut ::c_char, + maxsize: ::size_t, + format: *const ::c_char, + timeptr: *const ::tm, + ) -> ::size_t; + pub fn strftime_l( + buf: *mut ::c_char, + maxsize: ::size_t, + format: *const ::c_char, + timeptr: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; } cfg_if! { From 389d1ed3138f74a042fa6f6e177f1a03cc5de023 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 18 Dec 2023 13:44:28 +0000 Subject: [PATCH 22/41] adding iocb data for io_submit syscall for linux/glibc. close #3485 --- libc-test/build.rs | 1 + libc-test/semver/linux-gnu.txt | 1 + src/unix/linux_like/linux/gnu/mod.rs | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index a9d04ca81cc15..3b50438c6c672 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3406,6 +3406,7 @@ fn test_linux(target: &str) { headers! { cfg: "asm/mman.h", + [gnu]: "linux/aio_abi.h", "linux/can.h", "linux/can/raw.h", // FIXME: requires kernel headers >= 5.4.1. diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 591b2447dbab7..9bbdee0771b60 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -638,6 +638,7 @@ glob64 glob64_t globfree globfree64 +iocb lio_listio mallinfo mallinfo2 diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 3ee3d62667956..9af519e9077df 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -3,6 +3,7 @@ pub type __priority_which_t = ::c_uint; pub type __rlimit_resource_t = ::c_uint; pub type Lmid_t = ::c_long; pub type regoff_t = ::c_int; +pub type __kernel_rwf_t = ::c_int; cfg_if! { if #[cfg(doc)] { @@ -432,6 +433,27 @@ s! { pub len: ::__u32, pub options: ::__u32, } + + pub struct iocb { + pub aio_data: ::__u64, + #[cfg(target_endian = "little")] + pub aio_key: ::__u32, + #[cfg(target_endian = "little")] + pub aio_rw_flags: ::__kernel_rwf_t, + #[cfg(target_endian = "big")] + pub aio_rw_flags: ::__kernel_rwf_t, + #[cfg(target_endian = "big")] + pub aio_key: ::__u32, + pub aio_lio_opcode: ::__u16, + pub aio_reqprio: ::__s16, + pub aio_fildes: ::__u32, + pub aio_buf: ::__u64, + pub aio_nbytes: ::__u64, + pub aio_offset: ::__s64, + aio_reserved2: ::__u64, + pub aio_flags: ::__u32, + pub aio_resfd: ::__u32, + } } impl siginfo_t { From 23b49bbbc2bdc6ec200aae8b022f5295c49b5794 Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:12:53 +0100 Subject: [PATCH 23/41] Add missing symbols to semver/linux.txt --- libc-test/semver/linux.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 37aab57f23ee3..ff186a7d830ba 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2475,6 +2475,7 @@ SIOCSIFMAP SIOCSIFMEM SIOCSIFMETRIC SIOCSIFMTU +SIOCSIFNAME SIOCSIFNETMASK SIOCSIFPFLAGS SIOCSIFSLAVE @@ -3860,3 +3861,6 @@ wait4 waitid eventfd_read eventfd_write +__c_anonymous_ifru_map +__c_anonymous_ifr_ifru +__c_anonymous_ifc_ifcu From d8b4bb51f08abcca83ae883f218d555a458d8243 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Tue, 19 Dec 2023 21:41:52 +0900 Subject: [PATCH 24/41] Re-enable `i686-pc-windows-gnu` CI --- .github/workflows/bors.yml | 10 ++++------ .github/workflows/main.yml | 10 ++++------ libc-test/build.rs | 9 ++++++++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index 77f236c033e07..6ecf7c83ffe74 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -73,12 +73,10 @@ jobs: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc - # Disabled because broken: - # https://github.com/rust-lang/libc/issues/1592 - #- target: i686-pc-windows-gnu - # env: - # ARCH_BITS: 32 - # ARCH: i686 + - target: i686-pc-windows-gnu + env: + ARCH_BITS: 32 + ARCH: i686 - target: i686-pc-windows-msvc steps: - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@HEAD diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eaf4ffec2ad3c..c7784fc117df9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,12 +58,10 @@ jobs: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc - # Disabled because broken: - # https://github.com/rust-lang/libc/issues/1592 - #- target: i686-pc-windows-gnu - # env: - # ARCH_BITS: 32 - # ARCH: i686 + - target: i686-pc-windows-gnu + env: + ARCH_BITS: 32 + ARCH: i686 - target: i686-pc-windows-msvc steps: - uses: actions/checkout@v4 diff --git a/libc-test/build.rs b/libc-test/build.rs index 3b50438c6c672..7f4778ee1f113 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -618,6 +618,7 @@ fn test_openbsd(target: &str) { fn test_windows(target: &str) { assert!(target.contains("windows")); let gnu = target.contains("gnu"); + let i686 = target.contains("i686"); let mut cfg = ctest_cfg(); if target.contains("msvc") { @@ -684,6 +685,8 @@ fn test_windows(target: &str) { cfg.skip_type(move |name| match name { "SSIZE_T" if !gnu => true, "ssize_t" if !gnu => true, + // FIXME: The size and alignment of this type are incorrect + "time_t" if gnu && i686 => true, _ => false, }); @@ -691,7 +694,11 @@ fn test_windows(target: &str) { if ty.starts_with("__c_anonymous_") { return true; } - return false; + match ty { + // FIXME: The size and alignment of this struct are incorrect + "timespec" if gnu && i686 => true, + _ => false, + } }); cfg.skip_const(move |name| { From c0b1ccf49cc761e75fe124090375ea8977693514 Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:02:18 +0100 Subject: [PATCH 25/41] Add `ifreq`, `ifconf` and related constants to Android --- libc-test/build.rs | 2 + libc-test/semver/android.txt | 44 +++++++++ src/unix/linux_like/android/mod.rs | 145 +++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index a9d04ca81cc15..7319c65352958 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1996,6 +1996,8 @@ fn test_android(target: &str) { // this is actually a union on linux, so we can't represent it well and // just insert some padding. ("siginfo_t", "_pad") => true, + ("ifreq", "ifr_ifru") => true, + ("ifconf", "ifc_ifcu") => true, _ => false, } diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index a7c235eefb3ed..f0e4358d37c62 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -2241,7 +2241,44 @@ SIOCADDMULTI SIOCADDRT SIOCDARP SIOCDELMULTI +SIOCGIFINDEX +SIOGIFINDEX +SIOCSIFPFLAGS +SIOCGIFPFLAGS +SIOCDIFADDR +SIOCSIFHWBROADCAST +SIOCGIFCOUNT +SIOCGIFBR +SIOCSIFBR +SIOCGIFTXQLEN +SIOCSIFTXQLEN +SIOCETHTOOL +SIOCGMIIPHY +SIOCGMIIREG +SIOCSMIIREG +SIOCWANDEV +SIOCOUTQNSD +SIOCGSKNS +SIOCADDDLCI +SIOCDELDLCI +SIOCGIFVLAN +SIOCSIFVLAN +SIOCBONDENSLAVE +SIOCBONDRELEASE +SIOCBONDSETHWADDR +SIOCBONDSLAVEINFOQUERY +SIOCBONDINFOQUERY +SIOCBONDCHANGEACTIVE +SIOCBRADDBR +SIOCBRDELBR +SIOCBRADDIF +SIOCBRDELIF +SIOCSHWTSTAMP +SIOCGHWTSTAMP +SIOCDEVPRIVATE +SIOCPROTOPRIVATE SIOCDELRT +SIOCRTMSG SIOCDRARP SIOCGARP SIOCGIFADDR @@ -2250,6 +2287,7 @@ SIOCGIFCONF SIOCGIFDSTADDR SIOCGIFENCAP SIOCGIFFLAGS +SIOCSIFNAME SIOCGIFHWADDR SIOCGIFMAP SIOCGIFMEM @@ -3223,10 +3261,16 @@ group hostent id_t idtype_t +ifconf +ifreq +__c_anonymous_ifc_ifcu +__c_anonymous_ifr_ifru +__c_anonymous_ifru_map if_indextoname if_nametoindex ifaddrs in6_addr +in6_ifreq in6_pktinfo in6_rtmsg in_addr diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 999a15440d12c..94c4eace85539 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -496,6 +496,22 @@ s! { pub flag: *mut ::c_int, pub val: ::c_int, } + + pub struct __c_anonymous_ifru_map { + pub mem_start: ::c_ulong, + pub mem_end: ::c_ulong, + pub base_addr: ::c_ushort, + pub irq: ::c_uchar, + pub dma: ::c_uchar, + pub port: ::c_uchar, + } + + pub struct in6_ifreq { + pub ifr6_addr: ::in6_addr, + pub ifr6_prefixlen: u32, + pub ifr6_ifindex: ::c_int, + } + } s_no_extra_traits! { @@ -591,6 +607,50 @@ s_no_extra_traits! { __serial: ::c_uint, __value: [[::c_char; 4]; 23], } + + #[cfg(libc_union)] + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: ::sockaddr, + pub ifru_dstaddr: ::sockaddr, + pub ifru_broadaddr: ::sockaddr, + pub ifru_netmask: ::sockaddr, + pub ifru_hwaddr: ::sockaddr, + pub ifru_flags: ::c_short, + pub ifru_ifindex: ::c_int, + pub ifru_metric: ::c_int, + pub ifru_mtu: ::c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [::c_char; ::IFNAMSIZ], + pub ifru_newname: [::c_char; ::IFNAMSIZ], + pub ifru_data: *mut ::c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [::c_char; ::IFNAMSIZ], + #[cfg(libc_union)] + pub ifr_ifru: __c_anonymous_ifr_ifru, + #[cfg(not(libc_union))] + pub ifr_ifru: ::sockaddr, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut ::c_char, + pub ifcu_req: *mut ::ifreq, + } + + /* Structure used in SIOCGIFCONF request. Used to retrieve interface + configuration for machine (useful for programs which must know all + networks accessible). */ + pub struct ifconf { + pub ifc_len: ::c_int, /* Size of buffer. */ + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + #[cfg(not(libc_union))] + pub ifc_ifcu: *mut ::ifreq, + } + } cfg_if! { @@ -938,6 +998,53 @@ cfg_if! { } } + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifr_ifru { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifru_addr", unsafe { &self.ifru_addr }) + .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) + .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) + .field("ifru_netmask", unsafe { &self.ifru_netmask }) + .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr }) + .field("ifru_flags", unsafe { &self.ifru_flags }) + .field("ifru_ifindex", unsafe { &self.ifru_ifindex }) + .field("ifru_metric", unsafe { &self.ifru_metric }) + .field("ifru_mtu", unsafe { &self.ifru_mtu }) + .field("ifru_map", unsafe { &self.ifru_map }) + .field("ifru_slave", unsafe { &self.ifru_slave }) + .field("ifru_newname", unsafe { &self.ifru_newname }) + .field("ifru_data", unsafe { &self.ifru_data }) + .finish() + } + } + impl ::fmt::Debug for ifreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifreq") + .field("ifr_name", &self.ifr_name) + .field("ifr_ifru", &self.ifr_ifru) + .finish() + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifcu_buf", unsafe { &self.ifcu_buf }) + .field("ifcu_req", unsafe { &self.ifcu_req }) + .finish() + } + } + impl ::fmt::Debug for ifconf { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifconf") + .field("ifc_len", &self.ifc_len) + .field("ifc_ifcu", &self.ifc_ifcu) + .finish() + } + } + #[allow(deprecated)] impl af_alg_iv { fn as_slice(&self) -> &[u8] { @@ -2715,6 +2822,7 @@ pub const NFEA_DONT_REFRESH: ::c_ushort = 2; pub const SIOCADDRT: ::c_ulong = 0x0000890B; pub const SIOCDELRT: ::c_ulong = 0x0000890C; +pub const SIOCRTMSG: ::c_ulong = 0x0000890D; pub const SIOCGIFNAME: ::c_ulong = 0x00008910; pub const SIOCSIFLINK: ::c_ulong = 0x00008911; pub const SIOCGIFCONF: ::c_ulong = 0x00008912; @@ -2734,6 +2842,7 @@ pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; pub const SIOCSIFMEM: ::c_ulong = 0x00008920; pub const SIOCGIFMTU: ::c_ulong = 0x00008921; pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFNAME: ::c_ulong = 0x00008923; pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; @@ -2742,6 +2851,24 @@ pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; pub const SIOCADDMULTI: ::c_ulong = 0x00008931; pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCGIFINDEX: ::c_ulong = 0x00008933; +pub const SIOGIFINDEX: ::c_ulong = SIOCGIFINDEX; +pub const SIOCSIFPFLAGS: ::c_ulong = 0x00008934; +pub const SIOCGIFPFLAGS: ::c_ulong = 0x00008935; +pub const SIOCDIFADDR: ::c_ulong = 0x00008936; +pub const SIOCSIFHWBROADCAST: ::c_ulong = 0x00008937; +pub const SIOCGIFCOUNT: ::c_ulong = 0x00008938; +pub const SIOCGIFBR: ::c_ulong = 0x00008940; +pub const SIOCSIFBR: ::c_ulong = 0x00008941; +pub const SIOCGIFTXQLEN: ::c_ulong = 0x00008942; +pub const SIOCSIFTXQLEN: ::c_ulong = 0x00008943; +pub const SIOCETHTOOL: ::c_ulong = 0x00008946; +pub const SIOCGMIIPHY: ::c_ulong = 0x00008947; +pub const SIOCGMIIREG: ::c_ulong = 0x00008948; +pub const SIOCSMIIREG: ::c_ulong = 0x00008949; +pub const SIOCWANDEV: ::c_ulong = 0x0000894A; +pub const SIOCOUTQNSD: ::c_ulong = 0x0000894B; +pub const SIOCGSKNS: ::c_ulong = 0x0000894C; pub const SIOCDARP: ::c_ulong = 0x00008953; pub const SIOCGARP: ::c_ulong = 0x00008954; pub const SIOCSARP: ::c_ulong = 0x00008955; @@ -2750,6 +2877,24 @@ pub const SIOCGRARP: ::c_ulong = 0x00008961; pub const SIOCSRARP: ::c_ulong = 0x00008962; pub const SIOCGIFMAP: ::c_ulong = 0x00008970; pub const SIOCSIFMAP: ::c_ulong = 0x00008971; +pub const SIOCADDDLCI: ::c_ulong = 0x00008980; +pub const SIOCDELDLCI: ::c_ulong = 0x00008981; +pub const SIOCGIFVLAN: ::c_ulong = 0x00008982; +pub const SIOCSIFVLAN: ::c_ulong = 0x00008983; +pub const SIOCBONDENSLAVE: ::c_ulong = 0x00008990; +pub const SIOCBONDRELEASE: ::c_ulong = 0x00008991; +pub const SIOCBONDSETHWADDR: ::c_ulong = 0x00008992; +pub const SIOCBONDSLAVEINFOQUERY: ::c_ulong = 0x00008993; +pub const SIOCBONDINFOQUERY: ::c_ulong = 0x00008994; +pub const SIOCBONDCHANGEACTIVE: ::c_ulong = 0x00008995; +pub const SIOCBRADDBR: ::c_ulong = 0x000089a0; +pub const SIOCBRDELBR: ::c_ulong = 0x000089a1; +pub const SIOCBRADDIF: ::c_ulong = 0x000089a2; +pub const SIOCBRDELIF: ::c_ulong = 0x000089a3; +pub const SIOCSHWTSTAMP: ::c_ulong = 0x000089b0; +pub const SIOCGHWTSTAMP: ::c_ulong = 0x000089b1; +pub const SIOCDEVPRIVATE: ::c_ulong = 0x000089F0; +pub const SIOCPROTOPRIVATE: ::c_ulong = 0x000089E0; // linux/module.h pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001; From ba4dd05e027960c980237d286310dc8cbd33ab28 Mon Sep 17 00:00:00 2001 From: arctic-alpaca <67190338+arctic-alpaca@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:05:29 +0100 Subject: [PATCH 26/41] Remove overwritten `cfg.skip_field()` call in `test_android()` --- libc-test/build.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7319c65352958..f8decdb8a692a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1972,21 +1972,6 @@ fn test_android(target: &str) { (struct_ == "flock64" && (field == "l_start" || field == "l_len")) }); - cfg.skip_field(move |struct_, field| { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - (struct_ == "siginfo_t" && field == "_pad") || - // FIXME: `sa_sigaction` has type `sighandler_t` but that type is - // incorrect, see: https://github.com/rust-lang/libc/issues/1359 - (struct_ == "sigaction" && field == "sa_sigaction") || - // sigev_notify_thread_id is actually part of a sigev_un union - (struct_ == "sigevent" && field == "sigev_notify_thread_id") || - // signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet. - (struct_ == "signalfd_siginfo" && (field == "ssi_syscall" || - field == "ssi_call_addr" || - field == "ssi_arch")) - }); - cfg.skip_field(|struct_, field| { match (struct_, field) { // conflicting with `p_type` macro from . From 4e0bfc4392c5784525814b5d11fc0c1f5465d69d Mon Sep 17 00:00:00 2001 From: Laurent Cheylus Date: Tue, 19 Dec 2023 17:23:54 +0100 Subject: [PATCH 27/41] Add waitid function for OpenBSD - Same prototype for waitid function on NetBSD and OpenBSD. - To support it on OpenBSD, move definition from src/unix/bsd/netbsdlike/netbsd/mod.rs to src/unix/bsd/netbsdlike/mod.rs => available on both BSD OS Signed-off-by: Laurent Cheylus --- libc-test/semver/openbsd.txt | 1 + src/unix/bsd/netbsdlike/mod.rs | 6 ++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 6 ------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index fe3d602f54eb7..4f3e01f7390ec 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1274,4 +1274,5 @@ utimensat utmp utrace wait4 +waitid xucred diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 07cdec800658f..a71d48ca7ffa4 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -747,6 +747,12 @@ extern "C" { argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: ::id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; } extern "C" { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 63957d17834f0..f24b82987e1a2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2776,12 +2776,6 @@ extern "C" { timeout: *const ::timespec, ) -> ::c_int; pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; - pub fn waitid( - idtype: idtype_t, - id: ::id_t, - infop: *mut ::siginfo_t, - options: ::c_int, - ) -> ::c_int; pub fn duplocale(base: ::locale_t) -> ::locale_t; pub fn freelocale(loc: ::locale_t); From 65229f1d17728663ae38f30b35a770e3c38dba08 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 20 Dec 2023 07:21:27 +0000 Subject: [PATCH 28/41] adding SOMAXCONN to redox --- src/unix/redox/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 17242eaf2a1df..915fc2c4780e2 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -813,6 +813,7 @@ pub const SOCK_NONBLOCK: ::c_int = 0o4_000; pub const SOCK_CLOEXEC: ::c_int = 0o2_000_000; pub const SOCK_SEQPACKET: ::c_int = 5; pub const SOL_SOCKET: ::c_int = 1; +pub const SOMAXCONN: ::c_int = 128; // sys/termios.h pub const VEOF: usize = 0; From 95fab0f8460b6b14f49abda98bf245a66922d426 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 20 Dec 2023 07:56:16 -0700 Subject: [PATCH 29/41] fix typos in comments These two messages got accidentally swapped in PR #2545 --- src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 0e04a12e70e47..ec6bce2a03091 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -1,4 +1,4 @@ -// APIs in FreeBSD 14 that have changed since 11. +// APIs in FreeBSD 13 that have changed since 11. pub type nlink_t = u64; pub type dev_t = u64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index a86ca6e7c56ea..160a4baae481b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -1,4 +1,4 @@ -// APIs in FreeBSD 13 that have changed since 11. +// APIs in FreeBSD 14 that have changed since 11. pub type nlink_t = u64; pub type dev_t = u64; From 346b7380c51d2f14b24b23f61130647a643c6f05 Mon Sep 17 00:00:00 2001 From: Takashi Idobe Date: Sat, 23 Dec 2023 19:28:52 -0500 Subject: [PATCH 30/41] fix typos in libc --- libc-test/build.rs | 4 ++-- src/unix/bsd/apple/mod.rs | 2 +- src/unix/linux_like/linux/uclibc/x86_64/l4re.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 23134e0f56609..4c2f7f03614c0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3281,7 +3281,7 @@ fn test_linux(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - // This macro re-deifnes fscanf,scanf,sscanf to link to the symbols that are + // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are // deprecated since glibc >= 2.29. This allows Rust binaries to link against // glibc versions older than 2.29. cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None); @@ -3849,7 +3849,7 @@ fn test_linux(target: &str) { "PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true, // present in recent kernels only - "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, + "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, // present in recent kernels only >= 5.13 "PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 7d27777232842..dbf91a099a7bc 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -6239,7 +6239,7 @@ extern "C" { buffersize: u32, ) -> ::c_int; pub fn proc_kmsgbuf(buffer: *mut ::c_void, buffersize: u32) -> ::c_int; - pub fn proc_libversion(major: *mut ::c_int, mintor: *mut ::c_int) -> ::c_int; + pub fn proc_libversion(major: *mut ::c_int, minor: *mut ::c_int) -> ::c_int; pub fn proc_pid_rusage(pid: ::c_int, flavor: ::c_int, buffer: *mut rusage_info_t) -> ::c_int; // Available from Big Sur diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index c7cbafa16ecf3..56a0e37f6dfcb 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -13,7 +13,7 @@ s! { /// Combination of granularity and offset. /// /// The granularity defines how many CPUs each bit in map describes. - /// The offset is the numer of the first CPU described by the first + /// The offset is the number of the first CPU described by the first /// bit in the bitmap. /// offset must be a multiple of 2^graularity. /// From 9bb8dca44e07bf8bc514edaa33fce7a725526456 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 15 Dec 2023 19:04:08 +0000 Subject: [PATCH 31/41] apple adding tcp_connection_info struct --- libc-test/build.rs | 3 +++ libc-test/semver/apple.txt | 2 ++ src/unix/bsd/apple/mod.rs | 44 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 23134e0f56609..c71ce48513205 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -309,6 +309,9 @@ fn test_apple(target: &str) { // FIXME: The size is changed in recent macOSes. "malloc_zone_t" => true, + // it is a moving target, changing through versions + // also contains bitfields members + "tcp_connection_info" => true, _ => false, } diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 5a34303a157fc..b1911e290dad4 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1366,6 +1366,7 @@ TAB1 TAB2 TAB3 TABDLY +TCP_CONNECTION_INFO TCP_FASTOPEN TCP_KEEPALIVE TCP_KEEPCNT @@ -2246,6 +2247,7 @@ task_info task_inspect_t task_terminate task_threads +tcp_connection_info telldir thread_basic_info_t thread_extended_info_t diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 7d27777232842..7b2cf825d5ebb 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1138,6 +1138,49 @@ s! { #[cfg(not(libc_union))] pub ifc_ifcu: *mut ifreq, } + + #[cfg_attr(libc_align, repr(align(8)))] + pub struct tcp_connection_info { + pub tcpi_state: u8, + pub tcpi_snd_wscale: u8, + pub tcpi_rcv_wscale: u8, + __pad1: u8, + pub tcpi_options: u32, + pub tcpi_flags: u32, + pub tcpi_rto: u32, + pub tcpi_maxseg: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_sbbytes: u32, + pub tcpi_rcv_wnd: u32, + pub tcpi_rttcur: u32, + pub tcpi_srtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_tfo_cookie_req: u32, + pub tcpi_tfo_cookie_rcv: u32, + pub tcpi_tfo_syn_loss: u32, + pub tcpi_tfo_syn_data_sent: u32, + pub tcpi_tfo_syn_data_acked: u32, + pub tcpi_tfo_syn_data_rcv: u32, + pub tcpi_tfo_cookie_req_rcv: u32, + pub tcpi_tfo_cookie_sent: u32, + pub tcpi_tfo_cookie_invalid: u32, + pub tcpi_tfo_cookie_wrong: u32, + pub tcpi_tfo_no_cookie_rcv: u32, + pub tcpi_tfo_heuristics_disable: u32, + pub tcpi_tfo_send_blackhole: u32, + pub tcpi_tfo_recv_blackhole: u32, + pub tcpi_tfo_onebyte_proxy: u32, + __pad2: u32, + pub tcpi_txpackets: u64, + pub tcpi_txbytes: u64, + pub tcpi_txretransmitbytes: u64, + pub tcpi_rxpackets: u64, + pub tcpi_rxbytes: u64, + pub tcpi_rxoutoforderbytes: u64, + pub tcpi_rxretransmitpackets: u64, + } } s_no_extra_traits! { @@ -4103,6 +4146,7 @@ pub const TCP_KEEPINTVL: ::c_int = 0x101; pub const TCP_KEEPCNT: ::c_int = 0x102; /// Enable/Disable TCP Fastopen on this socket pub const TCP_FASTOPEN: ::c_int = 0x105; +pub const TCP_CONNECTION_INFO: ::c_int = 0x106; pub const SOL_LOCAL: ::c_int = 0; From 4e59d5ee8b0532ac83ce63c9bbad5f108105ebc5 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 27 Dec 2023 19:04:12 +0000 Subject: [PATCH 32/41] solarish add fcntl's O_DIRECT constant. --- src/unix/solarish/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index c34ff890b412a..515c0037b42d2 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1294,12 +1294,13 @@ pub const O_EXCL: ::c_int = 1024; pub const O_NOCTTY: ::c_int = 2048; pub const O_TRUNC: ::c_int = 512; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const O_DIRECTORY: ::c_int = 0x1000000; pub const O_SEARCH: ::c_int = 0x200000; pub const O_EXEC: ::c_int = 0x400000; pub const O_CLOEXEC: ::c_int = 0x800000; pub const O_ACCMODE: ::c_int = 0x600003; pub const O_XATTR: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x1000000; +pub const O_DIRECT: ::c_int = 0x2000000; pub const S_IFIFO: mode_t = 4096; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; From c42459239c172ad30ce4b56fc88c9627af8c140f Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 24 Dec 2023 17:47:25 +0100 Subject: [PATCH 33/41] Improve the version parser of Emscripten Some Emscripten versions come with `-git` attached, so split the version string also on the `-` char. See: https://github.com/rust-lang/rust/issues/119250. --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index ee99981881c04..6c684a5c1c838 100644 --- a/build.rs +++ b/build.rs @@ -274,7 +274,10 @@ fn emcc_version_code() -> Option { return None; } let version = stdout.unwrap(); - let mut pieces = version.trim().split('.'); + + // Some Emscripten versions come with `-git` attached, so split the + // version string also on the `-` char. + let mut pieces = version.trim().split(|c| c == '.' || c == '-'); let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); From e0fcb4b70579b48bc831aec2c60f84731e60c836 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 29 Dec 2023 08:28:07 -0800 Subject: [PATCH 34/41] Define `TFD_TIMER_*` constants on FreeBSD. Following up on #3341, add `TFD_TIMER_*` constants for use with the timerfd API on FreeBSD. --- libc-test/build.rs | 6 +++++- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1a5500072ece5..f21a069a57ddd 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2425,7 +2425,11 @@ fn test_freebsd(target: &str) { "AT_USRSTACKBASE" | "AT_USRSTACKLIM" if Some(13) > freebsd_ver => true, // Added in FreeBSD 14 - "TFD_CLOEXEC" | "TFD_NONBLOCK" if Some(14) > freebsd_ver => true, + "TFD_CLOEXEC" | "TFD_NONBLOCK" | "TFD_TIMER_ABSTIME" | "TFD_TIMER_CANCEL_ON_SET" + if Some(14) > freebsd_ver => + { + true + } _ => false, } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 799e3811ed44c..68bd4e28b0cf8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4732,6 +4732,8 @@ pub const RB_MULTIPLE: ::c_int = 0x20000000; pub const TFD_NONBLOCK: ::c_int = ::O_NONBLOCK; pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; +pub const TFD_TIMER_ABSTIME: ::c_int = 0x01; +pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02; cfg_if! { if #[cfg(libc_const_extern_fn)] { From f859c278eda743efc52b00bd4e7b84abd09f5536 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 29 Dec 2023 00:28:33 +0100 Subject: [PATCH 35/41] Add constants from --- libc-test/build.rs | 27 +++++++++++++++++++++++++++ src/unix/linux_like/linux/mod.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4c2f7f03614c0..05e11f8e43e14 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4056,6 +4056,33 @@ fn test_linux(target: &str) { true } + // FIXME: seems to not be available all the time (from : + "PF_VCPU" + | "PF_IDLE" + | "PF_EXITING" + | "PF_POSTCOREDUMP" + | "PF_IO_WORKER" + | "PF_WQ_WORKER" + | "PF_FORKNOEXEC" + | "PF_MCE_PROCESS" + | "PF_SUPERPRIV" + | "PF_DUMPCORE" + | "PF_SIGNALED" + | "PF_MEMALLOC" + | "PF_NPROC_EXCEEDED" + | "PF_USED_MATH" + | "PF_USER_WORKER" + | "PF_NOFREEZE" + | "PF_KSWAPD" + | "PF_MEMALLOC_NOFS" + | "PF_MEMALLOC_NOIO" + | "PF_LOCAL_THROTTLE" + | "PF_KTHREAD" + | "PF_RANDOMIZE" + | "PF_NO_SETAFFINITY" + | "PF_MCE_EARLY" + | "PF_MEMALLOC_PIN" => true, + _ => false, } }); diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index b763ab6261bb9..1f66cf6c42464 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4519,6 +4519,33 @@ pub const NET_NETFILTER: ::c_int = 19; pub const NET_DCCP: ::c_int = 20; pub const NET_IRDA: ::c_int = 412; +// include/linux/sched.h +pub const PF_VCPU: ::c_int = 0x00000001; +pub const PF_IDLE: ::c_int = 0x00000002; +pub const PF_EXITING: ::c_int = 0x00000004; +pub const PF_POSTCOREDUMP: ::c_int = 0x00000008; +pub const PF_IO_WORKER: ::c_int = 0x00000010; +pub const PF_WQ_WORKER: ::c_int = 0x00000020; +pub const PF_FORKNOEXEC: ::c_int = 0x00000040; +pub const PF_MCE_PROCESS: ::c_int = 0x00000080; +pub const PF_SUPERPRIV: ::c_int = 0x00000100; +pub const PF_DUMPCORE: ::c_int = 0x00000200; +pub const PF_SIGNALED: ::c_int = 0x00000400; +pub const PF_MEMALLOC: ::c_int = 0x00000800; +pub const PF_NPROC_EXCEEDED: ::c_int = 0x00001000; +pub const PF_USED_MATH: ::c_int = 0x00002000; +pub const PF_USER_WORKER: ::c_int = 0x00004000; +pub const PF_NOFREEZE: ::c_int = 0x00008000; +pub const PF_KSWAPD: ::c_int = 0x00020000; +pub const PF_MEMALLOC_NOFS: ::c_int = 0x00040000; +pub const PF_MEMALLOC_NOIO: ::c_int = 0x00080000; +pub const PF_LOCAL_THROTTLE: ::c_int = 0x00100000; +pub const PF_KTHREAD: ::c_int = 0x00200000; +pub const PF_RANDOMIZE: ::c_int = 0x00400000; +pub const PF_NO_SETAFFINITY: ::c_int = 0x04000000; +pub const PF_MCE_EARLY: ::c_int = 0x08000000; +pub const PF_MEMALLOC_PIN: ::c_int = 0x10000000; + f! { pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) From 5c197556db0fbc044d89a6c064b7f51bb3147efd Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 30 Dec 2023 11:59:18 +0900 Subject: [PATCH 36/41] Fix comment --- libc-test/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 05e11f8e43e14..5a8e77b1cc794 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4056,7 +4056,7 @@ fn test_linux(target: &str) { true } - // FIXME: seems to not be available all the time (from : + // FIXME: seems to not be available all the time (from : "PF_VCPU" | "PF_IDLE" | "PF_EXITING" From 2dc04b82a3f04abbf5199fa74767444c9f0fc924 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 30 Dec 2023 18:39:09 +0000 Subject: [PATCH 37/41] freebsd 15 support proposal. --- .cirrus.yml | 14 + build.rs | 3 + libc-test/build.rs | 11 +- .../bsd/freebsdlike/freebsd/freebsd15/b64.rs | 34 ++ .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 546 ++++++++++++++++++ .../freebsdlike/freebsd/freebsd15/x86_64.rs | 12 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 57 +- 7 files changed, 650 insertions(+), 27 deletions(-) create mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs create mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs create mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs diff --git a/.cirrus.yml b/.cirrus.yml index 31f0e98f2a09a..e428871c41b84 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -25,3 +25,17 @@ task: - . $HOME/.cargo/env - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd - sh ci/run.sh x86_64-unknown-freebsd + +task: + name: nightly x86_64-unknown-freebsd-15 + freebsd_instance: + image_family: freebsd-15-0-snap + setup_script: + - pkg install -y libnghttp2 curl + - curl https://sh.rustup.rs -sSf --output rustup.sh + - sh rustup.sh -y --default-toolchain nightly --profile=minimal + - . $HOME/.cargo/env + test_script: + - . $HOME/.cargo/env + - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd + - sh ci/run.sh x86_64-unknown-freebsd diff --git a/build.rs b/build.rs index 6c684a5c1c838..ec932007ae69f 100644 --- a/build.rs +++ b/build.rs @@ -13,6 +13,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd12", "freebsd13", "freebsd14", + "freebsd15", "libc_align", "libc_cfg_target_vendor", "libc_const_extern_fn", @@ -70,6 +71,7 @@ fn main() { Some(12) if libc_ci || rustc_dep_of_std => set_cfg("freebsd12"), Some(13) if libc_ci => set_cfg("freebsd13"), Some(14) if libc_ci => set_cfg("freebsd14"), + Some(15) if libc_ci => set_cfg("freebsd15"), Some(_) | None => set_cfg("freebsd11"), } @@ -252,6 +254,7 @@ fn which_freebsd() -> Option { 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, } } diff --git a/libc-test/build.rs b/libc-test/build.rs index 9da1ab9c7c55c..0373d0918239c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2013,6 +2013,7 @@ fn test_freebsd(target: &str) { Some(12) => cfg.cfg("freebsd12", None), Some(13) => cfg.cfg("freebsd13", None), Some(14) => cfg.cfg("freebsd14", None), + Some(15) => cfg.cfg("freebsd15", None), _ => &mut cfg, }; @@ -2031,6 +2032,10 @@ fn test_freebsd(target: &str) { Some(n) if n >= 14 => true, _ => false, }; + let freebsd15 = match freebsd_ver { + Some(n) if n >= 15 => true, + _ => false, + }; headers! { cfg: "aio.h", @@ -2118,7 +2123,7 @@ fn test_freebsd(target: &str) { "sys/sysctl.h", "sys/thr.h", "sys/time.h", - [freebsd14]:"sys/timerfd.h", + [freebsd14 || freebsd15]:"sys/timerfd.h", "sys/times.h", "sys/timex.h", "sys/types.h", @@ -2402,6 +2407,9 @@ fn test_freebsd(target: &str) { true } + // Introduced in FreeBSD 14 then removed ? + "TCP_LRD" if freebsd_ver >= Some(15) => true, + // Added in FreeBSD 14 "LIO_READV" | "LIO_WRITEV" | "LIO_VECTORED" if Some(14) > freebsd_ver => true, @@ -4487,6 +4495,7 @@ fn which_freebsd() -> Option { 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, } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs new file mode 100644 index 0000000000000..80c6fa1684530 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs @@ -0,0 +1,34 @@ +#[repr(C)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { + *self + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs new file mode 100644 index 0000000000000..d73215a68ec33 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -0,0 +1,546 @@ +// APIs in FreeBSD 15 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = ::c_ulong; +pub type shmatt_t = ::c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: i64, + pub udata: *mut ::c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: ::u_int, + pub kp_paddr: ::kpaddr_t, + pub kp_kmap_vaddr: ::kvaddr_t, + pub kp_dmap_vaddr: ::kvaddr_t, + pub kp_prot: ::vm_prot_t, + pub kp_offset: ::off_t, + pub kp_len: ::size_t, + } + + pub struct __c_anonymous_domainset { + _priv: [::uintptr_t; 4], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *const ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: u8, + pub d_namlen: u16, + d_pad1: u16, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 1024], + pub f_mntonname: [::c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_version == other.f_version + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_fsid == other.f_fsid + && self.f_fstypename == other.f_fstypename + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_fsid", &self.f_fsid) + .field("f_fstypename", &self.f_fstypename) + .field("f_mntfromname", &&self.f_mntfromname[..]) + .field("f_mntonname", &&self.f_mntonname[..]) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_version.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_fsid.hash(state); + self.f_charspare.hash(state); + self.f_fstypename.hash(state); + self.f_mntfromname.hash(state); + self.f_mntonname.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name[..self.d_namlen as _] + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + .field("d_name", &&self.d_name[..self.d_namlen as _]) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } + } +} + +pub const RAND_MAX: ::c_int = 0x7fff_ffff; +pub const ELAST: ::c_int = 97; + +pub const KF_TYPE_EVENTFD: ::c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: ::c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: ::c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: ::c_int = 2; +pub const DOMAINSET_POLICY_PREFER: ::c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4; + +pub const MINCORE_SUPER: ::c_int = 0x60; + +safe_f! { + pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { + let major = major as ::dev_t; + let minor = minor as ::dev_t; + let mut dev = 0; + dev |= ((major & 0xffffff00) as dev_t) << 32; + dev |= ((major & 0x000000ff) as dev_t) << 8; + dev |= ((minor & 0x0000ff00) as dev_t) << 24; + dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev + } +} + +f! { + pub fn major(dev: ::dev_t) -> ::c_int { + (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as ::c_int + } + + pub fn minor(dev: ::dev_t) -> ::c_int { + (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as ::c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn freelocale(loc: ::locale_t); + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + + pub fn cpuset_getdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *mut ::domainset_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn cpuset_setdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *const ::domainset_t, + policy: ::c_int, + ) -> ::c_int; + + pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; + pub fn basename(path: *mut ::c_char) -> *mut ::c_char; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64"))] { + mod b64; + pub use self::b64::*; + } +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs new file mode 100644 index 0000000000000..01d0b4328da81 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs @@ -0,0 +1,12 @@ +pub const PROC_KPTI_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: ::c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: ::c_int = 2; +pub const PROC_KPTI_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: ::c_int = 0x80000000; +pub const PROC_LA_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN + 2; +pub const PROC_LA_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 3; +pub const PROC_LA_CTL_LA48_ON_EXEC: ::c_int = 1; +pub const PROC_LA_CTL_LA57_ON_EXEC: ::c_int = 2; +pub const PROC_LA_CTL_DEFAULT_ON_EXEC: ::c_int = 3; +pub const PROC_LA_STATUS_LA48: ::c_int = 0x01000000; +pub const PROC_LA_STATUS_LA57: ::c_int = 0x02000000; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 68bd4e28b0cf8..e1dcc32f7c2a2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -367,13 +367,13 @@ s! { } pub struct cpuset_t { - #[cfg(all(freebsd14, target_pointer_width = "64"))] + #[cfg(all(any(freebsd15, freebsd14), target_pointer_width = "64"))] __bits: [::c_long; 16], - #[cfg(all(freebsd14, target_pointer_width = "32"))] + #[cfg(all(any(freebsd15, freebsd14), target_pointer_width = "32"))] __bits: [::c_long; 32], - #[cfg(all(not(freebsd14), target_pointer_width = "64"))] + #[cfg(all(not(any(freebsd15, freebsd14)), target_pointer_width = "64"))] __bits: [::c_long; 4], - #[cfg(all(not(freebsd14), target_pointer_width = "32"))] + #[cfg(all(not(any(freebsd15, freebsd14)), target_pointer_width = "32"))] __bits: [::c_long; 8], } @@ -597,9 +597,9 @@ s! { pub sa_peer: ::sockaddr_storage, pub type_: ::c_int, pub dname: [::c_char; 32], - #[cfg(any(freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub sendq: ::c_uint, - #[cfg(any(freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub recvq: ::c_uint, } @@ -1046,39 +1046,41 @@ s! { pub tcpi_snd_rexmitpack: u32, pub tcpi_rcv_ooopack: u32, pub tcpi_snd_zerowin: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_delivered_ce: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_received_ce: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_delivered_e1_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_delivered_e0_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_delivered_ce_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_received_e1_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_received_e0_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_received_ce_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_total_tlp: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_total_tlp_bytes: u64, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_snd_una: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_snd_max: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_rcv_numsacks: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_rcv_adv: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_dupacks: u32, #[cfg(freebsd14)] pub __tcpi_pad: [u32; 10], - #[cfg(not(freebsd14))] + #[cfg(freebsd15)] + pub __tcpi_pad: [u32; 14], + #[cfg(not(any(freebsd15, freebsd14)))] pub __tcpi_pad: [u32; 26], } @@ -1406,9 +1408,9 @@ s_no_extra_traits! { } pub struct ptsstat { - #[cfg(any(freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub dev: u64, - #[cfg(not(any(freebsd12, freebsd13, freebsd14)))] + #[cfg(not(any(freebsd12, freebsd13, freebsd14, freebsd15)))] pub dev: u32, pub devname: [::c_char; SPECNAMELEN as usize + 1], } @@ -2622,7 +2624,7 @@ pub const DEVSTAT_NAME_LEN: ::c_int = 16; // sys/cpuset.h cfg_if! { - if #[cfg(freebsd14)] { + if #[cfg(any(freebsd15, freebsd14))] { pub const CPU_SETSIZE: ::c_int = 1024; } else { pub const CPU_SETSIZE: ::c_int = 256; @@ -5710,7 +5712,10 @@ extern "C" { } cfg_if! { - if #[cfg(freebsd14)] { + if #[cfg(freebsd15)] { + mod freebsd15; + pub use self::freebsd15::*; + } else if #[cfg(freebsd14)] { mod freebsd14; pub use self::freebsd14::*; } else if #[cfg(freebsd13)] { From e004210089f3d16af0916a305574c29b72db5163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D1=81=D0=B0=D0=B0=D0=BA=20=D0=90=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= <62861466+nuudlman@users.noreply.github.com> Date: Tue, 26 Dec 2023 19:13:36 +0000 Subject: [PATCH 38/41] Add posix_spawn(3) support on OpenBSD --- libc-test/build.rs | 1 + libc-test/semver/openbsd.txt | 21 +++++++ src/unix/bsd/netbsdlike/mod.rs | 84 ++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 83 ------------------------- src/unix/bsd/netbsdlike/openbsd/mod.rs | 4 ++ 5 files changed, 110 insertions(+), 83 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4c2f7f03614c0..21b0331a14a9e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -478,6 +478,7 @@ fn test_openbsd(target: &str) { "pthread.h", "dlfcn.h", "search.h", + "spawn.h", "signal.h", "string.h", "sys/file.h", diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 4f3e01f7390ec..755983539ac8f 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1156,6 +1156,27 @@ pipe2 pledge popen posix_madvise +posix_spawn +posix_spawn_file_actions_addclose +posix_spawn_file_actions_adddup2 +posix_spawn_file_actions_addopen +posix_spawn_file_actions_destroy +posix_spawn_file_actions_init +posix_spawnattr_destroy +posix_spawnattr_getflags +posix_spawnattr_getpgroup +posix_spawnattr_getschedparam +posix_spawnattr_getschedpolicy +posix_spawnattr_getsigdefault +posix_spawnattr_getsigmask +posix_spawnattr_init +posix_spawnattr_setflags +posix_spawnattr_setpgroup +posix_spawnattr_setschedparam +posix_spawnattr_setschedpolicy +posix_spawnattr_setsigdefault +posix_spawnattr_setsigmask +posix_spawnp preadv pseudo_AF_HDRCMPLT pseudo_AF_PFLOW diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index a71d48ca7ffa4..e92cf65940141 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -364,6 +364,13 @@ pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; + pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; @@ -753,6 +760,83 @@ extern "C" { infop: *mut ::siginfo_t, options: ::c_int, ) -> ::c_int; + + pub fn posix_spawn( + pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnp( + pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getflags( + attr: *const posix_spawnattr_t, + flags: *mut ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: ::c_int) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; } extern "C" { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index f24b82987e1a2..7c63db8e0e205 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2343,13 +2343,6 @@ pub const PT_LWPNEXT: ::c_int = 25; pub const PT_SET_SIGPASS: ::c_int = 26; pub const PT_GET_SIGPASS: ::c_int = 27; pub const PT_FIRSTMACH: ::c_int = 32; - -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; -pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; -pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; pub const POSIX_SPAWN_RETURNERROR: ::c_int = 0x40; // Flags for chflags(2) @@ -2888,82 +2881,6 @@ extern "C" { ts: *const ::timespec, sigmask: *const ::sigset_t, ) -> ::c_int; - pub fn posix_spawn( - pid: *mut ::pid_t, - path: *const ::c_char, - file_actions: *const ::posix_spawn_file_actions_t, - attrp: *const ::posix_spawnattr_t, - argv: *const *mut ::c_char, - envp: *const *mut ::c_char, - ) -> ::c_int; - pub fn posix_spawnp( - pid: *mut ::pid_t, - file: *const ::c_char, - file_actions: *const ::posix_spawn_file_actions_t, - attrp: *const ::posix_spawnattr_t, - argv: *const *mut ::c_char, - envp: *const *mut ::c_char, - ) -> ::c_int; - pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; - pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; - pub fn posix_spawnattr_getsigdefault( - attr: *const posix_spawnattr_t, - default: *mut ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_setsigdefault( - attr: *mut posix_spawnattr_t, - default: *const ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_getsigmask( - attr: *const posix_spawnattr_t, - default: *mut ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_setsigmask( - attr: *mut posix_spawnattr_t, - default: *const ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_getflags( - attr: *const posix_spawnattr_t, - flags: *mut ::c_short, - ) -> ::c_int; - pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int; - pub fn posix_spawnattr_getpgroup( - attr: *const posix_spawnattr_t, - flags: *mut ::pid_t, - ) -> ::c_int; - pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; - pub fn posix_spawnattr_getschedpolicy( - attr: *const posix_spawnattr_t, - flags: *mut ::c_int, - ) -> ::c_int; - pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: ::c_int) -> ::c_int; - pub fn posix_spawnattr_getschedparam( - attr: *const posix_spawnattr_t, - param: *mut ::sched_param, - ) -> ::c_int; - pub fn posix_spawnattr_setschedparam( - attr: *mut posix_spawnattr_t, - param: *const ::sched_param, - ) -> ::c_int; - - pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; - pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; - pub fn posix_spawn_file_actions_addopen( - actions: *mut posix_spawn_file_actions_t, - fd: ::c_int, - path: *const ::c_char, - oflag: ::c_int, - mode: ::mode_t, - ) -> ::c_int; - pub fn posix_spawn_file_actions_addclose( - actions: *mut posix_spawn_file_actions_t, - fd: ::c_int, - ) -> ::c_int; - pub fn posix_spawn_file_actions_adddup2( - actions: *mut posix_spawn_file_actions_t, - fd: ::c_int, - newfd: ::c_int, - ) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; pub fn reboot(mode: ::c_int, bootstr: *mut ::c_char) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 1b683a4eb98b7..8f470aff9a357 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -41,6 +41,10 @@ pub type Elf64_Xword = u64; pub type ENTRY = entry; pub type ACTION = ::c_uint; +// spawn.h +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; From b27bf46e5fb81f24e96cee36aff4ea6daaad4f8f Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 31 Dec 2023 20:05:56 +0000 Subject: [PATCH 39/41] clock_nanosleep for dragonflybsd, moving constants freebsd only too. --- libc-test/semver/dragonfly.txt | 1 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 12 +++++------- src/unix/bsd/freebsdlike/mod.rs | 10 +++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index c1942853289dc..20e8a515d36f4 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1263,6 +1263,7 @@ chroot clearerr clock_getcpuclockid clock_getres +clock_nanosleep clock_settime cmsgcred cmsghdr diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 68bd4e28b0cf8..59e7e3939eb75 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4728,6 +4728,11 @@ pub const RB_POWERCYCLE: ::c_int = 0x400000; pub const RB_PROBE: ::c_int = 0x10000000; pub const RB_MULTIPLE: ::c_int = 0x20000000; +// sys/time.h +pub const CLOCK_BOOTTIME: ::clockid_t = ::CLOCK_UPTIME; +pub const CLOCK_REALTIME_COARSE: ::clockid_t = ::CLOCK_REALTIME_FAST; +pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = ::CLOCK_MONOTONIC_FAST; + // sys/timerfd.h pub const TFD_NONBLOCK: ::c_int = ::O_NONBLOCK; @@ -5363,13 +5368,6 @@ extern "C" { pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int; - pub fn clock_nanosleep( - clk_id: ::clockid_t, - flags: ::c_int, - rqtp: *const ::timespec, - rmtp: *mut ::timespec, - ) -> ::c_int; - pub fn strchrnul(s: *const ::c_char, c: ::c_int) -> *mut ::c_char; pub fn shm_create_largepage( diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index d2cd7794b107e..00a944e42bf2d 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -824,15 +824,12 @@ pub const CLOCK_VIRTUAL: ::clockid_t = 1; pub const CLOCK_PROF: ::clockid_t = 2; pub const CLOCK_MONOTONIC: ::clockid_t = 4; pub const CLOCK_UPTIME: ::clockid_t = 5; -pub const CLOCK_BOOTTIME: ::clockid_t = CLOCK_UPTIME; pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; -pub const CLOCK_REALTIME_COARSE: ::clockid_t = CLOCK_REALTIME_FAST; pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; -pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = CLOCK_MONOTONIC_FAST; pub const CLOCK_SECOND: ::clockid_t = 13; pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; @@ -1493,6 +1490,13 @@ extern "C" { atflag: ::c_int, ) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; From 9824274d9ddfd9e86c1e061edec6cb114ceabce3 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 3 Jan 2024 15:59:51 +0900 Subject: [PATCH 40/41] Unpin cc dependency version --- libc-test/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index d09d3802ad72c..20543d69bcb0f 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -16,8 +16,7 @@ version = "0.2.151" default-features = false [build-dependencies] -# FIXME: 1.0.84 has a bug about macOS version detection. -cc = "=1.0.83" +cc = "1.0.83" # FIXME: Use fork ctest until the maintainer gets back. ctest2 = "0.4.3" From a6191c5f6f4e1a737eff83728173e2939211a6d2 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 3 Jan 2024 10:04:15 -0700 Subject: [PATCH 41/41] redox: add openpty, login_tty, TIOCSCTTY, and organize functions --- libc-test/semver/redox.txt | 3 +++ src/unix/redox/mod.rs | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 5f85e1aa7f3d4..80095a09f5345 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -145,6 +145,7 @@ TCGETS TCP_KEEPIDLE TCSETS TIOCGPGRP +TIOCSCTTY TIOCSPGRP UTSLENGTH VDISCARD @@ -207,11 +208,13 @@ getservbyport getservent killpg lockf +login_tty madvise memalign nice open_memstream open_wmemstream +openpty pipe2 pthread_condattr_setclock qsort diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 915fc2c4780e2..19315c3872c88 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -729,6 +729,7 @@ pub const FIOCLEX: ::c_ulong = 0x5451; pub const TCGETS: ::c_ulong = 0x5401; pub const TCSETS: ::c_ulong = 0x5402; pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCSCTTY: ::c_ulong = 0x540E; pub const TIOCGPGRP: ::c_ulong = 0x540F; pub const TIOCSPGRP: ::c_ulong = 0x5410; pub const TIOCGWINSZ: ::c_ulong = 0x5413; @@ -1138,6 +1139,15 @@ extern "C" { clock_id: ::clockid_t, ) -> ::c_int; + //pty.h + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *const termios, + winp: *const ::winsize, + ) -> ::c_int; + // pwd.h pub fn getpwent() -> *mut passwd; pub fn setpwent(); @@ -1173,9 +1183,15 @@ extern "C" { pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; // stdlib.h + pub fn getsubopt( + optionp: *mut *mut c_char, + tokens: *const *mut c_char, + valuep: *mut *mut c_char, + ) -> ::c_int; pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; // string.h + pub fn explicit_bzero(p: *mut ::c_void, len: ::size_t); pub fn strlcat(dst: *mut ::c_char, src: *const ::c_char, siz: ::size_t) -> ::size_t; pub fn strlcpy(dst: *mut ::c_char, src: *const ::c_char, siz: ::size_t) -> ::size_t; @@ -1202,6 +1218,8 @@ extern "C" { pub fn shm_unlink(name: *const ::c_char) -> ::c_int; // sys/resource.h + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; @@ -1230,17 +1248,8 @@ extern "C" { pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - // strings.h - pub fn explicit_bzero(p: *mut ::c_void, len: ::size_t); - - pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; - pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - - pub fn getsubopt( - optionp: *mut *mut c_char, - tokens: *const *mut c_char, - valuep: *mut *mut c_char, - ) -> ::c_int; + // utmp.h + pub fn login_tty(fd: ::c_int) -> ::c_int; } cfg_if! {