Skip to content

Commit 1b3d2c0

Browse files
marxinAmanieu
authored andcommitted
Simplify code related to testing of xtest
1 parent 96a614b commit 1b3d2c0

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

crates/core_arch/src/x86/xsave.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ mod tests {
167167
use stdarch_test::simd_test;
168168

169169
#[repr(align(64))]
170+
#[derive(Debug)]
170171
struct XsaveArea {
171172
// max size for 256-bit registers is 800 bytes:
172173
// see https://software.intel.com/en-us/node/682996
@@ -198,19 +199,6 @@ mod tests {
198199
}
199200
}
200201

201-
impl fmt::Debug for XsaveArea {
202-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
203-
write!(f, "[")?;
204-
for i in 0..self.data.len() {
205-
write!(f, "{}", self.data[i])?;
206-
if i != self.data.len() - 1 {
207-
write!(f, ", ")?;
208-
}
209-
}
210-
write!(f, "]")
211-
}
212-
}
213-
214202
// We cannot test for `_xsave`, `xrstor`, `_xsetbv`, `_xsaveopt`, `_xsaves`, `_xrstors` as they
215203
// are privileged instructions and will need access to kernel mode to execute and test them.
216204
// see https://github.com/rust-lang/stdarch/issues/209

crates/core_arch/src/x86_64/xsave.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ mod tests {
131131
use stdarch_test::simd_test;
132132

133133
#[repr(align(64))]
134+
#[derive(Debug)]
134135
struct XsaveArea {
135136
// max size for 256-bit registers is 800 bytes:
136137
// see https://software.intel.com/en-us/node/682996
@@ -144,7 +145,7 @@ mod tests {
144145
XsaveArea { data: [0; 2560] }
145146
}
146147
fn ptr(&mut self) -> *mut u8 {
147-
&mut self.data[0] as *mut _ as *mut u8
148+
self.data.as_mut_ptr()
148149
}
149150
}
150151

@@ -162,19 +163,6 @@ mod tests {
162163
}
163164
}
164165

165-
impl fmt::Debug for XsaveArea {
166-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
167-
write!(f, "[")?;
168-
for i in 0..self.data.len() {
169-
write!(f, "{}", self.data[i])?;
170-
if i != self.data.len() - 1 {
171-
write!(f, ", ")?;
172-
}
173-
}
174-
write!(f, "]")
175-
}
176-
}
177-
178166
// We cannot test `_xsave64`, `_xrstor64`, `_xsaveopt64`, `_xsaves64` and `_xrstors64` directly
179167
// as they are privileged instructions and will need access to the kernel to run and test them.
180168
// See https://github.com/rust-lang/stdarch/issues/209

0 commit comments

Comments
 (0)