Fixed cpuid assembly to work on PIC code
authorSam Lantinga <slouken@libsdl.org>
Wed, 16 Dec 2009 16:42:04 +0000
changeset 358441d01d70659c
parent 3583 65f66674b7fb
child 3585 f8816ffa210b
Fixed cpuid assembly to work on PIC code
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Wed Dec 16 16:08:17 2009 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Wed Dec 16 16:42:04 2009 +0000
     1.3 @@ -122,16 +122,16 @@
     1.4  #elif defined(__sun) && defined(__i386)
     1.5      __asm (
     1.6  "       pushfl                 \n"
     1.7 -"   popl    %eax           \n"
     1.8 -"   movl    %eax,%ecx      \n"
     1.9 -"   xorl    $0x200000,%eax \n"
    1.10 -"   pushl   %eax           \n"
    1.11 -"   popfl                  \n"
    1.12 -"   pushfl                 \n"
    1.13 -"   popl    %eax           \n"
    1.14 -"   xorl    %ecx,%eax      \n"
    1.15 -"   jz      1f             \n"
    1.16 -"   movl    $1,-8(%ebp)    \n"
    1.17 +"       popl    %eax           \n"
    1.18 +"       movl    %eax,%ecx      \n"
    1.19 +"       xorl    $0x200000,%eax \n"
    1.20 +"       pushl   %eax           \n"
    1.21 +"       popfl                  \n"
    1.22 +"       pushfl                 \n"
    1.23 +"       popl    %eax           \n"
    1.24 +"       xorl    %ecx,%eax      \n"
    1.25 +"       jz      1f             \n"
    1.26 +"       movl    $1,-8(%ebp)    \n"
    1.27  "1:                            \n"
    1.28      );
    1.29  #elif defined(__sun) && defined(__amd64)
    1.30 @@ -156,8 +156,12 @@
    1.31  
    1.32  #if defined(__GNUC__) && (defined(i386) || defined(__x86_64__))
    1.33  #define cpuid(func, a, b, c, d) \
    1.34 -    __asm__ __volatile__ ("cpuid": \
    1.35 -    "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (func))
    1.36 +    __asm__ __volatile__ ( \
    1.37 +"        pushl %%ebx        \n" \
    1.38 +"        cpuid              \n" \
    1.39 +"        movl %%ebx, %%esi  \n" \
    1.40 +"        popl %%ebx         \n" : \
    1.41 +            "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func))
    1.42  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    1.43  #define cpuid(func, a, b, c, d) \
    1.44      __asm { \