From 585e3df981e2c3bb33df903ef1339ab673b65534 Mon Sep 17 00:00:00 2001 From: Mohan Date: Wed, 7 Jan 2026 20:10:52 +0530 Subject: [PATCH 1/5] pushed the proper type of sighandler_t using anonymous union on unix. CoAuthored by : Bradley Landherr --- src/unix/mod.rs | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 79c3ef8be2220..efce828d311a0 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -17,7 +17,7 @@ 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 sighandler_t = __c_anonymous_sigaction_handler; pub type cc_t = c_uchar; cfg_if! { @@ -44,6 +44,18 @@ extern_ty! { #[cfg(not(target_os = "nuttx"))] pub type locale_t = *mut c_void; +s_no_extra_traits!{ + pub union __c_anonymous_sigaction_handler{ + pub sa_handler: Option ()>, + pub sa_sigaction: Option ()>, + pub default: size_t, + } +} + s! { pub struct group { pub gr_name: *mut c_char, @@ -244,12 +256,36 @@ cfg_if! { } } +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_sigaction_handler { + fn eq(&self, other: &__c_anonymous_sigaction_handler) -> bool { + unsafe{ self.default == other.default }; + } + } + impl Eq for __c_anonymous_sigaction_handler{} + impl ::fmt::Debug for __c_anonymous_sigaction_handler { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result + { + f.debug_struct("sigaction_t") + .field("value", unsafe{ &self.default }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_sigaction_handler { + fn hash(&self, _state: &mut H) { + unsafe{ self.default.hash(state) }; + } + } + } +} + pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; -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; +pub const SIG_DFL: sighandler_t = sighandler_t { default:0 }; +pub const SIG_IGN: sighandler_t = sighandler_t { default:1 }; +pub const SIG_ERR: sighandler_t = sighandler_t { default:!0 }; cfg_if! { if #[cfg(all(not(target_os = "nto"), not(target_os = "aix")))] { From 611b672c64f8f57d8987286efd32a66999fbf61e Mon Sep 17 00:00:00 2001 From: Mohan Date: Wed, 7 Jan 2026 23:35:45 +0530 Subject: [PATCH 2/5] fixed the argument state name. CoAuthored by : Bradley Landherr --- src/unix/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index efce828d311a0..8ed2fe639e931 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -44,7 +44,7 @@ extern_ty! { #[cfg(not(target_os = "nuttx"))] pub type locale_t = *mut c_void; -s_no_extra_traits!{ +s_no_extra_traits! { pub union __c_anonymous_sigaction_handler{ pub sa_handler: Option ()>, pub sa_sigaction: Option ::fmt::Result + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sigaction_t") .field("value", unsafe{ &self.default }) @@ -273,19 +273,19 @@ cfg_if! { } } impl ::hash::Hash for __c_anonymous_sigaction_handler { - fn hash(&self, _state: &mut H) { + fn hash(&self, state: &mut H) { unsafe{ self.default.hash(state) }; } - } + } } } pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; -pub const SIG_DFL: sighandler_t = sighandler_t { default:0 }; -pub const SIG_IGN: sighandler_t = sighandler_t { default:1 }; -pub const SIG_ERR: sighandler_t = sighandler_t { default:!0 }; +pub const SIG_DFL: sighandler_t = sighandler_t { default: 0 }; +pub const SIG_IGN: sighandler_t = sighandler_t { default: 1 }; +pub const SIG_ERR: sighandler_t = sighandler_t { default: !0 }; cfg_if! { if #[cfg(all(not(target_os = "nto"), not(target_os = "aix")))] { From f63e902f51b603edf003b9a1dba171c73b4403fd Mon Sep 17 00:00:00 2001 From: Mohan Date: Wed, 7 Jan 2026 23:42:40 +0530 Subject: [PATCH 3/5] fixed the missing crate issue. CoAuthored by : Bradley Landherr --- src/unix/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 8ed2fe639e931..45bf218a87a24 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -264,16 +264,16 @@ cfg_if! { } } impl Eq for __c_anonymous_sigaction_handler{} - impl ::fmt::Debug for __c_anonymous_sigaction_handler { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result + impl fmt::Debug for __c_anonymous_sigaction_handler { + fn fmt(&self, f: &mut fmt::Formatter) -> ::fmt::Result { f.debug_struct("sigaction_t") .field("value", unsafe{ &self.default }) .finish() } } - impl ::hash::Hash for __c_anonymous_sigaction_handler { - fn hash(&self, state: &mut H) { + impl hash::Hash for __c_anonymous_sigaction_handler { + fn hash(&self, state: &mut H) { unsafe{ self.default.hash(state) }; } } From 92b120e07821d60ba9fcf9c4c26f66317b1551d7 Mon Sep 17 00:00:00 2001 From: Mohan Date: Wed, 7 Jan 2026 23:49:04 +0530 Subject: [PATCH 4/5] fixed the :: issue CoAuthored by : Bradley Landherr --- src/unix/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 45bf218a87a24..869dcb253a04b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -260,12 +260,12 @@ cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for __c_anonymous_sigaction_handler { fn eq(&self, other: &__c_anonymous_sigaction_handler) -> bool { - unsafe{ self.default == other.default }; + unsafe{ self.default == other.default } } } impl Eq for __c_anonymous_sigaction_handler{} impl fmt::Debug for __c_anonymous_sigaction_handler { - fn fmt(&self, f: &mut fmt::Formatter) -> ::fmt::Result + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("sigaction_t") .field("value", unsafe{ &self.default }) From cf39bce54b330590291bf882ed42b7d870fb4001 Mon Sep 17 00:00:00 2001 From: Mohan Date: Thu, 8 Jan 2026 00:23:32 +0530 Subject: [PATCH 5/5] Removed the Debug implementation from the __c_anonymous_sigaction_handler as it is already implemented. --- src/unix/mod.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 869dcb253a04b..562b70f80b1f1 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -264,14 +264,6 @@ cfg_if! { } } impl Eq for __c_anonymous_sigaction_handler{} - impl fmt::Debug for __c_anonymous_sigaction_handler { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result - { - f.debug_struct("sigaction_t") - .field("value", unsafe{ &self.default }) - .finish() - } - } impl hash::Hash for __c_anonymous_sigaction_handler { fn hash(&self, state: &mut H) { unsafe{ self.default.hash(state) };