diff options
author | Jonathan Lennox <jonathan@vidyo.com> | 2015-08-04 00:04:23 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2015-09-02 00:21:31 +0300 |
commit | 33cf9e2f47067c6545c12a0876af5eb9ce116455 (patch) | |
tree | 447fede8e705fdfdbf1eacd95e35a027bd78ebe0 /celt | |
parent | ee6ec6349e7b1d888baa49c064076cef0559b6e4 (diff) |
Fix cpuid asm on 32-bit PIC.
Diffstat (limited to 'celt')
-rw-r--r-- | celt/x86/x86cpu.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/celt/x86/x86cpu.c b/celt/x86/x86cpu.c index c82a4b7b..090e23df 100644 --- a/celt/x86/x86cpu.c +++ b/celt/x86/x86cpu.c @@ -48,14 +48,28 @@ static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) { #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__ ( "cpuid": "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : - "a" (InfoType), "c" (0) + "0" (InfoType) ); +#endif #elif defined(CPU_INFO_BY_C) __get_cpuid(InfoType, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3])); #endif |