-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fixing the improper type of sighandler_t on unix #4918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
585e3df
611b672
f63e902
92b120e
cf39bce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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{ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a comment about what the variants are representing? The two function pointers come from source, the integer variant is needed since sentinel values that aren't function pointers are used. (maybe there's a better name for |
||
| pub sa_handler: Option<extern "C" fn(c_int) -> ()>, | ||
| pub sa_sigaction: Option<extern "C" fn( | ||
|
Comment on lines
+49
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you make these functions |
||
| c_int, | ||
| *mut siginfo_t, | ||
| *mut c_void | ||
| ) -> ()>, | ||
| pub default: size_t, | ||
| } | ||
| } | ||
|
|
||
| s! { | ||
| pub struct group { | ||
| pub gr_name: *mut c_char, | ||
|
|
@@ -244,12 +256,28 @@ 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 hash::Hash for __c_anonymous_sigaction_handler { | ||
| fn hash<H: hash::Hasher>(&self, state: &mut H) { | ||
| unsafe{ self.default.hash(state) }; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please delete these, we are avoiding adding more iffy trait impls (even though this one is reasonably sound) |
||
|
|
||
| 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")))] { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be a
__c_anonymoustype, it can just beunion sighandler_twith no alias since we're exporting it this way anyway.