Fixes has_cpuid implementation
https://github.com/rust-lang/rust/issues/51691
This commit is contained in:
parent
39b15bc993
commit
a51a3ab289
1 changed files with 6 additions and 1 deletions
|
|
@ -96,7 +96,7 @@ pub fn has_cpuid() -> bool {
|
|||
let eflags: u32 = __readeflags();
|
||||
|
||||
// Invert the ID bit in EFLAGS:
|
||||
let eflags_mod: u32 = eflags | 0x0020_0000;
|
||||
let eflags_mod: u32 = eflags ^ 0x0020_0000;
|
||||
|
||||
// Store the modified EFLAGS (ID bit may or may not be inverted)
|
||||
__writeeflags(eflags_mod);
|
||||
|
|
@ -138,6 +138,11 @@ mod tests {
|
|||
assert!(cpuid::has_cpuid());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_has_cpuid_idempotent() {
|
||||
assert_eq!(cpuid::has_cpuid(), cpuid::has_cpuid());
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[test]
|
||||
fn test_has_cpuid() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue