|
1 | 1 | pub type __priority_which_t = ::c_uint;
|
2 | 2 |
|
| 3 | +cfg_if! { |
| 4 | + if #[cfg(libc_union)] { |
| 5 | + #[repr(C)] |
| 6 | + #[derive(Copy, Clone)] |
| 7 | + struct addr_bnd_t { |
| 8 | + lower: *mut ::c_void, |
| 9 | + upper: *mut ::c_void, |
| 10 | + } |
| 11 | + |
| 12 | + #[repr(C)] |
| 13 | + #[derive(Copy, Clone)] |
| 14 | + union sigfault_t_anonymous_union { |
| 15 | + addr_bnd: addr_bnd_t, |
| 16 | + pkey: u32, |
| 17 | + } |
| 18 | + |
| 19 | + #[repr(C)] |
| 20 | + #[derive(Copy, Clone)] |
| 21 | + struct sigfault_t { |
| 22 | + addr: *mut ::c_void, |
| 23 | + #[cfg(target_arch = "sparc")] |
| 24 | + trapno: ::c_int, |
| 25 | + addr_lsb: ::c_short, |
| 26 | + anonymous_union: sigfault_t_anonymous_union, |
| 27 | + } |
| 28 | + |
| 29 | + cfg_if! { |
| 30 | + if #[cfg(target_point_width = "64")] { |
| 31 | + type SI_PADDING = [::c_int; 28]; |
| 32 | + } else { |
| 33 | + type SI_PADDING = [::c_int; 29]; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + #[repr(C)] |
| 38 | + #[derive(Copy, Clone)] |
| 39 | + union sifields_t { |
| 40 | + _pad: SI_PADDING, |
| 41 | + sigfault: sigfault_t, |
| 42 | + } |
| 43 | + |
| 44 | + impl ::fmt::Debug for sigfault_t_anonymous_union { |
| 45 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 46 | + // Excludes the fields because we can't know which is valid |
| 47 | + f.debug_struct("sigfault_t_anonymous_union") |
| 48 | + .finish() |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + impl ::fmt::Debug for sigfault_t { |
| 53 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 54 | + // TODO: include trapno on Sparc |
| 55 | + f.debug_struct("sigfault_t") |
| 56 | + .field("addr", &self.addr) |
| 57 | + .field("addr_lsb", &self.addr_lsb) |
| 58 | + .field("anonymous_union", &self.anonymous_union) |
| 59 | + .finish() |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + impl ::fmt::Debug for sifields_t { |
| 64 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 65 | + // No way to print anything more detailed without the |
| 66 | + // discriminant from siginfo_t |
| 67 | + f.debug_struct("sifields_t").finish() |
| 68 | + } |
| 69 | + } |
| 70 | + } else { |
| 71 | + type sifields_t = [::c_int; 29]; |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +s_no_extra_traits! { |
| 76 | + pub struct siginfo_t { |
| 77 | + pub si_signo: ::c_int, |
| 78 | + pub si_errno: ::c_int, |
| 79 | + pub si_code: ::c_int, |
| 80 | + sifields: sifields_t, |
| 81 | + |
| 82 | + #[cfg(target_arch = "x86_64")] |
| 83 | + _align: [u64; 0], |
| 84 | + #[cfg(not(target_arch = "x86_64"))] |
| 85 | + _align: [usize; 0], |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +cfg_if! { |
| 90 | + if #[cfg(libc_union)] { |
| 91 | + impl siginfo_t { |
| 92 | + pub unsafe fn si_addr(&self) -> *mut ::c_void { |
| 93 | + self.sifields.sigfault.addr |
| 94 | + } |
| 95 | + } |
| 96 | + } else { |
| 97 | + impl siginfo_t { |
| 98 | + pub unsafe fn si_addr(&self) -> *mut ::c_void { |
| 99 | + #[repr(C)] |
| 100 | + struct siginfo_sigfault { |
| 101 | + _si_signo: ::c_int, |
| 102 | + _si_errno: ::c_int, |
| 103 | + _si_code: ::c_int, |
| 104 | + si_addr: *mut ::c_void |
| 105 | + } |
| 106 | + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | + |
| 112 | +impl ::fmt::Debug for siginfo_t { |
| 113 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 114 | + // TODO: include fields from sifields |
| 115 | + f.debug_struct("siginfo_t") |
| 116 | + .field("si_signo", &self.si_signo) |
| 117 | + .field("si_errno", &self.si_errno) |
| 118 | + .field("si_code", &self.si_code) |
| 119 | + .finish() |
| 120 | + } |
| 121 | +} |
| 122 | + |
3 | 123 | s! {
|
4 | 124 | pub struct aiocb {
|
5 | 125 | pub aio_fildes: ::c_int,
|
|
44 | 164 | pub ss_size: ::size_t
|
45 | 165 | }
|
46 | 166 |
|
47 |
| - pub struct siginfo_t { |
48 |
| - pub si_signo: ::c_int, |
49 |
| - pub si_errno: ::c_int, |
50 |
| - pub si_code: ::c_int, |
51 |
| - pub _pad: [::c_int; 29], |
52 |
| - #[cfg(target_arch = "x86_64")] |
53 |
| - _align: [u64; 0], |
54 |
| - #[cfg(not(target_arch = "x86_64"))] |
55 |
| - _align: [usize; 0], |
56 |
| - } |
57 |
| - |
58 | 167 | pub struct glob64_t {
|
59 | 168 | pub gl_pathc: ::size_t,
|
60 | 169 | pub gl_pathv: *mut *mut ::c_char,
|
|
0 commit comments