# HG changeset patch # User Sam Lantinga # Date 1259610754 0 # Node ID a4ce84c4f21103f9dfb0b5ed30ca6a4566824bdc # Parent 74d2f44a85de46146ded3ac1e2641aa1ee0638c5 Fixed crash - need to save and restore rbx around cpuid, since the compiler may be assuming the stack pointer isn't being modified when filling in %0. I did it around each call to cpuid which isn't strictly necessary, but is definitely future proof. :) diff -r 74d2f44a85de -r a4ce84c4f211 src/cpuinfo/SDL_cpuinfo.c --- a/src/cpuinfo/SDL_cpuinfo.c Mon Nov 30 17:57:12 2009 +0000 +++ b/src/cpuinfo/SDL_cpuinfo.c Mon Nov 30 19:52:34 2009 +0000 @@ -170,17 +170,19 @@ ); #elif defined(__GNUC__) && defined(__x86_64__) __asm__ ( +" xorl %%eax,%%eax # Set up for CPUID instruction \n" " pushq %%rbx\n" -" xorl %%eax,%%eax # Set up for CPUID instruction \n" " cpuid # Get and save vendor ID \n" +" popq %%rbx\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" +" pushq %%rbx\n" " cpuid # Get family/model/stepping/features\n" +" popq %%rbx\n" " movl %%edx,%0 \n" "1: \n" -" popq %%rbx\n" : "=m" (features) : : "%rax", "%rcx", "%rdx" @@ -242,16 +244,18 @@ ); #elif defined(__GNUC__) && defined (__x86_64__) __asm__ ( +" movl $0x80000000,%%eax # Query for extended functions \n" " pushq %%rbx\n" -" movl $0x80000000,%%eax # Query for extended functions \n" " cpuid # Get extended function limit \n" +" popq %%rbx\n" " cmpl $0x80000001,%%eax \n" " jl 1f # Nope, we dont have function 800000001h\n" " movl $0x80000001,%%eax # Setup extended function 800000001h\n" +" pushq %%rbx\n" " cpuid # and get the information \n" +" popq %%rbx\n" " movl %%edx,%0 \n" "1: \n" -" popq %%rbx\n" : "=m" (features) : : "%rax", "%rcx", "%rdx"