From b528b987da6f980d7705141667972b3623f620a4 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 4 Sep 2009 23:14:29 +0000 Subject: [PATCH] - Add an alternate PIC-compliant __cpuid macro in x86.cpp. SVN r1793 (trunk) --- docs/rh-log.txt | 1 + src/x86.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 128520ac38..465ad7a728 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -2,6 +2,7 @@ September 5, 2009 (Changes by Graf Zahl) - made menu dimming a mapping option but kept the CVARS as user override. September 4, 2009 +- Add an alternate PIC-compliant __cpuid macro in x86.cpp. - Fixed: S_LoadSound() did not byte-swap the frequency and length it reads from DMX sounds. - Fixed: PNGTexture must not use the FArchive >> operator as a short hand diff --git a/src/x86.cpp b/src/x86.cpp index 6fcfb55208..880149bc4e 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -25,10 +25,21 @@ void DumpCPUInfo(const CPUInfo *cpu) #include #include + #ifdef __GNUC__ +#if defined(__i386__) && defined(__PIC__) +// %ebx may by the PIC register. */ +#define __cpuid(output, func) \ + __asm__ __volatile__("xchgl\t%%ebx, %1\n\t" \ + "cpuid\n\t" \ + "xchgl\t%%ebx, %1\n\t" \ + : "=a" ((output)[0]), "=r" ((output)[1]), "=c" ((output)[2]), "=d" ((output)[3]) \ + : "a" (func)); +#else #define __cpuid(output, func) __asm__ __volatile__("cpuid" : "=a" ((output)[0]),\ "=b" ((output)[1]), "=c" ((output)[2]), "=d" ((output)[3]) : "a" (func)); #endif +#endif void CheckCPUID(CPUInfo *cpu) {