|
252 | 252 | }
|
253 | 253 |
|
254 | 254 | // signal.h
|
| 255 | + |
255 | 256 | pub struct sigaction {
|
256 |
| - pub sa_u : ::size_t, // actually union of two function pointers |
| 257 | + pub sa_u : ::sa_u_t, |
257 | 258 | pub sa_mask : ::sigset_t,
|
258 | 259 | pub sa_flags : ::c_int,
|
259 | 260 | }
|
|
269 | 270 | pub struct siginfo_t {
|
270 | 271 | pub si_signo : ::c_int,
|
271 | 272 | pub si_code : ::c_int,
|
272 |
| - pub si_value : ::size_t, // actually union of int and void * |
| 273 | + pub si_value : ::sigval, |
273 | 274 | pub si_errno : ::c_int,
|
274 | 275 | pub si_status: ::c_int,
|
275 | 276 | pub si_addr: *mut ::c_void,
|
@@ -414,6 +415,16 @@ s_no_extra_traits! {
|
414 | 415 | pub __ss_pad2 : [::c_char; _SS_PAD2SIZE],
|
415 | 416 | }
|
416 | 417 |
|
| 418 | + pub union sa_u_t { |
| 419 | + pub sa_handler : extern "C" fn(::c_int) -> !, |
| 420 | + pub sa_sigaction: extern "C" fn(::c_int, *mut ::siginfo_t, |
| 421 | + *mut ::c_void) -> !, |
| 422 | + } |
| 423 | + |
| 424 | + pub union sigval { |
| 425 | + pub sival_int : ::c_int, |
| 426 | + pub sival_ptr : *mut ::c_void, |
| 427 | + } |
417 | 428 | }
|
418 | 429 |
|
419 | 430 | cfg_if! {
|
@@ -463,6 +474,46 @@ cfg_if! {
|
463 | 474 | .finish()
|
464 | 475 | }
|
465 | 476 | }
|
| 477 | + |
| 478 | + impl PartialEq for sa_u_t { |
| 479 | + fn eq(&self, other: &sa_u_t) -> bool { |
| 480 | + unsafe { self.sa_handler == other.sa_handler } |
| 481 | + } |
| 482 | + } |
| 483 | + impl Eq for sa_u_t {} |
| 484 | + impl ::fmt::Debug for sa_u_t { |
| 485 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 486 | + f.debug_struct("sa_u_t") |
| 487 | + .field("sa_handler", unsafe { &self.sa_handler }) |
| 488 | + .field("sa_sigaction", unsafe { &self.sa_sigaction }) |
| 489 | + .finish() |
| 490 | + } |
| 491 | + } |
| 492 | + impl ::hash::Hash for sa_u_t { |
| 493 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 494 | + unsafe { self.sa_handler.hash(state) }; |
| 495 | + } |
| 496 | + } |
| 497 | + |
| 498 | + impl PartialEq for sigval { |
| 499 | + fn eq(&self, other: &sigval) -> bool { |
| 500 | + unsafe { self.sival_ptr == other.sival_ptr } |
| 501 | + } |
| 502 | + } |
| 503 | + impl Eq for sigval {} |
| 504 | + impl ::fmt::Debug for sigval { |
| 505 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 506 | + f.debug_struct("sigval") |
| 507 | + .field("sival_int", unsafe { &self.sival_int}) |
| 508 | + .field("sival_ptr", unsafe { &self.sival_ptr }) |
| 509 | + .finish() |
| 510 | + } |
| 511 | + } |
| 512 | + impl ::hash::Hash for sigval { |
| 513 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 514 | + unsafe { self.sival_ptr.hash(state) }; |
| 515 | + } |
| 516 | + } |
466 | 517 | }
|
467 | 518 | }
|
468 | 519 |
|
@@ -1976,16 +2027,14 @@ extern "C" {
|
1976 | 2027 | pub fn sigqueue(
|
1977 | 2028 | __pid: pid_t,
|
1978 | 2029 | __signo: ::c_int,
|
1979 |
| - __value: ::size_t, // Actual type is const union sigval value, |
1980 |
| - // which is a union of int and void * |
| 2030 | + __value: ::sigval, |
1981 | 2031 | ) -> ::c_int;
|
1982 | 2032 |
|
1983 | 2033 | // signal.h for user
|
1984 | 2034 | pub fn _sigqueue(
|
1985 | 2035 | rtpId: ::RTP_ID,
|
1986 | 2036 | signo: ::c_int,
|
1987 |
| - pValue: *mut ::size_t, // Actual type is const union * sigval value, |
1988 |
| - // which is a union of int and void * |
| 2037 | + pValue: *const ::sigval, |
1989 | 2038 | sigCode: ::c_int,
|
1990 | 2039 | ) -> ::c_int;
|
1991 | 2040 |
|
|
0 commit comments