From 410209286e7b3f6099b193774134c1c2673b2575 Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Wed, 2 Sep 2026 22:37:26 -0700 Subject: [PATCH 1/6] Unix: scope sighandler_t to GNU/Linux platforms Background: Refer to `libc-test/build/main.rs`, sighandler_t` is a GNU extension provided by glibc on Linux and Hurd. Non-GNU Unix platforms (such as BSDs, Solaris, AIX, and Cygwin) do not define `sighandler_t` in their native C headers (BSDs define `sig_t` instead). Fixes: Scope `sighandler_t` to `linux_like` and `hurd`, removing it from non-GNU platforms. --- libc-test/semver/linux.txt | 1 + libc-test/semver/unix.txt | 1 - src/unix/aix/mod.rs | 2 +- src/unix/cygwin/mod.rs | 2 +- src/unix/haiku/mod.rs | 2 +- src/unix/hurd/mod.rs | 3 ++- src/unix/linux_like/mod.rs | 1 + src/unix/mod.rs | 50 ++++++++++++++++++++++++++++++-------- src/unix/nto/mod.rs | 2 +- src/unix/redox/mod.rs | 2 +- src/unix/solarish/mod.rs | 2 +- 11 files changed, 50 insertions(+), 18 deletions(-) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index be054f1da530..6fee55657b9e 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -4519,6 +4519,7 @@ shmget shmid_ds sigaltstack sigevent +sighandler_t siginfo_t signalfd signalfd_siginfo diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 07b6a9cd61c4..88118211a432 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -783,7 +783,6 @@ sigaddset sigdelset sigemptyset sigfillset -sighandler_t sigismember signal sigpending diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b593c11cce0f..52ea7fdb0d6e 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -541,7 +541,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, // FIXME(union): this field is actually a union + pub sa_sigaction: size_t, // FIXME(union): this field is actually a union pub sa_mask: sigset_t, pub sa_flags: c_int, } diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 5645bdd2b2dc..dc83b29e1b8f 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -93,7 +93,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: sighandler_t, + pub sa_sigaction: size_t, pub sa_mask: sigset_t, pub sa_flags: c_int, } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index a98e4b17bcce..acf280acb334 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -362,7 +362,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, //actually a union with sa_handler + pub sa_sigaction: size_t, //actually a union with sa_handler pub sa_mask: crate::sigset_t, pub sa_flags: c_int, sa_userdata: *mut c_void, diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 3335786cd2be..367f18c666ca 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -80,6 +80,7 @@ pub type wchar_t = c_int; pub type wint_t = c_uint; pub type gid_t = __gid_t; pub type uid_t = __uid_t; +pub type sighandler_t = size_t; cfg_if! { if #[cfg(any(target_pointer_width = "64", gnu_file_offset_bits64))] { @@ -451,7 +452,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: sighandler_t, pub sa_mask: __sigset_t, pub sa_flags: c_int, } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 361ab290e2c4..04c941fe5d9f 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -8,6 +8,7 @@ pub type timer_t = *mut c_void; pub type useconds_t = u32; pub type key_t = c_int; pub type id_t = c_uint; +pub type sighandler_t = size_t; extern_ty! { pub type timezone; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 92467886a378..eaa3cf671df9 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -18,7 +18,6 @@ pub type ssize_t = isize; pub type pid_t = i32; pub type in_addr_t = u32; pub type in_port_t = u16; -pub type sighandler_t = size_t; pub type cc_t = c_uchar; cfg_if! { @@ -250,9 +249,23 @@ pub const INT_MIN: c_int = c_int::MIN; #[deprecated(since = "0.2.190", note = "Use `c_int::MAX` instead.")] pub const INT_MAX: c_int = c_int::MAX; -pub const SIG_DFL: sighandler_t = 0 as sighandler_t; -pub const SIG_IGN: sighandler_t = 1 as sighandler_t; -pub const SIG_ERR: sighandler_t = !0 as sighandler_t; +cfg_if! { + if #[cfg(any( + target_os = "linux", + target_os = "l4re", + target_os = "android", + target_os = "emscripten", + target_os = "hurd" + ))] { + pub const SIG_DFL: sighandler_t = 0 as sighandler_t; + pub const SIG_IGN: sighandler_t = 1 as sighandler_t; + pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + } else { + pub const SIG_DFL: size_t = 0; + pub const SIG_IGN: size_t = 1; + pub const SIG_ERR: size_t = !0; + } +} cfg_if! { if #[cfg(all( @@ -1341,23 +1354,40 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")] pub fn ftruncate(fd: c_int, length: off_t) -> c_int; - #[cfg(not(any( + #[cfg(any( + target_os = "linux", + target_os = "l4re", + target_os = "android", + target_os = "emscripten", + target_os = "hurd" + ))] + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + + #[cfg(any( target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd" - )))] - pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + ))] + pub fn signal(signum: c_int, handler: sig_t) -> sig_t; - #[cfg(any( + #[cfg(not(any( + target_os = "linux", + target_os = "l4re", + target_os = "android", + target_os = "emscripten", + target_os = "hurd", target_vendor = "apple", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd" - ))] - pub fn signal(signum: c_int, handler: sig_t) -> sig_t; + )))] + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")] diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 3fe3f7579b89..764cbc809b94 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -262,7 +262,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: size_t, pub sa_flags: c_int, pub sa_mask: crate::sigset_t, } diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index e5001f9c7e40..4e6b37b66682 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -152,7 +152,7 @@ s! { // FIXME(1.0): This should not implement `PartialEq` #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: size_t, pub sa_flags: c_int, pub sa_restorer: Option, pub sa_mask: crate::sigset_t, diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index b54de0f0d3d8..2b147ebb9bdd 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -265,7 +265,7 @@ s! { pub struct sigaction { pub sa_flags: c_int, - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: size_t, pub sa_mask: sigset_t, } From 6ae74dbfffd5266d496bb3314b336c3b8bf1a05c Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Wed, 2 Sep 2026 23:08:54 -0700 Subject: [PATCH 2/6] test(apple): skip SIG_DFL/IGN/ERR following other BSDs Since `SIG_DFL`, `SIG_IGN`, and `SIG_ERR` are changed to `size_t` for apple platform, `ctest` fails on Apple because its C headers define them as function pointers. Fixes: - Skip `SIG_DFL`, `SIG_IGN`, and `SIG_ERR` in `test_apple`. (Follow what other BSDs have already done) - Remove the obsolete `rename_type` for `sighandler_t`. --- libc-test/build/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 8338a0664e5b..7153b182cca9 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -300,6 +300,9 @@ fn test_apple(t: &Target) { // FIXME(macos): bumped up on macOS/iOS/... 27, from 16 to 32 "AIO_LISTIO_MAX" => apple.unwrap() < (27, 0), + // In C, these are function pointers, but in Rust they are `size_t`. + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, + _ => false, } }); @@ -352,9 +355,6 @@ fn test_apple(t: &Target) { .then_some(ty.to_string()) }); - // OSX calls this something else - cfg.rename_type(|ty| (ty == "sighandler_t").then_some("sig_t".to_string())); - cfg.rename_struct_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); cfg.rename_union_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); From b7b8c32877b3f191e599487a4f61d1f4e97f5385 Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Thu, 3 Sep 2026 22:25:53 -0700 Subject: [PATCH 3/6] test(freebsd): skip SIG_DFL/IGN/ERR in libc-test Since `SIG_DFL`, `SIG_IGN`, and `SIG_ERR` were changed to `size_t` for FreeBSD, `ctest` failed because C headers define them as function pointer macros. Fixes: - Skip `SIG_DFL`, `SIG_IGN`, and `SIG_ERR` in `test_freebsd`. - Remove obsolete `rename_type` for `sighandler_t`. --- libc-test/build/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index 7153b182cca9..c7101d752edc 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -2638,12 +2638,6 @@ fn test_freebsd(t: &Target) { "wchar.h", ); - cfg.rename_type(|ty| match ty { - // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 - "sighandler_t" => Some("sig_t".to_string()), - _ => None, - }); - cfg.rename_struct_ty(|ty| { match ty { // Just pass all these through, no need for a "struct" prefix @@ -2689,6 +2683,9 @@ fn test_freebsd(t: &Target) { cfg.skip_const(move |constant| { match constant.ident() { + // In C, these are function pointers, but in Rust they are `size_t`. + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, + // These constants were introduced in FreeBSD 13: "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" From 16d8ba65766ed67c342161eb581b8b69584efd5b Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Fri, 4 Sep 2026 14:41:47 -0700 Subject: [PATCH 4/6] Unix: scope signal() definition to related child platforms Move `signal()` from `src/unix/mod.rs` to child platforms repectively to reduce the codebase complexity --- src/unix/aix/mod.rs | 5 +++++ src/unix/bsd/mod.rs | 1 + src/unix/cygwin/mod.rs | 5 +++++ src/unix/haiku/mod.rs | 5 +++++ src/unix/hurd/mod.rs | 2 ++ src/unix/linux_like/mod.rs | 2 ++ src/unix/mod.rs | 35 ----------------------------------- src/unix/newlib/mod.rs | 4 ++++ src/unix/nto/mod.rs | 5 +++++ src/unix/nuttx/mod.rs | 5 +++++ src/unix/redox/mod.rs | 5 +++++ src/unix/solarish/mod.rs | 5 +++++ 12 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 52ea7fdb0d6e..899e6a5059fd 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2863,6 +2863,11 @@ extern "C" { } extern "C" { + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; + pub fn acct(filename: *mut c_char) -> c_int; #[link_name = "_posix_aio_cancel"] pub fn aio_cancel(fildes: c_int, aiocbp: *mut crate::aiocb) -> c_int; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index e925289796e5..47cfe54e2249 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -858,6 +858,7 @@ extern "C" { pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; pub fn issetugid() -> c_int; + pub fn signal(signum: c_int, handler: sig_t) -> sig_t; } cfg_if! { diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index dc83b29e1b8f..196e55e28fbf 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1836,6 +1836,11 @@ const fn CMSG_ALIGN(len: usize) -> usize { } extern "C" { + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index acf280acb334..c445c41eea2a 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1485,6 +1485,11 @@ f! { } extern "C" { + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; pub fn getpriority(which: c_int, who: id_t) -> c_int; diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 367f18c666ca..55df9a4244c8 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3734,6 +3734,8 @@ extern "C" { pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + pub fn __libc_current_sigrtmin() -> c_int; pub fn __libc_current_sigrtmax() -> c_int; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 04c941fe5d9f..0381a4f98dbb 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1959,6 +1959,8 @@ f! { } extern "C" { + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + #[doc(hidden)] pub fn __libc_current_sigrtmax() -> c_int; #[doc(hidden)] diff --git a/src/unix/mod.rs b/src/unix/mod.rs index eaa3cf671df9..05e8862eee55 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1354,41 +1354,6 @@ extern "C" { #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")] pub fn ftruncate(fd: c_int, length: off_t) -> c_int; - #[cfg(any( - target_os = "linux", - target_os = "l4re", - target_os = "android", - target_os = "emscripten", - target_os = "hurd" - ))] - pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; - - #[cfg(any( - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - ))] - pub fn signal(signum: c_int, handler: sig_t) -> sig_t; - - #[cfg(not(any( - target_os = "linux", - target_os = "l4re", - target_os = "android", - target_os = "emscripten", - target_os = "hurd", - target_vendor = "apple", - target_os = "freebsd", - target_os = "dragonfly", - target_os = "netbsd", - target_os = "openbsd" - )))] - pub fn signal( - signum: c_int, - handler: Option, - ) -> Option; - #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")] #[cfg_attr(musl_redir_time64, link_name = "__getrusage_time64")] diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index f5c7396d67d9..fb7ffea13b97 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -954,6 +954,10 @@ extern "C" { result: *mut *mut passwd, ) -> c_int; pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; pub fn pthread_atfork( prepare: Option, parent: Option, diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 764cbc809b94..a865abd99877 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2470,6 +2470,11 @@ f! { // `inotify_*` functions are provided by `fsnotify` on QNX 8.0 #[cfg_attr(target_os = "qnx", link(name = "fsnotify"))] extern "C" { + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; + pub fn sem_destroy(sem: *mut sem_t) -> c_int; pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; pub fn fdatasync(fd: c_int) -> c_int; diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 2380bba1ba40..8fed6172908a 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -681,6 +681,11 @@ extern "C" { pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; pub fn arc4random() -> u32; pub fn arc4random_buf(bytes: *mut c_void, nbytes: usize); + // signal.h + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; // string.h pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; // sys/socket.h diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 4e6b37b66682..2c1805953346 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1209,6 +1209,11 @@ f! { } extern "C" { + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; + // errno.h pub fn __errno_location() -> *mut c_int; pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 2b147ebb9bdd..69c4e7c63036 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2322,6 +2322,11 @@ f! { } extern "C" { + pub fn signal( + signum: c_int, + handler: Option, + ) -> Option; + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; From 5f874a5010821f38c5c070ac1335db1b6f28d2ca Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Fri, 4 Sep 2026 15:34:32 -0700 Subject: [PATCH 5/6] Remove redundant `crate::` for `c_int` Since `c_int` is already re-exported in `crate::prelude::*`, explicitly qualifying it with `crate::` is redundant. --- src/unix/bsd/mod.rs | 2 +- src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 +- src/unix/linux_like/linux/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 47cfe54e2249..a6654251c2db 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -11,7 +11,7 @@ pub type nfds_t = c_uint; pub type regoff_t = c_int; #[cfg(not(target_os = "dragonfly"))] pub type regoff_t = off_t; -pub type sig_t = Option; +pub type sig_t = Option; s! { pub struct sockaddr { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 89348d7ec156..11871a868eb9 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -863,7 +863,7 @@ impl siginfo_t { _uid: crate::uid_t, _utime: crate::clock_t, _stime: crate::clock_t, - _status: crate::c_int, + _status: c_int, } (*(self as *const siginfo_t).cast::())._status } diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 37956affc2d7..05216033a382 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3302,7 +3302,7 @@ pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000u32 as crate::off_t; pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000; pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000; -pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48; +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48; pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; From 039ddbe4d3e197c022fc6d6cd59151d49ab55ef2 Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Fri, 4 Sep 2026 22:44:14 -0700 Subject: [PATCH 6/6] test(unix): clean up obsolete sighandler_t rules Since `sighandler_t` was scoped to GNU/Linux platforms, several test configs and semver files became obsolete. - Remove `skip_alias` and `rename_type` for `sighandler_t` across non-GNU Unix targets in `libc-test/build/main.rs`. - Remove obsolete `signal` skips in Solarish, Neutrino, and AIX, where `signal` was using `sighandler_t`. => Now using function pointers. - Update `SIG_DFL`/`SIG_ERR`/`SIG_IGN` comments to clarify they are C function pointers mapped to Rust `size_t`. - Remove `sighandler_t` from `semver/aix.txt`, `semver/nto.txt`, and `semver/qnx.txt`. --- libc-test/build/main.rs | 83 ++++++++-------------------------------- libc-test/semver/aix.txt | 1 - libc-test/semver/nto.txt | 1 - libc-test/semver/qnx.txt | 1 - 4 files changed, 15 insertions(+), 71 deletions(-) diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index c7101d752edc..b59848d1e674 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -475,12 +475,6 @@ fn test_openbsd(t: &Target) { "sys/auxv.h", ); - cfg.rename_type(|ty| match ty { - // FIXME(openbsd): https://github.com/rust-lang/libc/issues/1273 - "sighandler_t" => Some("sig_t".to_string()), - _ => None, - }); - cfg.rename_struct_ty(move |ty| { match ty { // Just pass all these through, no need for a "struct" prefix @@ -648,9 +642,6 @@ fn test_cygwin(t: &Target) { cfg.skip_signededness(move |c| match c { n if n.starts_with("pthread") => true, - // For consistency with other platforms. Actually a function ptr. - "sighandler_t" => true, - _ => false, }); @@ -1015,11 +1006,6 @@ fn test_solarish(t: &Target) { headers!(cfg, "sys/lgrp_user_impl.h",); } - cfg.skip_alias(move |ty| match ty.ident() { - "sighandler_t" => true, - _ => false, - }); - cfg.rename_union_ty(|ty| match ty { t if t.ends_with("_t") => Some(t.to_string()), _ => None, @@ -1048,7 +1034,7 @@ fn test_solarish(t: &Target) { "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" | "USRQUOTA" | "GRPQUOTA" | "PRIO_MIN" | "PRIO_MAX" => true, - // skip sighandler_t assignments + // In C, these are function pointers, but in Rust they are `size_t`. "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, "DT_UNKNOWN" => true, @@ -1148,9 +1134,6 @@ fn test_solarish(t: &Target) { // FIXME(solarish): unskip these for next major release "setpriority" | "personality" => true, - // signal is defined in terms of sighandler_t, so ignore - "signal" => true, - // Currently missing "cfmakeraw" | "cfsetspeed" => true, @@ -1305,15 +1288,6 @@ fn test_netbsd(t: &Target) { "utmpx.h", ); - cfg.rename_type(move |ty| { - match ty { - // OSX calls this something else - "sighandler_t" => Some("sig_t".to_string()), - - _ => None, - } - }); - cfg.rename_struct_ty(|ty| match ty { // Just pass all these through, no need for a "struct" prefix "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr" @@ -1338,8 +1312,6 @@ fn test_netbsd(t: &Target) { cfg.skip_alias(move |ty| { match ty.ident() { - // FIXME(netbsd): sighandler_t is crazy across platforms - "sighandler_t" => true, // Incomplete type in C "cpuset_t" => true, "eventfd_t" if netbsd9 => true, @@ -1378,7 +1350,8 @@ fn test_netbsd(t: &Target) { cfg.skip_const(move |constant| { match constant.ident() { - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + // In C, these are function pointers, but in Rust they are `size_t`. + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // deprecated, obsolete upstream "PT_LWPINFO" | "PL_EVENT_NONE" | "PL_EVENT_SIGNAL" | "PL_EVENT_SUSPENDED" => true, @@ -1620,16 +1593,12 @@ fn test_dragonflybsd(t: &Target) { } }); - cfg.rename_type(|ty| { - match ty { - // FIXME(dragonflybsd): OSX calls this something else - "sighandler_t" => Some("sig_t".to_string()), - "lwpstat" => Some("enum lwpstat".to_string()), - "procstat" => Some("enum procstat".to_string()), - "vm_map_t" => Some("struct vm_map *".to_string()), - "vm_map_entry_t" => Some("struct vm_map_entry *".to_string()), - _ => None, - } + cfg.rename_type(|ty| match ty { + "lwpstat" => Some("enum lwpstat".to_string()), + "procstat" => Some("enum procstat".to_string()), + "vm_map_t" => Some("struct vm_map *".to_string()), + "vm_map_entry_t" => Some("struct vm_map_entry *".to_string()), + _ => None, }); cfg.rename_struct_field(move |struct_, field| { @@ -1646,14 +1615,6 @@ fn test_dragonflybsd(t: &Target) { } }); - cfg.skip_alias(move |ty| { - match ty.ident() { - // sighandler_t is crazy across platforms - "sighandler_t" => true, - _ => false, - } - }); - cfg.skip_struct(move |struct_| { match struct_.ident() { // FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since @@ -1688,7 +1649,8 @@ fn test_dragonflybsd(t: &Target) { cfg.skip_const(move |constant| { match constant.ident() { - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + // In C, these are function pointers, but in Rust they are `size_t`. + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // Kernel-only symbols in DragonFly headers. "DTYPE_VNODE" | "DTYPE_SOCKET" | "DTYPE_PIPE" | "DTYPE_FIFO" | "DTYPE_KQUEUE" @@ -1768,8 +1730,6 @@ fn test_dragonflybsd(t: &Target) { cfg.skip_alias(move |ty| { match ty.ident() { - // sighandler_t is crazy across platforms - "sighandler_t" => true, // Same as FreeBSD: `kvm_t` is an opaque handle used through // pointers, and libc does not bind the private `struct __kvm`. "kvm_t" => true, @@ -3597,10 +3557,6 @@ fn test_neutrino(t: &Target) { cfg.skip_alias(move |ty| { match ty.ident() { - // FIXME(sighandler): `sighandler_t` type is incorrect, see: - // https://github.com/rust-lang/libc/issues/1359 - "sighandler_t" => true, - // Does not exist in Neutrino "locale_t" => true, @@ -3646,9 +3602,6 @@ fn test_neutrino(t: &Target) { cfg.skip_fn(move |func| { // skip those that are manually verified match func.ident() { - // wrong signature - "signal" => true, - // wrong signature of callback ptr "__cxa_atexit" => true, @@ -5607,7 +5560,6 @@ fn test_haiku(t: &Target) { // FIXME(haiku): locale_t does not exist on Haiku "locale_t" => true, // These cause errors, to be reviewed in the future - "sighandler_t" => true, "pthread_t" => true, "pthread_condattr_t" => true, "pthread_mutexattr_t" => true, @@ -5858,9 +5810,6 @@ fn test_aix(t: &Target) { ); cfg.skip_alias(move |ty| match ty.ident() { - // AIX does not define type 'sighandler_t'. - "sighandler_t" => true, - // The alignment of 'double' does not agree between C and Rust for AIX. // We are working on a resolution. "c_double" => true, @@ -5875,7 +5824,7 @@ fn test_aix(t: &Target) { }); cfg.skip_const(move |constant| match constant.ident() { - // Skip 'sighandler_t' assignments. + // In C, these are function pointers, but in Rust they are `size_t`. "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // _ALL_SOURCE defines ENOTEMPTY as an alias of EEXIST, but POSIX @@ -5972,9 +5921,6 @@ fn test_aix(t: &Target) { cfg.skip_fn(move |func| { match func.ident() { - // 'sighandler_t' is not defined on AIX. - "signal" => true, - // The function is only available under macro _USE_IRS in 'netdb.h'. "hstrerror" => true, @@ -6090,8 +6036,9 @@ fn test_qurt(t: &Target) { | "suseconds_t" | "useconds_t" | "timer_t" | "dev_t" | "ino_t" | "mode_t" | "nlink_t" | "off_t" | "blkcnt_t" | "blksize_t" | "uid_t" | "gid_t" | "socklen_t" | "sa_family_t" | "in_addr_t" | "in_port_t" | "fpos_t" | "clock_t" | "nfds_t" - | "va_list" | "c_schar" | "wchar_t" | "errno_t" | "rlim_t" | "speed_t" | "tcflag_t" - | "sighandler_t" => true, + | "va_list" | "c_schar" | "wchar_t" | "errno_t" | "rlim_t" | "speed_t" | "tcflag_t" => { + true + } // fd_set is defined in mqueue.h as a struct, but libc has it as c_ulong "fd_set" => true, // sem_t is a struct in QuRT but an alias in libc diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt index aa337c44d3a1..cbb02db41802 100644 --- a/libc-test/semver/aix.txt +++ b/libc-test/semver/aix.txt @@ -2467,7 +2467,6 @@ sigdelset sigemptyset sigevent sigfillset -sighandler_t siginfo_t sigismember signal diff --git a/libc-test/semver/nto.txt b/libc-test/semver/nto.txt index 4fe337edf2b1..d3ba1e156baa 100644 --- a/libc-test/semver/nto.txt +++ b/libc-test/semver/nto.txt @@ -775,7 +775,6 @@ sigaddset sigdelset sigemptyset sigfillset -sighandler_t sigismember signal sigpending diff --git a/libc-test/semver/qnx.txt b/libc-test/semver/qnx.txt index 955f6fba9bff..ae0ee961a573 100644 --- a/libc-test/semver/qnx.txt +++ b/libc-test/semver/qnx.txt @@ -777,7 +777,6 @@ sigaddset sigdelset sigemptyset sigfillset -sighandler_t sigismember signal sigpending