Commit 7d38d7ef authored by Ryan C. Gordon's avatar Ryan C. Gordon

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

 Fixes Bugzilla #760. (...and bugzilla.redhat.com #487720).

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%403683
parent a220b6ab
...@@ -146,7 +146,7 @@ done: ...@@ -146,7 +146,7 @@ done:
static __inline__ int CPU_getCPUIDFeatures(void) static __inline__ int CPU_getCPUIDFeatures(void)
{ {
int features = 0; int features = 0;
#if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) ) #if defined(__GNUC__) && defined(i386)
__asm__ ( __asm__ (
" movl %%ebx,%%edi\n" " movl %%ebx,%%edi\n"
" xorl %%eax,%%eax # Set up for CPUID instruction \n" " xorl %%eax,%%eax # Set up for CPUID instruction \n"
...@@ -163,6 +163,23 @@ static __inline__ int CPU_getCPUIDFeatures(void) ...@@ -163,6 +163,23 @@ static __inline__ int CPU_getCPUIDFeatures(void)
: :
: "%eax", "%ecx", "%edx", "%edi" : "%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__) #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
__asm { __asm {
xor eax, eax ; Set up for CPUID instruction xor eax, eax ; Set up for CPUID instruction
...@@ -199,7 +216,7 @@ done: ...@@ -199,7 +216,7 @@ done:
static __inline__ int CPU_getCPUIDFeaturesExt(void) static __inline__ int CPU_getCPUIDFeaturesExt(void)
{ {
int features = 0; int features = 0;
#if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) ) #if defined(__GNUC__) && defined(i386)
__asm__ ( __asm__ (
" movl %%ebx,%%edi\n" " movl %%ebx,%%edi\n"
" movl $0x80000000,%%eax # Query for extended functions \n" " movl $0x80000000,%%eax # Query for extended functions \n"
...@@ -215,6 +232,22 @@ static __inline__ int CPU_getCPUIDFeaturesExt(void) ...@@ -215,6 +232,22 @@ static __inline__ int CPU_getCPUIDFeaturesExt(void)
: :
: "%eax", "%ecx", "%edx", "%edi" : "%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__) #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
__asm { __asm {
mov eax,80000000h ; Query for extended functions mov eax,80000000h ; Query for extended functions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment