Skip to content

Commit ac2785e

Browse files
committed
Add extra traits for user_fpregs_struct
1 parent fd64756 commit ac2785e

File tree

1 file changed

+54
-0
lines changed
  • src/unix/linux_like/android/b64

1 file changed

+54
-0
lines changed

src/unix/linux_like/android/b64/mod.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,60 @@ cfg_if! {
317317
.finish()
318318
}
319319
}
320+
321+
impl PartialEq for user_fpregs_struct {
322+
fn eq(&self, other: &user_fpregs_struct) -> bool {
323+
self.cwd == other.cwd
324+
&& self.swd == other.swd
325+
&& self.ftw == other.ftw
326+
&& self.fop == other.fop
327+
&& self.rip == other.rip
328+
&& self.rdp == other.rdp
329+
&& self.mxcsr == other.mxcsr
330+
&& self.mxcr_mask == other.mxcr_mask
331+
&& self.st_space == other.st_space
332+
&& self
333+
.xmm_space
334+
.iter()
335+
.zip(other.xmm_space.iter())
336+
.all(|(a,b)| a == b)
337+
// Ignore padding field
338+
}
339+
}
340+
341+
impl Eq for user_fpregs_struct {}
342+
343+
impl ::fmt::Debug for user_fpregs_struct {
344+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
345+
f.debug_struct("user_fpregs_struct")
346+
.field("cwd", &self.cwd)
347+
.field("ftw", &self.ftw)
348+
.field("fop", &self.fop)
349+
.field("rip", &self.rip)
350+
.field("rdp", &self.rdp)
351+
.field("mxcsr", &self.mxcsr)
352+
.field("mxcr_mask", &self.mxcr_mask)
353+
.field("st_space", &self.st_space)
354+
// FIXME: .field("xmm_space", &self.xmm_space)
355+
// Ignore padding field
356+
.finish()
357+
}
358+
}
359+
360+
impl ::hash::Hash for user_fpregs_struct {
361+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
362+
self.cwd.hash(state);
363+
self.ftw.hash(state);
364+
self.fop.hash(state);
365+
self.rip.hash(state);
366+
self.rdp.hash(state);
367+
self.mxcsr.hash(state);
368+
self.mxcr_mask.hash(state);
369+
self.st_space.hash(state);
370+
self.xmm_space.hash(state);
371+
// Ignore padding field
372+
}
373+
}
320374
}
321375
}
322376

0 commit comments

Comments
 (0)