From 9dfd263d3947500783a83a132680db1dc55fdc21 Mon Sep 17 00:00:00 2001 From: scop Date: Tue, 22 Mar 2005 16:31:09 +0000 Subject: Sync PIC build fix from 0-2 branch. --- HISTORY | 1 + dxr3cpu.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index f7aca58..a472d98 100644 --- a/HISTORY +++ b/HISTORY @@ -276,3 +276,4 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 - use $CXX for generating dependencies instead of hardcoded g++ (Ville Skyttä) - assume SSE support implies MMXEXT support, this enables optimized memcpy routines on more systems (Ville Skyttä) +- fix compilation with -fPIC, kudos to ffmpeg (Ville Skyttä) diff --git a/dxr3cpu.c b/dxr3cpu.c index 4cd0a7a..3881480 100644 --- a/dxr3cpu.c +++ b/dxr3cpu.c @@ -125,6 +125,13 @@ bool cDxr3CPU::CheckCPUIDPresence() //! cpuid function bool cDxr3CPU::Cpuid(unsigned long function, unsigned long& out_eax, unsigned long& out_ebx, unsigned long& out_ecx, unsigned long& out_edx) { - asm("cpuid": "=a" (out_eax), "=b" (out_ebx), "=c" (out_ecx), "=d" (out_edx) : "a" (function)); + // This works with PIC/non-PIC, from ffmpeg (libavcodec/i386/cputest.c) + __asm __volatile \ + ("movl %%ebx, %%esi\n\t" \ + "cpuid\n\t" \ + "xchgl %%ebx, %%esi" \ + : "=a" (out_eax), "=S" (out_ebx), \ + "=c" (out_ecx), "=d" (out_edx) \ + : "0" (function)); return true; } -- cgit v1.2.3