| 1 |
use crate::prelude::*; |
| 2 |
|
| 3 |
s_no_extra_traits! { |
| 4 |
pub struct fpu_state { |
| 5 |
pub control: c_ushort, |
| 6 |
pub status: c_ushort, |
| 7 |
pub tag: c_ushort, |
| 8 |
pub opcode: c_ushort, |
| 9 |
pub rip: c_ulong, |
| 10 |
pub rdp: c_ulong, |
| 11 |
pub mxcsr: c_uint, |
| 12 |
pub mscsr_mask: c_uint, |
| 13 |
pub _fpreg: [[c_uchar; 8]; 16], |
| 14 |
pub _xmm: [[c_uchar; 16]; 16], |
| 15 |
pub _reserved_416_511: [c_uchar; 96], |
| 16 |
} |
| 17 |
|
| 18 |
pub struct xstate_hdr { |
| 19 |
pub bv: c_ulong, |
| 20 |
pub xcomp_bv: c_ulong, |
| 21 |
pub _reserved: [c_uchar; 48], |
| 22 |
} |
| 23 |
|
| 24 |
pub struct savefpu { |
| 25 |
pub fp_fxsave: fpu_state, |
| 26 |
pub fp_xstate: xstate_hdr, |
| 27 |
pub _fp_ymm: [[c_uchar; 16]; 16], |
| 28 |
} |
| 29 |
|
| 30 |
pub struct mcontext_t { |
| 31 |
pub rax: c_ulong, |
| 32 |
pub rbx: c_ulong, |
| 33 |
pub rcx: c_ulong, |
| 34 |
pub rdx: c_ulong, |
| 35 |
pub rdi: c_ulong, |
| 36 |
pub rsi: c_ulong, |
| 37 |
pub rbp: c_ulong, |
| 38 |
pub r8: c_ulong, |
| 39 |
pub r9: c_ulong, |
| 40 |
pub r10: c_ulong, |
| 41 |
pub r11: c_ulong, |
| 42 |
pub r12: c_ulong, |
| 43 |
pub r13: c_ulong, |
| 44 |
pub r14: c_ulong, |
| 45 |
pub r15: c_ulong, |
| 46 |
pub rsp: c_ulong, |
| 47 |
pub rip: c_ulong, |
| 48 |
pub rflags: c_ulong, |
| 49 |
pub fpu: savefpu, |
| 50 |
} |
| 51 |
|
| 52 |
pub struct ucontext_t { |
| 53 |
pub uc_link: *mut ucontext_t, |
| 54 |
pub uc_sigmask: crate::sigset_t, |
| 55 |
pub uc_stack: crate::stack_t, |
| 56 |
pub uc_mcontext: mcontext_t, |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
cfg_if! { |
| 61 |
if #[cfg(feature = "extra_traits")] { |
| 62 |
impl PartialEq for fpu_state { |
| 63 |
fn eq(&self, other: &fpu_state) -> bool { |
| 64 |
self.control == other.control |
| 65 |
&& self.status == other.status |
| 66 |
&& self.tag == other.tag |
| 67 |
&& self.opcode == other.opcode |
| 68 |
&& self.rip == other.rip |
| 69 |
&& self.rdp == other.rdp |
| 70 |
&& self.mxcsr == other.mxcsr |
| 71 |
&& self.mscsr_mask == other.mscsr_mask |
| 72 |
&& self |
| 73 |
._fpreg |
| 74 |
.iter() |
| 75 |
.zip(other._fpreg.iter()) |
| 76 |
.all(|(a, b)| a == b) |
| 77 |
&& self._xmm.iter().zip(other._xmm.iter()).all(|(a, b)| a == b) |
| 78 |
&& self |
| 79 |
._reserved_416_511 |
| 80 |
.iter() |
| 81 |
.zip(other._reserved_416_511.iter()) |
| 82 |
.all(|(a, b)| a == b) |
| 83 |
} |
| 84 |
} |
| 85 |
impl Eq for fpu_state {} |
| 86 |
impl fmt::Debug for fpu_state { |
| 87 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 88 |
f.debug_struct("fpu_state") |
| 89 |
.field("control", &self.control) |
| 90 |
.field("status", &self.status) |
| 91 |
.field("tag", &self.tag) |
| 92 |
.field("opcode", &self.opcode) |
| 93 |
.field("rip", &self.rip) |
| 94 |
.field("rdp", &self.rdp) |
| 95 |
.field("mxcsr", &self.mxcsr) |
| 96 |
.field("mscsr_mask", &self.mscsr_mask) |
| 97 |
// FIXME(debug): .field("_fpreg", &self._fpreg) |
| 98 |
// FIXME(debug): .field("_xmm", &self._xmm) |
| 99 |
// FIXME(debug): .field("_reserved_416_511", &self._reserved_416_511) |
| 100 |
.finish() |
| 101 |
} |
| 102 |
} |
| 103 |
impl hash::Hash for fpu_state { |
| 104 |
fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 105 |
self.control.hash(state); |
| 106 |
self.status.hash(state); |
| 107 |
self.tag.hash(state); |
| 108 |
self.opcode.hash(state); |
| 109 |
self.rip.hash(state); |
| 110 |
self.rdp.hash(state); |
| 111 |
self.mxcsr.hash(state); |
| 112 |
self.mscsr_mask.hash(state); |
| 113 |
self._fpreg.hash(state); |
| 114 |
self._xmm.hash(state); |
| 115 |
self._reserved_416_511.hash(state); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
impl PartialEq for xstate_hdr { |
| 120 |
fn eq(&self, other: &xstate_hdr) -> bool { |
| 121 |
self.bv == other.bv |
| 122 |
&& self.xcomp_bv == other.xcomp_bv |
| 123 |
&& self |
| 124 |
._reserved |
| 125 |
.iter() |
| 126 |
.zip(other._reserved.iter()) |
| 127 |
.all(|(a, b)| a == b) |
| 128 |
} |
| 129 |
} |
| 130 |
impl Eq for xstate_hdr {} |
| 131 |
impl fmt::Debug for xstate_hdr { |
| 132 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 133 |
f.debug_struct("xstate_hdr") |
| 134 |
.field("bv", &self.bv) |
| 135 |
.field("xcomp_bv", &self.xcomp_bv) |
| 136 |
// FIXME(debug): .field("_reserved", &field._reserved) |
| 137 |
.finish() |
| 138 |
} |
| 139 |
} |
| 140 |
impl hash::Hash for xstate_hdr { |
| 141 |
fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 142 |
self.bv.hash(state); |
| 143 |
self.xcomp_bv.hash(state); |
| 144 |
self._reserved.hash(state); |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
impl PartialEq for savefpu { |
| 149 |
fn eq(&self, other: &savefpu) -> bool { |
| 150 |
self.fp_fxsave == other.fp_fxsave |
| 151 |
&& self.fp_xstate == other.fp_xstate |
| 152 |
&& self |
| 153 |
._fp_ymm |
| 154 |
.iter() |
| 155 |
.zip(other._fp_ymm.iter()) |
| 156 |
.all(|(a, b)| a == b) |
| 157 |
} |
| 158 |
} |
| 159 |
impl Eq for savefpu {} |
| 160 |
impl fmt::Debug for savefpu { |
| 161 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 162 |
f.debug_struct("savefpu") |
| 163 |
.field("fp_fxsave", &self.fp_fxsave) |
| 164 |
.field("fp_xstate", &self.fp_xstate) |
| 165 |
// FIXME(debug): .field("_fp_ymm", &field._fp_ymm) |
| 166 |
.finish() |
| 167 |
} |
| 168 |
} |
| 169 |
impl hash::Hash for savefpu { |
| 170 |
fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 171 |
self.fp_fxsave.hash(state); |
| 172 |
self.fp_xstate.hash(state); |
| 173 |
self._fp_ymm.hash(state); |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
impl PartialEq for mcontext_t { |
| 178 |
fn eq(&self, other: &mcontext_t) -> bool { |
| 179 |
self.rax == other.rax |
| 180 |
&& self.rbx == other.rbx |
| 181 |
&& self.rbx == other.rbx |
| 182 |
&& self.rcx == other.rcx |
| 183 |
&& self.rdx == other.rdx |
| 184 |
&& self.rdi == other.rdi |
| 185 |
&& self.rsi == other.rsi |
| 186 |
&& self.r8 == other.r8 |
| 187 |
&& self.r9 == other.r9 |
| 188 |
&& self.r10 == other.r10 |
| 189 |
&& self.r11 == other.r11 |
| 190 |
&& self.r12 == other.r12 |
| 191 |
&& self.r13 == other.r13 |
| 192 |
&& self.r14 == other.r14 |
| 193 |
&& self.r15 == other.r15 |
| 194 |
&& self.rsp == other.rsp |
| 195 |
&& self.rip == other.rip |
| 196 |
&& self.rflags == other.rflags |
| 197 |
&& self.fpu == other.fpu |
| 198 |
} |
| 199 |
} |
| 200 |
impl Eq for mcontext_t {} |
| 201 |
impl fmt::Debug for mcontext_t { |
| 202 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 203 |
f.debug_struct("mcontext_t") |
| 204 |
.field("rax", &self.rax) |
| 205 |
.field("rbx", &self.rbx) |
| 206 |
.field("rcx", &self.rcx) |
| 207 |
.field("rdx", &self.rdx) |
| 208 |
.field("rdi", &self.rdi) |
| 209 |
.field("rsi", &self.rsi) |
| 210 |
.field("rbp", &self.rbp) |
| 211 |
.field("r8", &self.r8) |
| 212 |
.field("r9", &self.r9) |
| 213 |
.field("r10", &self.r10) |
| 214 |
.field("r11", &self.r11) |
| 215 |
.field("r12", &self.r12) |
| 216 |
.field("r13", &self.r13) |
| 217 |
.field("r14", &self.r14) |
| 218 |
.field("r15", &self.r15) |
| 219 |
.field("rsp", &self.rsp) |
| 220 |
.field("rip", &self.rip) |
| 221 |
.field("rflags", &self.rflags) |
| 222 |
.field("fpu", &self.fpu) |
| 223 |
.finish() |
| 224 |
} |
| 225 |
} |
| 226 |
impl hash::Hash for mcontext_t { |
| 227 |
fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 228 |
self.rax.hash(state); |
| 229 |
self.rbx.hash(state); |
| 230 |
self.rcx.hash(state); |
| 231 |
self.rdx.hash(state); |
| 232 |
self.rdi.hash(state); |
| 233 |
self.rsi.hash(state); |
| 234 |
self.rbp.hash(state); |
| 235 |
self.r8.hash(state); |
| 236 |
self.r9.hash(state); |
| 237 |
self.r10.hash(state); |
| 238 |
self.r11.hash(state); |
| 239 |
self.r12.hash(state); |
| 240 |
self.r13.hash(state); |
| 241 |
self.r14.hash(state); |
| 242 |
self.r15.hash(state); |
| 243 |
self.rsp.hash(state); |
| 244 |
self.rip.hash(state); |
| 245 |
self.rflags.hash(state); |
| 246 |
self.fpu.hash(state); |
| 247 |
} |
| 248 |
} |
| 249 |
|
| 250 |
impl PartialEq for ucontext_t { |
| 251 |
fn eq(&self, other: &ucontext_t) -> bool { |
| 252 |
self.uc_link == other.uc_link |
| 253 |
&& self.uc_sigmask == other.uc_sigmask |
| 254 |
&& self.uc_stack == other.uc_stack |
| 255 |
&& self.uc_mcontext == other.uc_mcontext |
| 256 |
} |
| 257 |
} |
| 258 |
impl Eq for ucontext_t {} |
| 259 |
impl fmt::Debug for ucontext_t { |
| 260 |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 261 |
f.debug_struct("ucontext_t") |
| 262 |
.field("uc_link", &self.uc_link) |
| 263 |
.field("uc_sigmask", &self.uc_sigmask) |
| 264 |
.field("uc_stack", &self.uc_stack) |
| 265 |
.field("uc_mcontext", &self.uc_mcontext) |
| 266 |
.finish() |
| 267 |
} |
| 268 |
} |
| 269 |
impl hash::Hash for ucontext_t { |
| 270 |
fn hash<H: hash::Hasher>(&self, state: &mut H) { |
| 271 |
self.uc_link.hash(state); |
| 272 |
self.uc_sigmask.hash(state); |
| 273 |
self.uc_stack.hash(state); |
| 274 |
self.uc_mcontext.hash(state); |
| 275 |
} |
| 276 |
} |
| 277 |
} |
| 278 |
} |