Fixes has_cpuid implementation

https://github.com/rust-lang/rust/issues/51691
This commit is contained in:
gnzlbg 2018-06-23 13:05:15 +02:00 committed by gnzlbg
parent 39b15bc993
commit a51a3ab289

View file

@ -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() {