src/cpuinfo/SDL_cpuinfo.c
changeset 1361 19418e4422cb
parent 1312 c9b51268668f
child 1402 d910939febfa
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Fri Feb 10 07:29:08 2006 +0000
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Feb 16 10:11:48 2006 +0000
     1.3 @@ -22,16 +22,15 @@
     1.4  
     1.5  /* CPU feature detection for SDL */
     1.6  
     1.7 -#ifdef unix /* FIXME: Better setjmp detection? */
     1.8 -#define USE_SETJMP
     1.9 +#include "SDL.h"
    1.10 +#include "SDL_cpuinfo.h"
    1.11 +
    1.12 +#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
    1.13  #include <signal.h>
    1.14  #include <setjmp.h>
    1.15  #endif
    1.16  
    1.17 -#include "SDL.h"
    1.18 -#include "SDL_cpuinfo.h"
    1.19 -
    1.20 -#ifdef MACOSX
    1.21 +#if MACOSX
    1.22  #include <sys/sysctl.h> /* For AltiVec check */
    1.23  #endif
    1.24  
    1.25 @@ -44,7 +43,7 @@
    1.26  #define CPU_HAS_SSE2	0x00000080
    1.27  #define CPU_HAS_ALTIVEC	0x00000100
    1.28  
    1.29 -#if defined(USE_SETJMP) && defined(GCC_ALTIVEC)
    1.30 +#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
    1.31  /* This is the brute force way of detecting instruction sets...
    1.32     the idea is borrowed from the libmpeg2 library - thanks!
    1.33   */
    1.34 @@ -53,7 +52,7 @@
    1.35  {
    1.36  	longjmp(jmpbuf, 1);
    1.37  }
    1.38 -#endif // USE_SETJMP
    1.39 +#endif /* HAVE_SETJMP */
    1.40  
    1.41  static __inline__ int CPU_haveCPUID()
    1.42  {
    1.43 @@ -112,18 +111,18 @@
    1.44  done:
    1.45  	}
    1.46  #elif defined(__sun) && defined(__x86)
    1.47 -	    __asm (
    1.48 +	__asm (
    1.49  "       pushfl                 \n"
    1.50 -"	    popl    %eax           \n"
    1.51 -"	    movl    %eax,%ecx      \n"
    1.52 -"	    xorl    $0x200000,%eax \n"
    1.53 -"	    pushl   %eax           \n"
    1.54 -"	    popfl                  \n"
    1.55 -"	    pushfl                 \n"
    1.56 -"	    popl    %eax           \n"
    1.57 -"	    xorl    %ecx,%eax      \n"
    1.58 -"	    jz      1f             \n"
    1.59 -"	    movl    $1,-8(%ebp)    \n"
    1.60 +"	popl    %eax           \n"
    1.61 +"	movl    %eax,%ecx      \n"
    1.62 +"	xorl    $0x200000,%eax \n"
    1.63 +"	pushl   %eax           \n"
    1.64 +"	popfl                  \n"
    1.65 +"	pushfl                 \n"
    1.66 +"	popl    %eax           \n"
    1.67 +"	xorl    %ecx,%eax      \n"
    1.68 +"	jz      1f             \n"
    1.69 +"	movl    $1,-8(%ebp)    \n"
    1.70  "1:                            \n"
    1.71  	);
    1.72  #elif defined(__sun) && defined(__amd64)
    1.73 @@ -308,14 +307,14 @@
    1.74  static __inline__ int CPU_haveAltiVec()
    1.75  {
    1.76  	volatile int altivec = 0;
    1.77 -#ifdef MACOSX
    1.78 +#if MACOSX
    1.79  	int selectors[2] = { CTL_HW, HW_VECTORUNIT }; 
    1.80  	int hasVectorUnit = 0; 
    1.81  	size_t length = sizeof(hasVectorUnit); 
    1.82  	int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); 
    1.83  	if( 0 == error )
    1.84  		altivec = (hasVectorUnit != 0); 
    1.85 -#elif defined(USE_SETJMP) && defined(GCC_ALTIVEC)
    1.86 +#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
    1.87  	void (*handler)(int sig);
    1.88  	handler = signal(SIGILL, illegal_instruction);
    1.89  	if ( setjmp(jmpbuf) == 0 ) {