From 232bc838b5402682378d0e4f228a348243da7178 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 f5f8d954fdadf..a33039e61b105 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, @@ -242,12 +254,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 1143268b1fec148a8eeac2eb4f17589a80009d55 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 a33039e61b105..db40c204bd0be 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 }) @@ -271,19 +271,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 4db2303e5743802856929b66179b1a84c6e6499a 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 db40c204bd0be..934efa8947419 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -262,16 +262,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 b89de82e28857d08b514440312405a6b5b2e0eeb 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 934efa8947419..725acc8b535c9 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -258,12 +258,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 2f3a9d7feefd9d249b00e9dced8ea1daed4b72a6 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 725acc8b535c9..2def8e50f8be3 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -262,14 +262,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) };