From 90f6ea468b56dfd17572665a7b5eefa32faa89b2 Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Sun, 8 Mar 2026 21:13:42 -0700 Subject: [PATCH 1/2] Test: Add variable `sig_t` Expected Error: error[E0432]: unresolved import `libc::sig_t` | 3108 | sig_t, | ^^^^^ no `sig_t` in the root --- libc-test/semver/apple.txt | 1 + libc-test/semver/dragonfly.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + 5 files changed, 5 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 7b11ad7c66ebd..97c76d0365dcd 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2195,6 +2195,7 @@ shmctl shmdt shmget shmid_ds +sig_t sigaltstack sigevent siginfo_t diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 6d41c8c6cabd9..1c7d4a1110777 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1606,6 +1606,7 @@ shmat shmctl shmdt shmget +sig_t sigaltstack sigevent siginfo_t diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 110e75e2bca12..d07c6cb7a87c4 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2368,6 +2368,7 @@ shmctl shmdt shmget shmid_ds +sig_t sigaltstack sigevent siginfo_t diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 982f610a4f3aa..c8df66d004950 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1571,6 +1571,7 @@ shmctl shmdt shmget shmid_ds +sig_t sigaltstack sigevent siginfo_t diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 575fcc0736075..9bd0c238979d8 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1332,6 +1332,7 @@ shmctl shmdt shmget shmid_ds +sig_t sigaltstack siginfo_t sigsuspend From d9d5db81817ea8a2e1266f23c2bb156f97ca72ee Mon Sep 17 00:00:00 2001 From: R4 Cheng Date: Sun, 8 Mar 2026 21:18:21 -0700 Subject: [PATCH 2/2] Fix: Replace `sighandler_t` with `sig_t for consistency across platforms - Result: Tests pass - Check Apple type at local ```bash grep -r "sig_t" /usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include 2>/dev/null /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/kern/kcdata.h: uint8_t ceri_page_codesig_tainted; /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/signal.h:typedef void (*sig_t)(int); /* type of signal function */ ``` > Aarch MacOS 26.3.1 - Check Other OS from the Internet Source: - (Freebsd) https://github.com/freebsd/freebsd-src/blob/016570c4463d5908953355ee1cf9a385ad9601b4/sys/sys/signal.h - (Dragonfly) https://github.com/DragonFlyBSD/DragonFlyBSD/blob/51591aff67978c86de99839e31d8c8fcc54bc316/sys/sys/signal.h - https://www.gnu.org/software/gnulib/manual/html_node/signal_002eh.html - The type sighandler_t (a GNU extension) is not defined on most non-glibc platforms: macOS 11.1, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, AIX 5.1, HP-UX 11, Solaris 11.4, Cygwin, mingw, MSVC 14. --- src/unix/bsd/apple/mod.rs | 2 +- src/unix/bsd/freebsdlike/mod.rs | 2 +- src/unix/bsd/netbsdlike/mod.rs | 2 +- src/unix/mod.rs | 12 ++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index fceea8869cbfd..adaac55f75e9c 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -327,7 +327,7 @@ s! { pub struct sigaction { // FIXME(union): this field is actually a union - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: crate::sig_t, pub sa_mask: sigset_t, pub sa_flags: c_int, } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 0c93d2edc2f4b..2127b603986f8 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -164,7 +164,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: crate::sig_t, pub sa_flags: c_int, pub sa_mask: sigset_t, } diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index e4d4e68ad1fb7..71c07b72ad177 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -27,7 +27,7 @@ s! { } pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, + pub sa_sigaction: crate::sig_t, pub sa_mask: crate::sigset_t, pub sa_flags: c_int, } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 79c3ef8be2220..1520b210304ea 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -18,6 +18,18 @@ pub type pid_t = i32; pub type in_addr_t = u32; pub type in_port_t = u16; pub type sighandler_t = size_t; +#[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd", + target_os = "netbsd" +))] +pub type sig_t = sighandler_t; pub type cc_t = c_uchar; cfg_if! {