Skip to content

Commit d198f5d

Browse files
committed
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.
1 parent d93c557 commit d198f5d

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/unix/bsd/apple/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ s! {
327327

328328
pub struct sigaction {
329329
// FIXME(union): this field is actually a union
330-
pub sa_sigaction: crate::sighandler_t,
330+
pub sa_sigaction: crate::sig_t,
331331
pub sa_mask: sigset_t,
332332
pub sa_flags: c_int,
333333
}

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ s! {
164164
}
165165

166166
pub struct sigaction {
167-
pub sa_sigaction: crate::sighandler_t,
167+
pub sa_sigaction: crate::sig_t,
168168
pub sa_flags: c_int,
169169
pub sa_mask: sigset_t,
170170
}

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ s! {
2727
}
2828

2929
pub struct sigaction {
30-
pub sa_sigaction: crate::sighandler_t,
30+
pub sa_sigaction: crate::sig_t,
3131
pub sa_mask: crate::sigset_t,
3232
pub sa_flags: c_int,
3333
}

src/unix/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ pub type pid_t = i32;
1818
pub type in_addr_t = u32;
1919
pub type in_port_t = u16;
2020
pub type sighandler_t = size_t;
21+
#[cfg(any(
22+
target_os = "macos",
23+
target_os = "ios",
24+
target_os = "tvos",
25+
target_os = "watchos",
26+
target_os = "visionos",
27+
target_os = "freebsd",
28+
target_os = "dragonfly",
29+
target_os = "openbsd",
30+
target_os = "netbsd"
31+
))]
32+
pub type sig_t = sighandler_t;
2133
pub type cc_t = c_uchar;
2234

2335
cfg_if! {

0 commit comments

Comments
 (0)