@@ -57,18 +57,18 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult {
57
57
let edx;
58
58
#[ cfg( target_arch = "x86" ) ]
59
59
{
60
- asm ! ( "cpuid"
61
- : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
62
- : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
63
- : : ) ;
60
+ llvm_asm ! ( "cpuid"
61
+ : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
62
+ : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
63
+ : : ) ;
64
64
}
65
65
#[ cfg( target_arch = "x86_64" ) ]
66
66
{
67
67
// x86-64 uses %rbx as the base register, so preserve it.
68
- asm ! ( "cpuid"
69
- : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
70
- : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
71
- : "rbx" : ) ;
68
+ llvm_asm ! ( "cpuid"
69
+ : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
70
+ : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
71
+ : "rbx" : ) ;
72
72
}
73
73
CpuidResult { eax, ebx, ecx, edx }
74
74
}
@@ -113,29 +113,29 @@ pub fn has_cpuid() -> bool {
113
113
// If it is, then `cpuid` is available.
114
114
let result: u32 ;
115
115
let _temp: u32 ;
116
- asm ! ( r#"
117
- # Read eflags into $0 and copy it into $1:
118
- pushfd
119
- pop $0
120
- mov $1, $0
121
- # Flip 21st bit of $0.
122
- xor $0, 0x200000
123
- # Set eflags to the value of $0
124
- #
125
- # Bit 21st can only be modified if cpuid is available
126
- push $0
127
- popfd # A
128
- # Read eflags into $0:
129
- pushfd # B
130
- pop $0
131
- # xor with the original eflags sets the bits that
132
- # have been modified:
133
- xor $0, $1
134
- "#
135
- : "=r" ( result) , "=r" ( _temp)
136
- :
137
- : "cc" , "memory"
138
- : "intel" ) ;
116
+ llvm_asm ! ( r#"
117
+ # Read eflags into $0 and copy it into $1:
118
+ pushfd
119
+ pop $0
120
+ mov $1, $0
121
+ # Flip 21st bit of $0.
122
+ xor $0, 0x200000
123
+ # Set eflags to the value of $0
124
+ #
125
+ # Bit 21st can only be modified if cpuid is available
126
+ push $0
127
+ popfd # A
128
+ # Read eflags into $0:
129
+ pushfd # B
130
+ pop $0
131
+ # xor with the original eflags sets the bits that
132
+ # have been modified:
133
+ xor $0, $1
134
+ "#
135
+ : "=r" ( result) , "=r" ( _temp)
136
+ :
137
+ : "cc" , "memory"
138
+ : "intel" ) ;
139
139
// There is a race between popfd (A) and pushfd (B)
140
140
// where other bits beyond 21st may have been modified due to
141
141
// interrupts, a debugger stepping through the asm, etc.
0 commit comments