From 1b3d2c0c8a652644559bba8176d6af5c1a28e04d Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Sat, 21 Sep 2024 14:40:22 +0200 Subject: [PATCH] Simplify code related to testing of xtest --- crates/core_arch/src/x86/xsave.rs | 14 +------------- crates/core_arch/src/x86_64/xsave.rs | 16 ++-------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/crates/core_arch/src/x86/xsave.rs b/crates/core_arch/src/x86/xsave.rs index d555760133..45f840323f 100644 --- a/crates/core_arch/src/x86/xsave.rs +++ b/crates/core_arch/src/x86/xsave.rs @@ -167,6 +167,7 @@ mod tests { use stdarch_test::simd_test; #[repr(align(64))] + #[derive(Debug)] struct XsaveArea { // max size for 256-bit registers is 800 bytes: // see https://software.intel.com/en-us/node/682996 @@ -198,19 +199,6 @@ mod tests { } } - impl fmt::Debug for XsaveArea { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "[")?; - for i in 0..self.data.len() { - write!(f, "{}", self.data[i])?; - if i != self.data.len() - 1 { - write!(f, ", ")?; - } - } - write!(f, "]") - } - } - // We cannot test for `_xsave`, `xrstor`, `_xsetbv`, `_xsaveopt`, `_xsaves`, `_xrstors` as they // are privileged instructions and will need access to kernel mode to execute and test them. // see https://github.com/rust-lang/stdarch/issues/209 diff --git a/crates/core_arch/src/x86_64/xsave.rs b/crates/core_arch/src/x86_64/xsave.rs index 569054c431..072f651fef 100644 --- a/crates/core_arch/src/x86_64/xsave.rs +++ b/crates/core_arch/src/x86_64/xsave.rs @@ -131,6 +131,7 @@ mod tests { use stdarch_test::simd_test; #[repr(align(64))] + #[derive(Debug)] struct XsaveArea { // max size for 256-bit registers is 800 bytes: // see https://software.intel.com/en-us/node/682996 @@ -144,7 +145,7 @@ mod tests { XsaveArea { data: [0; 2560] } } fn ptr(&mut self) -> *mut u8 { - &mut self.data[0] as *mut _ as *mut u8 + self.data.as_mut_ptr() } } @@ -162,19 +163,6 @@ mod tests { } } - impl fmt::Debug for XsaveArea { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "[")?; - for i in 0..self.data.len() { - write!(f, "{}", self.data[i])?; - if i != self.data.len() - 1 { - write!(f, ", ")?; - } - } - write!(f, "]") - } - } - // We cannot test `_xsave64`, `_xrstor64`, `_xsaveopt64`, `_xsaves64` and `_xrstors64` directly // as they are privileged instructions and will need access to the kernel to run and test them. // See https://github.com/rust-lang/stdarch/issues/209