Skip to content
Permalink
Browse files

Patch from Fedora project to fix crashes with SDL_HasSSE() on amd64.

 Fixes Bugzilla #760. (...and bugzilla.redhat.com #487720).
  • Loading branch information
icculus committed Jul 1, 2009
1 parent aec9e34 commit f4995c3c57e8571d08cc672357c8150f021542e8
Showing with 35 additions and 2 deletions.
  1. +35 −2 src/cpuinfo/SDL_cpuinfo.c
@@ -146,7 +146,7 @@ CPUid by definition. But it's nice to be able to prove it. :) */
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 @@ static __inline__ int CPU_getCPUIDFeatures(void)
:
: "%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_getCPUIDFeatures(void)
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 @@ static __inline__ int CPU_getCPUIDFeaturesExt(void)
:
: "%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

0 comments on commit f4995c3

Please sign in to comment.