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