Mercurial > sdl-ios-xcode
diff src/cpuinfo/SDL_cpuinfo.c @ 4180:0a9a29fc00c2 SDL-1.2
Patch from Fedora project to fix crashes with SDL_HasSSE() on amd64.
Fixes Bugzilla #760. (...and bugzilla.redhat.com #487720).
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 01 Jul 2009 19:06:31 +0000 |
parents | a1b03ba2fcd0 |
children | fa62bede8038 |
line wrap: on
line diff
--- a/src/cpuinfo/SDL_cpuinfo.c Thu May 07 12:40:16 2009 +0000 +++ b/src/cpuinfo/SDL_cpuinfo.c Wed Jul 01 19:06:31 2009 +0000 @@ -146,7 +146,7 @@ static __inline__ int CPU_getCPUIDFeatures(void) { int features = 0; -#if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) ) +#if defined(__GNUC__) && defined(i386) __asm__ ( " movl %%ebx,%%edi\n" " xorl %%eax,%%eax # Set up for CPUID instruction \n" @@ -163,6 +163,23 @@ : : "%eax", "%ecx", "%edx", "%edi" ); +#elif defined(__GNUC__) && defined(__x86_64__) + __asm__ ( +" movq %%rbx,%%rdi\n" +" xorl %%eax,%%eax # Set up for CPUID instruction \n" +" cpuid # Get and save vendor ID \n" +" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n" +" jl 1f # We dont have the CPUID instruction\n" +" xorl %%eax,%%eax \n" +" incl %%eax \n" +" cpuid # Get family/model/stepping/features\n" +" movl %%edx,%0 \n" +"1: \n" +" movq %%rdi,%%rbx\n" + : "=m" (features) + : + : "%rax", "%rcx", "%rdx", "%rdi" + ); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { xor eax, eax ; Set up for CPUID instruction @@ -199,7 +216,7 @@ static __inline__ int CPU_getCPUIDFeaturesExt(void) { int features = 0; -#if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) ) +#if defined(__GNUC__) && defined(i386) __asm__ ( " movl %%ebx,%%edi\n" " movl $0x80000000,%%eax # Query for extended functions \n" @@ -215,6 +232,22 @@ : : "%eax", "%ecx", "%edx", "%edi" ); +#elif defined(__GNUC__) && defined (__x86_64__) + __asm__ ( +" movq %%rbx,%%rdi\n" +" movl $0x80000000,%%eax # Query for extended functions \n" +" cpuid # Get extended function limit \n" +" cmpl $0x80000001,%%eax \n" +" jl 1f # Nope, we dont have function 800000001h\n" +" movl $0x80000001,%%eax # Setup extended function 800000001h\n" +" cpuid # and get the information \n" +" movl %%edx,%0 \n" +"1: \n" +" movq %%rdi,%%rbx\n" + : "=m" (features) + : + : "%rax", "%rcx", "%rdx", "%rdi" + ); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { mov eax,80000000h ; Query for extended functions