Skip to content

Commit 9f4ac58

Browse files
committed
Correct the definition of sigval
1 parent 7f3d696 commit 9f4ac58

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/unix/mod.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ missing! {
4343
}
4444
pub type locale_t = *mut c_void;
4545

46+
s_no_extra_traits! {
47+
pub union sigval {
48+
pub sival_ptr: *mut c_void,
49+
pub sival_int: c_int,
50+
}
51+
}
52+
53+
impl hash::Hash for sigval {
54+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
55+
state.write_usize(unsafe { self.sival_ptr } as usize);
56+
}
57+
}
58+
59+
impl ::core::cmp::PartialEq for sigval {
60+
fn eq(&self, other: &Self) -> bool {
61+
unsafe { self.sival_ptr == other.sival_ptr }
62+
}
63+
}
64+
65+
impl ::core::cmp::Eq for sigval {}
66+
4667
s! {
4768
pub struct group {
4869
pub gr_name: *mut c_char,
@@ -173,11 +194,6 @@ s! {
173194
pub l_linger: c_int,
174195
}
175196

176-
pub struct sigval {
177-
// Actually a union of an int and a void*
178-
pub sival_ptr: *mut c_void,
179-
}
180-
181197
// <sys/time.h>
182198
pub struct itimerval {
183199
pub it_interval: crate::timeval,

0 commit comments

Comments
 (0)