File tree Expand file tree Collapse file tree 1 file changed +25
-27
lines changed
Expand file tree Collapse file tree 1 file changed +25
-27
lines changed Original file line number Diff line number Diff line change @@ -95,33 +95,31 @@ pub fn has_cpuid() -> bool {
9595 // If it is, then `cpuid` is available.
9696 let result: u32 ;
9797 let _temp: u32 ;
98- unsafe {
99- asm ! ( r#"
100- # Read eflags into $0 and copy into $1:
101- pushfd
102- pop $0
103- mov $1, $0
104- # Flip 21st bit:
105- xor $0, 0x200000
106- # Set eflags:
107- push $0
108- popfd
109- # Read eflags again, if cpuid is available
110- # the 21st bit will be flipped, otherwise it
111- # it will have the same value as the original in $1:
112- pushfd
113- pop $0
114- # Xor'ing with the original eflags should have the
115- # 21st bit set to true if cpuid is available and zero
116- # otherwise. All other bits have not been modified and
117- # are zero:
118- xor $0, $1
119- "#
120- : "=r" ( result) , "=r" ( _temp)
121- :
122- : "cc" , "memory"
123- : "intel" ) ;
124- }
98+ asm ! ( r#"
99+ # Read eflags into $0 and copy into $1:
100+ pushfd
101+ pop $0
102+ mov $1, $0
103+ # Flip 21st bit:
104+ xor $0, 0x200000
105+ # Set eflags:
106+ push $0
107+ popfd
108+ # Read eflags again, if cpuid is available
109+ # the 21st bit will be flipped, otherwise it
110+ # it will have the same value as the original in $1:
111+ pushfd
112+ pop $0
113+ # Xor'ing with the original eflags should have the
114+ # 21st bit set to true if cpuid is available and zero
115+ # otherwise. All other bits have not been modified and
116+ # are zero:
117+ xor $0, $1
118+ "#
119+ : "=r" ( result) , "=r" ( _temp)
120+ :
121+ : "cc" , "memory"
122+ : "intel" ) ;
125123 // Therefore, if result is 0, the bit was not modified and cpuid is
126124 // not available. If cpuid is available, the bit was modified and
127125 // result != 0.
You can’t perform that action at this time.
0 commit comments