mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Does not clobber ebx to allow compilation in PIC mode.
This commit is contained in:
parent
27fe843e8c
commit
a029c75470
1 changed files with 11 additions and 1 deletions
12
cpu.h
12
cpu.h
|
|
@ -31,9 +31,19 @@ static inline int cpu_has(uint32_t flag)
|
|||
uint32_t eax = (flag >> 5) ? 0x80000001 : 1;
|
||||
uint32_t edx;
|
||||
|
||||
asm volatile("cpuid"
|
||||
asm volatile(
|
||||
#if defined(__i386__)
|
||||
/* allow compilation in PIC mode saving ebx */
|
||||
"push %%ebx\n"
|
||||
"cpuid\n"
|
||||
"pop %%ebx\n"
|
||||
: "+a" (eax), "=d" (edx)
|
||||
: : "ecx");
|
||||
#else
|
||||
"cpuid\n"
|
||||
: "+a" (eax), "=d" (edx)
|
||||
: : "ecx", "ebx");
|
||||
#endif
|
||||
|
||||
return (edx >> (flag & 31)) & 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue