From b668252303c6a79c465aabc9a002bc0b4a79df6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=96=D1=83=D0=BD=D1=91=D0=B2=D0=B0=20=D0=9C=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=9C=D0=B8=D1=85=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=BD=D0=B0?= Date: Fri, 21 Jun 2024 18:21:30 +0300 Subject: [PATCH 1/5] Add structures for freebsd (backport ) (cherry picked from commit 187468d37a3e9d785d915bfe7b82f81c3c6dc3f1) --- libc-test/build.rs | 2 ++ libc-test/semver/freebsd.txt | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index eb41e2eaa7ac8..4aa1fa8bd8338 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2312,6 +2312,7 @@ fn test_freebsd(target: &str) { "sys/thr.h", "sys/time.h", [freebsd14 || freebsd15]:"sys/timerfd.h", + [freebsd13 || freebsd14 || freebsd15]:"dev/evdev/input.h", "sys/times.h", "sys/timex.h", "sys/types.h", @@ -2385,6 +2386,7 @@ fn test_freebsd(target: &str) { "type_" if struct_ == "rtprio" => "type".to_string(), "type_" if struct_ == "sockstat" => "type".to_string(), "type_" if struct_ == "devstat_match_table" => "type".to_string(), + "type_" if struct_ == "input_event" => "type".to_string(), s => s.to_string(), } }); diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 486d11e64a60a..a5a9f9befb9d9 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2026,6 +2026,8 @@ ifconf ifreq in6_pktinfo initgroups +input_absinfo +input_event ip_mreqn ipc_perm jail diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index ae4e366afdd48..23bbb1e1c47fe 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -290,6 +290,22 @@ s! { pub sem_flg: c_short, } + pub struct input_event { + pub time: crate::timeval, + pub type_: crate::u_short, + pub code: crate::u_short, + pub value: i32, + } + + pub struct input_absinfo { + pub value: i32, + pub minimum: i32, + pub maximum: i32, + pub fuzz: i32, + pub flat: i32, + pub resolution: i32, + } + pub struct msqid_ds { pub msg_perm: crate::ipc_perm, __unused1: *mut c_void, From 116b82e5aec3a42415d4586fbe01d4dcde5240dd Mon Sep 17 00:00:00 2001 From: Kartik Agarwala Date: Thu, 30 Jan 2025 13:52:59 +0530 Subject: [PATCH 2/5] Fix size of time_t in vxworks (backport ) (cherry picked from commit eec39f5d73774977fe237958e44490e0ec86fcdc) --- src/vxworks/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 2b910616d794c..073b5d07ce6fa 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -34,7 +34,7 @@ pub type ino_t = c_ulong; pub type rlim_t = c_ulong; pub type suseconds_t = c_long; -pub type time_t = c_long; +pub type time_t = c_longlong; pub type errno_t = c_int; From 7a7fe4683185d030bd16630b58387b82786f5597 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 19 Dec 2024 09:03:23 +0100 Subject: [PATCH 3/5] Apply modulo 256 to BSD WEXITSTATUS wait(2p)[^1] says > WEXITSTATUS(status) > If WIFEXITED(status) is true, evaluates to the low-order 8 bits > of the argument passed to _exit(2) or exit(3) by the child. meaning WEXITSTATUS(status) is an 8-bit value. We accidentally return too many bits. For example WEXITSTATUS(-1) returns -1 instead of 255. Fix it, matching the C library and our other WEXITSTATUS implementations. [^1] https://manpage.me/index.cgi?apropos=0&q=wait&sektion=2&manpath=FreeBSD+12-CURRENT+and+Ports&arch=default&format=html Originally reported at https://github.com/fish-shell/fish-shell/issues/10919 (backport ) (cherry picked from commit f9cde2f7241fca7fe5c5d9564c8d361847f42f9e) --- src/unix/bsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d8e52f5f74245..445957537eb76 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -639,7 +639,7 @@ safe_f! { } pub {const} fn WEXITSTATUS(status: c_int) -> c_int { - status >> 8 + (status >> 8) & 0x00ff } pub {const} fn WCOREDUMP(status: c_int) -> bool { From a0021d2cb1c5cb3ed33969afacb4b9b9760989f9 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Tue, 18 Feb 2025 14:23:52 +0000 Subject: [PATCH 4/5] Add recent socket timestamping flags for Linux and Android Linux defines 3 more flags for socket option SO_TIMESTAMPING: - SOF_TIMESTAMPING_BIND_PHC introduced in Linux 5.14 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d463126e23f112629edb01594141ca437a92a108 - SOF_TIMESTAMPING_OPT_ID_TCP introduced in Linux 6.2 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b534dc46c8ae0165b1b2509be24dbea4fa9c4011 - SOF_TIMESTAMPING_OPT_RX_FILTER introduced in Linux 6.12 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=be8e9eb3750639aa5cffb3f764ca080caed41bd0 These flags are defined in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net_tstamp.h?h=v6.13 Android C library (bionic) picked this flags up: https://android.googlesource.com/platform//bionic/+/9cdc362a2f7463670a766400defcd332a9edfe19/libc/kernel/uapi/linux/net_tstamp.h Update Linux and Android files accordingly. (backport ) (cherry picked from commit d1d92db586e16f8ed1cc5e9ece79783b8b19b4ac) --- libc-test/build.rs | 9 +++++++++ libc-test/semver/android.txt | 3 +++ libc-test/semver/linux.txt | 3 +++ src/unix/linux_like/android/mod.rs | 3 +++ src/unix/linux_like/linux/mod.rs | 3 +++ 5 files changed, 21 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4aa1fa8bd8338..7efacf7a41e63 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2083,6 +2083,9 @@ fn test_android(target: &str) { | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, + // FIXME(android): Requires >= 6.12 kernel headers. + "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + _ => false, } }); @@ -4338,6 +4341,12 @@ fn test_linux(target: &str) { // FIXME: Requires >= 6.11 kernel headers. "MAP_DROPPABLE" => true, + // FIXME(linux): Requires >= 6.2 kernel headers. + "SOF_TIMESTAMPING_OPT_ID_TCP" => true, + + // FIXME(linux): Requires >= 6.12 kernel headers. + "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + _ => false, } }); diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index f8c136dd70e10..a60cd024f2040 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -2385,9 +2385,12 @@ SOCK_RAW SOCK_RDM SOCK_SEQPACKET SOCK_STREAM +SOF_TIMESTAMPING_BIND_PHC SOF_TIMESTAMPING_OPT_CMSG SOF_TIMESTAMPING_OPT_ID +SOF_TIMESTAMPING_OPT_ID_TCP SOF_TIMESTAMPING_OPT_PKTINFO +SOF_TIMESTAMPING_OPT_RX_FILTER SOF_TIMESTAMPING_OPT_STATS SOF_TIMESTAMPING_OPT_TSONLY SOF_TIMESTAMPING_OPT_TX_SWHW diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 3ec327aec6337..c91b5034608d2 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2898,9 +2898,12 @@ SOCK_NONBLOCK SOCK_PACKET SOCK_RAW SOCK_RDM +SOF_TIMESTAMPING_BIND_PHC SOF_TIMESTAMPING_OPT_CMSG SOF_TIMESTAMPING_OPT_ID +SOF_TIMESTAMPING_OPT_ID_TCP SOF_TIMESTAMPING_OPT_PKTINFO +SOF_TIMESTAMPING_OPT_RX_FILTER SOF_TIMESTAMPING_OPT_STATS SOF_TIMESTAMPING_OPT_TSONLY SOF_TIMESTAMPING_OPT_TX_SWHW diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 0e1b05aa5cf72..5debbe8fb967d 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2942,6 +2942,9 @@ pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11; pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12; pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13; pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14; +pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; +pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; +pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; #[deprecated( since = "0.2.55", diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 71311c1ed6681..63049fe1c5547 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4544,6 +4544,9 @@ pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11; pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12; pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13; pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14; +pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; +pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; +pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0; pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1; From 42a30adc36ecceaf231589c4b1a1347c66d14222 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sat, 22 Feb 2025 22:24:32 +0000 Subject: [PATCH 5/5] Switch back to matching `target_os` rather than `target_vendor` `ctest` is very particular about this and the current configuration, though working most of the time, seems to cause occasional CI errors that can't easily be explained or mitigated. Switch back to matching all Apple `target_os` options until `ctest` is fixed. (backport ) (cherry picked from commit a986f81dbc23bf669fdecd81a74b6ae3999cb8c8) --- src/primitives.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/primitives.rs b/src/primitives.rs index ed71e843057b1..668d3340d2abb 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -20,7 +20,14 @@ pub type c_double = f64; cfg_if! { if #[cfg(all( not(windows), - not(target_vendor = "apple"), + // FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it + not(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + )), not(target_os = "vita"), any( target_arch = "aarch64",