|
1 | 1 | pub type c_char = i8;
|
2 | 2 | pub type wchar_t = i32;
|
| 3 | +pub type greg_t = i64; |
3 | 4 |
|
4 | 5 | s! {
|
5 | 6 | pub struct stat {
|
|
41 | 42 | pub st_ctime_nsec: ::c_long,
|
42 | 43 | __unused: [::c_long; 3],
|
43 | 44 | }
|
| 45 | + |
| 46 | + pub struct _libc_xmmreg { |
| 47 | + pub element: [u32; 4], |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +cfg_if! { |
| 52 | + if #[cfg(libc_union)] { |
| 53 | + s_no_extra_traits! { |
| 54 | + pub union __c_anonymous_uc_sigmask { |
| 55 | + uc_sigmask: ::sigset_t, |
| 56 | + uc_sigmask64: ::sigset64_t, |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + cfg_if! { |
| 61 | + if #[cfg(feature = "extra_traits")] { |
| 62 | + impl PartialEq for __c_anonymous_uc_sigmask { |
| 63 | + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { |
| 64 | + unsafe { self.uc_sigmask == other.uc_sigmask } |
| 65 | + } |
| 66 | + } |
| 67 | + impl Eq for __c_anonymous_uc_sigmask {} |
| 68 | + impl ::fmt::Debug for __c_anonymous_uc_sigmask { |
| 69 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 70 | + f.debug_struct("uc_sigmask") |
| 71 | + .field("uc_sigmask", unsafe { &self.uc_sigmask }) |
| 72 | + .finish() |
| 73 | + } |
| 74 | + } |
| 75 | + impl ::hash::Hash for __c_anonymous_uc_sigmask { |
| 76 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 77 | + unsafe { self.uc_sigmask.hash(state) } |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +s_no_extra_traits! { |
| 86 | + pub struct _libc_fpxreg { |
| 87 | + pub significand: [u16; 4], |
| 88 | + pub exponent: u16, |
| 89 | + __padding: [u16; 3], |
| 90 | + } |
| 91 | + |
| 92 | + pub struct _libc_fpstate { |
| 93 | + pub cwd: u16, |
| 94 | + pub swd: u16, |
| 95 | + pub ftw: u16, |
| 96 | + pub fop: u16, |
| 97 | + pub rip: u64, |
| 98 | + pub rdp: u64, |
| 99 | + pub mxcsr: u32, |
| 100 | + pub mxcr_mask: u32, |
| 101 | + pub _st: [_libc_fpxreg; 8], |
| 102 | + pub _xmm: [_libc_xmmreg; 16], |
| 103 | + __private: [u32; 24], |
| 104 | + } |
| 105 | + |
| 106 | + pub struct mcontext_t { |
| 107 | + pub gregs: [greg_t; 23], |
| 108 | + pub fpregs: *mut _libc_fpstate, |
| 109 | + __private: [u64; 8], |
| 110 | + } |
| 111 | + |
| 112 | + pub struct ucontext_t { |
| 113 | + pub uc_flags: ::c_ulong, |
| 114 | + pub uc_link: *mut ucontext_t, |
| 115 | + pub uc_stack: ::stack_t, |
| 116 | + pub uc_mcontext: mcontext_t, |
| 117 | + pub uc_sigmask64: __c_anonymous_uc_sigmask, |
| 118 | + __fpregs_mem: _libc_fpstate, |
| 119 | + } |
| 120 | +} |
| 121 | + |
| 122 | +cfg_if! { |
| 123 | + if #[cfg(feature = "extra_traits")] { |
| 124 | + impl PartialEq for _libc_fpxreg { |
| 125 | + fn eq(&self, other: &Self) -> bool { |
| 126 | + self.significand == other.significand |
| 127 | + && self.exponent == other.exponent |
| 128 | + // Ignore padding field |
| 129 | + } |
| 130 | + } |
| 131 | + impl Eq for _libc_fpxreg {} |
| 132 | + impl ::fmt::Debug for _libc_fpxreg { |
| 133 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 134 | + f.debug_struct("_libc_fpxreg") |
| 135 | + .field("significand", &self.significand) |
| 136 | + .field("exponent", &self.exponent) |
| 137 | + // Ignore padding field |
| 138 | + .finish() |
| 139 | + } |
| 140 | + } |
| 141 | + impl ::hash::Hash for _libc_fpxreg { |
| 142 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 143 | + self.significand.hash(state); |
| 144 | + self.exponent.hash(state); |
| 145 | + // Ignore padding field |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + impl PartialEq for _libc_fpstate { |
| 150 | + fn eq(&self, other: &Self) -> bool { |
| 151 | + self.cwd == other.cwd |
| 152 | + && self.swd == other.swd |
| 153 | + && self.ftw == other.ftw |
| 154 | + && self.fop == other.fop |
| 155 | + && self.rip == other.rip |
| 156 | + && self.rdp == other.rdp |
| 157 | + && self.mxcsr == other.mxcsr |
| 158 | + && self.mxcr_mask == other.mxcr_mask |
| 159 | + && self._st == other._st |
| 160 | + && self._xmm == other._xmm |
| 161 | + // Ignore padding field |
| 162 | + } |
| 163 | + } |
| 164 | + impl Eq for _libc_fpstate {} |
| 165 | + impl ::fmt::Debug for _libc_fpstate { |
| 166 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 167 | + f.debug_struct("_libc_fpstate") |
| 168 | + .field("cwd", &self.cwd) |
| 169 | + .field("swd", &self.swd) |
| 170 | + .field("ftw", &self.ftw) |
| 171 | + .field("fop", &self.fop) |
| 172 | + .field("rip", &self.rip) |
| 173 | + .field("rdp", &self.rdp) |
| 174 | + .field("mxcsr", &self.mxcsr) |
| 175 | + .field("mxcr_mask", &self.mxcr_mask) |
| 176 | + .field("_st", &self._st) |
| 177 | + .field("_xmm", &self._xmm) |
| 178 | + // Ignore padding field |
| 179 | + .finish() |
| 180 | + } |
| 181 | + } |
| 182 | + impl ::hash::Hash for _libc_fpstate { |
| 183 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 184 | + self.cwd.hash(state); |
| 185 | + self.swd.hash(state); |
| 186 | + self.ftw.hash(state); |
| 187 | + self.fop.hash(state); |
| 188 | + self.rip.hash(state); |
| 189 | + self.rdp.hash(state); |
| 190 | + self.mxcsr.hash(state); |
| 191 | + self.mxcr_mask.hash(state); |
| 192 | + self._st.hash(state); |
| 193 | + self._xmm.hash(state); |
| 194 | + // Ignore padding field |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + impl PartialEq for mcontext_t { |
| 199 | + fn eq(&self, other: &Self) -> bool { |
| 200 | + self.gregs == other.gregs |
| 201 | + && self.fpregs == other.fpregs |
| 202 | + // Ignore padding field |
| 203 | + } |
| 204 | + } |
| 205 | + impl Eq for mcontext_t {} |
| 206 | + impl ::fmt::Debug for mcontext_t { |
| 207 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 208 | + f.debug_struct("mcontext_t") |
| 209 | + .field("gregs", &self.gregs) |
| 210 | + .field("fpregs", &self.fpregs) |
| 211 | + // Ignore padding field |
| 212 | + .finish() |
| 213 | + } |
| 214 | + } |
| 215 | + impl ::hash::Hash for mcontext_t { |
| 216 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 217 | + self.gregs.hash(state); |
| 218 | + self.fpregs.hash(state); |
| 219 | + // Ignore padding field |
| 220 | + } |
| 221 | + } |
| 222 | + |
| 223 | + impl PartialEq for ucontext_t { |
| 224 | + fn eq(&self, other: &Self) -> bool { |
| 225 | + self.uc_flags == other.uc_flags |
| 226 | + && self.uc_link == other.uc_link |
| 227 | + && self.uc_stack == other.uc_stack |
| 228 | + && self.uc_mcontext == other.uc_mcontext |
| 229 | + && self.uc_sigmask64 == other.uc_sigmask64 |
| 230 | + // Ignore padding field |
| 231 | + } |
| 232 | + } |
| 233 | + impl Eq for ucontext_t {} |
| 234 | + impl ::fmt::Debug for ucontext_t { |
| 235 | + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { |
| 236 | + f.debug_struct("ucontext_t") |
| 237 | + .field("uc_flags", &self.uc_flags) |
| 238 | + .field("uc_link", &self.uc_link) |
| 239 | + .field("uc_stack", &self.uc_stack) |
| 240 | + .field("uc_mcontext", &self.uc_mcontext) |
| 241 | + .field("uc_sigmask64", &self.uc_sigmask64) |
| 242 | + // Ignore padding field |
| 243 | + .finish() |
| 244 | + } |
| 245 | + } |
| 246 | + impl ::hash::Hash for ucontext_t { |
| 247 | + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { |
| 248 | + self.uc_flags.hash(state); |
| 249 | + self.uc_link.hash(state); |
| 250 | + self.uc_stack.hash(state); |
| 251 | + self.uc_mcontext.hash(state); |
| 252 | + self.uc_sigmask64.hash(state); |
| 253 | + // Ignore padding field |
| 254 | + } |
| 255 | + } |
| 256 | + } |
44 | 257 | }
|
45 | 258 |
|
46 | 259 | pub const O_DIRECT: ::c_int = 0x4000;
|
@@ -419,6 +632,31 @@ pub const ES: ::c_int = 24;
|
419 | 632 | pub const FS: ::c_int = 25;
|
420 | 633 | pub const GS: ::c_int = 26;
|
421 | 634 |
|
| 635 | +// offsets in mcontext_t.gregs from sys/ucontext.h |
| 636 | +pub const REG_R8: ::c_int = 0; |
| 637 | +pub const REG_R9: ::c_int = 1; |
| 638 | +pub const REG_R10: ::c_int = 2; |
| 639 | +pub const REG_R11: ::c_int = 3; |
| 640 | +pub const REG_R12: ::c_int = 4; |
| 641 | +pub const REG_R13: ::c_int = 5; |
| 642 | +pub const REG_R14: ::c_int = 6; |
| 643 | +pub const REG_R15: ::c_int = 7; |
| 644 | +pub const REG_RDI: ::c_int = 8; |
| 645 | +pub const REG_RSI: ::c_int = 9; |
| 646 | +pub const REG_RBP: ::c_int = 10; |
| 647 | +pub const REG_RBX: ::c_int = 11; |
| 648 | +pub const REG_RDX: ::c_int = 12; |
| 649 | +pub const REG_RAX: ::c_int = 13; |
| 650 | +pub const REG_RCX: ::c_int = 14; |
| 651 | +pub const REG_RSP: ::c_int = 15; |
| 652 | +pub const REG_RIP: ::c_int = 16; |
| 653 | +pub const REG_EFL: ::c_int = 17; |
| 654 | +pub const REG_CSGSFS: ::c_int = 18; |
| 655 | +pub const REG_ERR: ::c_int = 19; |
| 656 | +pub const REG_TRAPNO: ::c_int = 20; |
| 657 | +pub const REG_OLDMASK: ::c_int = 21; |
| 658 | +pub const REG_CR2: ::c_int = 22; |
| 659 | + |
422 | 660 | cfg_if! {
|
423 | 661 | if #[cfg(libc_align)] {
|
424 | 662 | mod align;
|
|
0 commit comments