Skip to content
Snippets Groups Projects
Commit 33cf9e2f authored by Jonathan Lennox's avatar Jonathan Lennox Committed by Jean-Marc Valin
Browse files

Fix cpuid asm on 32-bit PIC.

parent ee6ec634
No related branches found
No related tags found
No related merge requests found
...@@ -48,14 +48,28 @@ ...@@ -48,14 +48,28 @@
static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType)
{ {
#if defined(CPU_INFO_BY_ASM) #if defined(CPU_INFO_BY_ASM)
#if defined(__i386__) && defined(__PIC__)
/* %ebx is PIC register in 32-bit, so mustn't clobber it. */
__asm__ __volatile__ (
"xchg %%ebx, %1\n"
"cpuid\n"
"xchg %%ebx, %1\n":
"=a" (CPUInfo[0]),
"=r" (CPUInfo[1]),
"=c" (CPUInfo[2]),
"=d" (CPUInfo[3]) :
"0" (InfoType)
);
#else
__asm__ __volatile__ ( __asm__ __volatile__ (
"cpuid": "cpuid":
"=a" (CPUInfo[0]), "=a" (CPUInfo[0]),
"=b" (CPUInfo[1]), "=b" (CPUInfo[1]),
"=c" (CPUInfo[2]), "=c" (CPUInfo[2]),
"=d" (CPUInfo[3]) : "=d" (CPUInfo[3]) :
"a" (InfoType), "c" (0) "0" (InfoType)
); );
#endif
#elif defined(CPU_INFO_BY_C) #elif defined(CPU_INFO_BY_C)
__get_cpuid(InfoType, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3])); __get_cpuid(InfoType, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3]));
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment