|
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 : Option<unsafe extern "C" fn(::c_int) -> !>, |
| 420 | + pub sa_sigaction: Option<unsafe 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,67 @@ 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 { |
| 481 | + let h1 = match self.sa_handler { |
| 482 | + Some(handler) => handler as usize, |
| 483 | + None => 0 as usize, |
| 484 | + }; |
| 485 | + let h2 = match other.sa_handler { |
| 486 | + Some(handler) => handler as usize, |
| 487 | + None => 0 as usize, |
| 488 | + }; |
| 489 | + h1 == h2 |
| 490 | + } |
| 491 | + } |
| 492 | + } |
| 493 | + impl Eq for sa_u_t {} |
| 494 | + impl ::fmt::Debug for sa_u_t { |
| 495 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 496 | + unsafe { |
| 497 | + let h = match self.sa_handler { |
| 498 | + Some(handler) => handler as usize, |
| 499 | + None => 0 as usize, |
| 500 | + }; |
| 501 | + |
| 502 | + f.debug_struct("sa_u_t") |
| 503 | + .field("sa_handler", &h) |
| 504 | + .finish() |
| 505 | + } |
| 506 | + } |
| 507 | + } |
| 508 | + impl ::hash::Hash for sa_u_t { |
| 509 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 510 | + unsafe { |
| 511 | + let h = match self.sa_handler { |
| 512 | + Some(handler) => handler as usize, |
| 513 | + None => 0 as usize, |
| 514 | + }; |
| 515 | + h.hash(state) |
| 516 | + } |
| 517 | + } |
| 518 | + } |
| 519 | + |
| 520 | + impl PartialEq for sigval { |
| 521 | + fn eq(&self, other: &sigval) -> bool { |
| 522 | + unsafe { self.sival_ptr as usize == other.sival_ptr as usize } |
| 523 | + } |
| 524 | + } |
| 525 | + impl Eq for sigval {} |
| 526 | + impl ::fmt::Debug for sigval { |
| 527 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 528 | + f.debug_struct("sigval") |
| 529 | + .field("sival_ptr", unsafe { &(self.sival_ptr as usize) }) |
| 530 | + .finish() |
| 531 | + } |
| 532 | + } |
| 533 | + impl ::hash::Hash for sigval { |
| 534 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 535 | + unsafe { (self.sival_ptr as usize).hash(state) }; |
| 536 | + } |
| 537 | + } |
466 | 538 | }
|
467 | 539 | }
|
468 | 540 |
|
@@ -1976,16 +2048,14 @@ extern "C" {
|
1976 | 2048 | pub fn sigqueue(
|
1977 | 2049 | __pid: pid_t,
|
1978 | 2050 | __signo: ::c_int,
|
1979 |
| - __value: ::size_t, // Actual type is const union sigval value, |
1980 |
| - // which is a union of int and void * |
| 2051 | + __value: ::sigval, |
1981 | 2052 | ) -> ::c_int;
|
1982 | 2053 |
|
1983 | 2054 | // signal.h for user
|
1984 | 2055 | pub fn _sigqueue(
|
1985 | 2056 | rtpId: ::RTP_ID,
|
1986 | 2057 | signo: ::c_int,
|
1987 |
| - pValue: *mut ::size_t, // Actual type is const union * sigval value, |
1988 |
| - // which is a union of int and void * |
| 2058 | + pValue: *const ::sigval, |
1989 | 2059 | sigCode: ::c_int,
|
1990 | 2060 | ) -> ::c_int;
|
1991 | 2061 |
|
|
0 commit comments