src/cpuinfo/SDL_cpuinfo.c
branchSDL-1.2
changeset 4180 0a9a29fc00c2
parent 4159 a1b03ba2fcd0
child 4242 fa62bede8038
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu May 07 12:40:16 2009 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Wed Jul 01 19:06:31 2009 +0000
     1.3 @@ -146,7 +146,7 @@
     1.4  static __inline__ int CPU_getCPUIDFeatures(void)
     1.5  {
     1.6  	int features = 0;
     1.7 -#if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
     1.8 +#if defined(__GNUC__) && defined(i386)
     1.9  	__asm__ (
    1.10  "        movl    %%ebx,%%edi\n"
    1.11  "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
    1.12 @@ -163,6 +163,23 @@
    1.13  	:
    1.14  	: "%eax", "%ecx", "%edx", "%edi"
    1.15  	);
    1.16 +#elif defined(__GNUC__) && defined(__x86_64__)
    1.17 +	__asm__ (
    1.18 +"        movq    %%rbx,%%rdi\n"
    1.19 +"        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
    1.20 +"        cpuid                       # Get and save vendor ID          \n"
    1.21 +"        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
    1.22 +"        jl      1f                  # We dont have the CPUID instruction\n"
    1.23 +"        xorl    %%eax,%%eax                                           \n"
    1.24 +"        incl    %%eax                                                 \n"
    1.25 +"        cpuid                       # Get family/model/stepping/features\n"
    1.26 +"        movl    %%edx,%0                                              \n"
    1.27 +"1:                                                                    \n"
    1.28 +"        movq    %%rdi,%%rbx\n"
    1.29 +	: "=m" (features)
    1.30 +	:
    1.31 +	: "%rax", "%rcx", "%rdx", "%rdi"
    1.32 +	);
    1.33  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    1.34  	__asm {
    1.35          xor     eax, eax            ; Set up for CPUID instruction
    1.36 @@ -199,7 +216,7 @@
    1.37  static __inline__ int CPU_getCPUIDFeaturesExt(void)
    1.38  {
    1.39  	int features = 0;
    1.40 -#if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
    1.41 +#if defined(__GNUC__) && defined(i386)
    1.42  	__asm__ (
    1.43  "        movl    %%ebx,%%edi\n"
    1.44  "        movl    $0x80000000,%%eax   # Query for extended functions    \n"
    1.45 @@ -215,6 +232,22 @@
    1.46  	:
    1.47  	: "%eax", "%ecx", "%edx", "%edi"
    1.48  	);
    1.49 +#elif defined(__GNUC__) && defined (__x86_64__)
    1.50 +	__asm__ (
    1.51 +"        movq    %%rbx,%%rdi\n"
    1.52 +"        movl    $0x80000000,%%eax   # Query for extended functions    \n"
    1.53 +"        cpuid                       # Get extended function limit     \n"
    1.54 +"        cmpl    $0x80000001,%%eax                                     \n"
    1.55 +"        jl      1f                  # Nope, we dont have function 800000001h\n"
    1.56 +"        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n"
    1.57 +"        cpuid                       # and get the information         \n"
    1.58 +"        movl    %%edx,%0                                              \n"
    1.59 +"1:                                                                    \n"
    1.60 +"        movq    %%rdi,%%rbx\n"
    1.61 +	: "=m" (features)
    1.62 +	:
    1.63 +	: "%rax", "%rcx", "%rdx", "%rdi"
    1.64 +	);
    1.65  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    1.66  	__asm {
    1.67          mov     eax,80000000h       ; Query for extended functions