Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed cpuid assembly to work on PIC code
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 16, 2009
1 parent 2ffecc5 commit a202aef
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/cpuinfo/SDL_cpuinfo.c
Expand Up @@ -122,16 +122,16 @@ CPUid by definition. But it's nice to be able to prove it. :) */
#elif defined(__sun) && defined(__i386)
__asm (
" pushfl \n"
" popl %eax \n"
" movl %eax,%ecx \n"
" xorl $0x200000,%eax \n"
" pushl %eax \n"
" popfl \n"
" pushfl \n"
" popl %eax \n"
" xorl %ecx,%eax \n"
" jz 1f \n"
" movl $1,-8(%ebp) \n"
" popl %eax \n"
" movl %eax,%ecx \n"
" xorl $0x200000,%eax \n"
" pushl %eax \n"
" popfl \n"
" pushfl \n"
" popl %eax \n"
" xorl %ecx,%eax \n"
" jz 1f \n"
" movl $1,-8(%ebp) \n"
"1: \n"
);
#elif defined(__sun) && defined(__amd64)
Expand All @@ -156,8 +156,12 @@ CPUid by definition. But it's nice to be able to prove it. :) */

#if defined(__GNUC__) && (defined(i386) || defined(__x86_64__))
#define cpuid(func, a, b, c, d) \
__asm__ __volatile__ ("cpuid": \
"=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (func))
__asm__ __volatile__ ( \
" pushl %%ebx \n" \
" cpuid \n" \
" movl %%ebx, %%esi \n" \
" popl %%ebx \n" : \
"=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func))
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
#define cpuid(func, a, b, c, d) \
__asm { \
Expand Down

0 comments on commit a202aef

Please sign in to comment.