Skip to content

Commit cb41dd1

Browse files
committed
Fixes has_cpuid implementation
rust-lang/rust#51691
1 parent 965d0f2 commit cb41dd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

coresimd/x86/cpuid.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn has_cpuid() -> bool {
9696
let eflags: u32 = __readeflags();
9797

9898
// Invert the ID bit in EFLAGS:
99-
let eflags_mod: u32 = eflags | 0x0020_0000;
99+
let eflags_mod: u32 = eflags ^ 0x0020_0000;
100100

101101
// Store the modified EFLAGS (ID bit may or may not be inverted)
102102
__writeeflags(eflags_mod);
@@ -138,6 +138,11 @@ mod tests {
138138
assert!(cpuid::has_cpuid());
139139
}
140140

141+
#[test]
142+
fn test_has_cpuid_idempotent() {
143+
assert_eq!(cpuid::has_cpuid(), cpuid::has_cpuid());
144+
}
145+
141146
#[cfg(target_arch = "x86")]
142147
#[test]
143148
fn test_has_cpuid() {

0 commit comments

Comments
 (0)