From edd3346d82e65f294ce9ef3ec444f8eec091da87 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 13:39:58 +0200 Subject: [PATCH 1/7] linux: remove a skip over a field of `epoll_event` Remove a check in the Linux routine of build the build script that skipped a field whose type was a `union` upstream but only a specific field of the `union` in Rust. This is a remnant of versions prior to Rust 1.19, where `union`s got introduced. The definition under `unix/linux_like/mod.rs` uses a `union` for that field. The check is redundant now. --- libc-test/build.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index b13a8369849c..4d4208abad2c 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4322,10 +4322,6 @@ fn test_linux(target: &str) { Some(f.replace("e_nsec", ".tv_nsec")) } - // FIXME(linux): epoll_event.data is actually a union in C, but in Rust - // it is only a u64 because we only expose one field - // http://man7.org/linux/man-pages/man2/epoll_wait.2.html - ("epoll_event", "u64") => Some("data.u64".to_string()), // The following structs have a field called `type` in C, // but `type` is a Rust keyword, so these fields are translated // to `type_` in Rust. From d12e97924901cf870aebc14d081e69eea86238ad Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 13:42:22 +0200 Subject: [PATCH 2/7] illumos: provide full definition for `epoll_event` Replace field of `epoll_event` that was once only a single field of the upstream `union` with a proper `union`. This was done back before Rust had received support for `union`s, so it's redundant to keep this binding now. The build script also had a skip set in place for this one field, and that now has also been removed. --- libc-test/build.rs | 2 -- src/unix/solarish/illumos.rs | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4d4208abad2c..3d90f1fef350 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1120,8 +1120,6 @@ fn test_solarish(target: &str) { // expose stat.Xtim.tv_nsec fields Some(field.ident().trim_end_matches("e_nsec").to_string() + ".tv_nsec") } - // epoll_event.data is a union in C; our `u64` field lives at `data.u64` - "epoll_event" if field.ident() == "u64" => Some("data.u64".to_string()), _ => None, } }); diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 7b8ce2c29315..4898b4b5a451 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -48,12 +48,6 @@ s! { pub fi_name: [c_char; crate::FILNAME_MAX as usize], } - #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] - pub struct epoll_event { - pub events: u32, - pub u64: u64, - } - pub struct utmpx { pub ut_user: [c_char; _UTX_USERSIZE], pub ut_id: [c_char; _UTX_IDSIZE], @@ -69,6 +63,21 @@ s! { } } +s_no_extra_traits! { + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] + pub struct epoll_event { + pub events: u32, + pub data: epoll_data, + } + + pub union epoll_data { + pub ptr: *mut c_void, + pub fd: c_int, + pub u32: u32, + pub u64: u64, + } +} + pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 5; From 7e8119e9cbc7a7fcd823d18a75be0d74b94754db Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 13:53:36 +0200 Subject: [PATCH 3/7] linux: skip checking field of `sigevent` Remove check in Linux test routine for a field of `sigevent` that was once (pre-Rust 1.19) implemented as a `struct` instead of a `union`. This is no more the case so the check in the build script is redundant. --- libc-test/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 3d90f1fef350..94dc098db6ae 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5170,8 +5170,6 @@ fn test_linux(target: &str) { ("sigaction", "sa_sigaction") => true, // __timeval type is a patch which doesn't exist in glibc ("utmpx", "ut_tv") => true, - // sigval is actually a union, but we pretend it's a struct - ("sigevent", "sigev_value") => true, // this one is an anonymous union ("ff_effect", "u") => true, // `__exit_status` type is a patch which is absent in musl From f8d968788a7bc858a54ae4a06199de3343d488c8 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 13:58:41 +0200 Subject: [PATCH 4/7] haiku: remove redundant `union` skips Remove check for `cpuid_info` as a `union` as that dates back to the times where Rust didn't itself have `union`s so this type had to be implemented as a `struct`. Skipping it in libc-test's build script is redundant. The same applies to `cpu_topology_node_info`. --- libc-test/build.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 94dc098db6ae..af52afe66462 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5698,9 +5698,6 @@ fn test_haiku(target: &str) { "Elf64_Phdr" => true, - // is an union - "cpuid_info" => true, - _ => false, } }); @@ -5787,7 +5784,6 @@ fn test_haiku(target: &str) { ("sem_t", "named_sem_id") => true, ("sigaction", "sa_sigaction") => true, ("fpu_state", "_fpreg") => true, - ("cpu_topology_node_info", "data") => true, // these fields have a simplified data definition in libc ("fpu_state", "_xmm") => true, ("savefpu", "_fp_ymm") => true, From 508ae5aef0b6f73789fd16df897dd83882ad4ff0 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 18:30:14 +0200 Subject: [PATCH 5/7] haiku: fill in full definition for `sem_t` Replace dummy field for `union` with an actual definition fitting that of the upstream type. The current (pre-patch) field corresponded with the times back when Rust didn't have `union`s. Now it's not necessary anymore to expose only a single field of the `union`. The corresponding skip in libc-test's build script has also been removed. --- libc-test/build.rs | 1 - src/unix/haiku/mod.rs | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index af52afe66462..4343f38d3665 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -5781,7 +5781,6 @@ fn test_haiku(target: &str) { ("stat", "st_crtime_nsec") => true, // these are actually unions, but we cannot represent it well - ("sem_t", "named_sem_id") => true, ("sigaction", "sa_sigaction") => true, ("fpu_state", "_fpreg") => true, // these fields have a simplified data definition in libc diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index da8f5968cc8d..a98e4b17bcce 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -368,12 +368,6 @@ s! { sa_userdata: *mut c_void, } - pub struct sem_t { - pub type_: i32, - pub named_sem_id: i32, // actually a union with unnamed_sem (i32) - padding: Padding<[i32; 2]>, - } - pub struct ucred { pub pid: crate::pid_t, pub uid: crate::uid_t, @@ -499,6 +493,19 @@ s! { } } +s_no_extra_traits! { + pub struct sem_t { + pub type_: i32, + pub named_sem_id: __c_anonymous_sem_t_u, + padding: Padding<[i32; 2]>, + } + + pub union __c_anonymous_sem_t_u { + pub named_sem_id: i32, + pub unnamed_sem: i32, + } +} + pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; pub const RAND_MAX: c_int = 2147483647; From a53671a2d7f7284ce0cfc476c5b78db206f3be16 Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 18:52:56 +0200 Subject: [PATCH 6/7] hexagon: remove redundant `union` skip Remove a skip over `sigaction` in Hexagon QuRT as it seems the separate fields in Rust mentioned in libc-test's build script's skip aligns well with the (also) split fields upstream. See header file `posix/signal.h` under `rtos/qurt/computev81` in the Hexagon SDK. --- libc-test/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4343f38d3665..f34e3ee93fdc 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -6178,8 +6178,6 @@ fn test_qurt(target: &str) { // These are compatibility stubs in libc, not from QuRT headers "stat" | "tm" | "timespec" | "timeval" | "itimerspec" | "dirent" | "DIR" | "termios" | "rlimit" | "rusage" | "flock" | "div_t" | "ldiv_t" | "lldiv_t" => true, - // sigaction: sa_handler/sa_sigaction are a union in C but separate fields in Rust - "sigaction" => true, // sem_t is typedef of anonymous struct in C (no struct tag) "sem_t" => true, _ => false, From de46d22333a07f54756d25146960ba9daf7de6fc Mon Sep 17 00:00:00 2001 From: Adam Martinez <149513579+dybucc@users.noreply.github.com> Date: Sat, 1 Aug 2026 18:55:32 +0200 Subject: [PATCH 7/7] hexagon: remove possibly redundant skip on `sem_t` Remove skip over `sem_t` in Hexagon QuRT as it alleged to this being a `typedef` of an anonymous `struct`, but that also happens in other targets we test against without there being skips for their records. See header file `posix/semaphore.h` under `rtos/qurt/computev81` in the Hexagon SDK for details. --- libc-test/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f34e3ee93fdc..41d0550c4d0e 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -6178,8 +6178,6 @@ fn test_qurt(target: &str) { // These are compatibility stubs in libc, not from QuRT headers "stat" | "tm" | "timespec" | "timeval" | "itimerspec" | "dirent" | "DIR" | "termios" | "rlimit" | "rusage" | "flock" | "div_t" | "ldiv_t" | "lldiv_t" => true, - // sem_t is typedef of anonymous struct in C (no struct tag) - "sem_t" => true, _ => false, } });