src/cpuinfo/SDL_cpuinfo.c
changeset 881 9eb85a211abd
parent 804 b2fda076b02e
child 887 b4b64bb88f2f
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Sun Apr 11 19:47:28 2004 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Sun Apr 11 19:49:34 2004 +0000
     1.3 @@ -81,6 +81,26 @@
     1.4  	:
     1.5  	: "%eax", "%ecx"
     1.6  	);
     1.7 +#elif defined(__GNUC__) && defined(__x86_64__)
     1.8 +/* Technically, if this is being compiled under __x86_64__ then it has 
     1.9 +CPUid by definition.  But it's nice to be able to prove it.  :)      */
    1.10 +	__asm__ (
    1.11 +"        pushfq                      # Get original EFLAGS             \n"
    1.12 +"        popq    %%rax                                                 \n"
    1.13 +"        movq    %%rax,%%rcx                                           \n"
    1.14 +"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
    1.15 +"        pushq   %%rax               # Save new EFLAGS value on stack  \n"
    1.16 +"        popfq                       # Replace current EFLAGS value    \n"
    1.17 +"        pushfq                      # Get new EFLAGS                  \n"
    1.18 +"        popq    %%rax               # Store new EFLAGS in EAX         \n"
    1.19 +"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
    1.20 +"        jz      1f                  # Processor=80486                 \n"
    1.21 +"        movl    $1,%0               # We have CPUID support           \n"
    1.22 +"1:                                                                    \n"
    1.23 +	: "=m" (has_CPUID)
    1.24 +	:
    1.25 +	: "%rax", "%rcx"
    1.26 +	);
    1.27  #elif defined(_MSC_VER)
    1.28  	__asm {
    1.29          pushfd                      ; Get original EFLAGS
    1.30 @@ -103,7 +123,7 @@
    1.31  static __inline__ int CPU_getCPUIDFeatures()
    1.32  {
    1.33  	int features = 0;
    1.34 -#if defined(__GNUC__) && defined(i386)
    1.35 +#if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
    1.36  	__asm__ (
    1.37  "        movl    %%ebx,%%edi\n"
    1.38  "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
    1.39 @@ -139,7 +159,7 @@
    1.40  static __inline__ int CPU_getCPUIDFeaturesExt()
    1.41  {
    1.42  	int features = 0;
    1.43 -#if defined(__GNUC__) && defined(i386)
    1.44 +#if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
    1.45  	__asm__ (
    1.46  "        movl    %%ebx,%%edi\n"
    1.47  "        movl    $0x80000000,%%eax   # Query for extended functions    \n"