Check for altivec assembly support before trying to use it. :)
authorSam Lantinga <slouken@libsdl.org>
Thu, 29 Jan 2004 16:15:12 +0000
changeset 795275708f2e838
parent 794 a5defa3b93e1
child 796 dec19b813b04
Check for altivec assembly support before trying to use it. :)
configure.in
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/configure.in	Thu Jan 29 16:14:09 2004 +0000
     1.2 +++ b/configure.in	Thu Jan 29 16:15:12 2004 +0000
     1.3 @@ -1723,15 +1723,35 @@
     1.4      fi
     1.5  }
     1.6  
     1.7 +dnl Check for altivec instruction support using gas syntax
     1.8 +CheckAltivec()
     1.9 +{
    1.10 +    AC_MSG_CHECKING(for GCC Altivec instruction support)
    1.11 +    have_gcc_altivec=no
    1.12 +    AC_TRY_COMPILE([
    1.13 +    ],[
    1.14 +        asm volatile ("mtspr 256, %0\n\t"
    1.15 +                      "vand %%v0, %%v0, %%v0"
    1.16 +                      :
    1.17 +                      : "r" (-1));
    1.18 +    ],[
    1.19 +    have_gcc_altivec=yes
    1.20 +    ])
    1.21 +    if test x$have_gcc_altivec = xyes; then
    1.22 +        CFLAGS="$CFLAGS -DGCC_ALTIVEC"
    1.23 +    fi
    1.24 +    AC_MSG_RESULT($have_gcc_altivec)
    1.25 +}
    1.26 +
    1.27  case "$target" in
    1.28      *-*-linux*|*-*-gnu*|*-*-k*bsd*-gnu)
    1.29          case "$target" in
    1.30 -	  *-*-linux*) ARCH=linux ;;
    1.31 -	  *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;;
    1.32 -	  *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;;
    1.33 -	  *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;;
    1.34 -	  *-*-gnu*) ARCH=gnu ;; # must be last
    1.35 -	esac
    1.36 +          *-*-linux*) ARCH=linux ;;
    1.37 +          *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;;
    1.38 +          *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;;
    1.39 +          *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;;
    1.40 +          *-*-gnu*) ARCH=gnu ;; # must be last
    1.41 +        esac
    1.42          CheckDummyVideo
    1.43          CheckDiskAudio
    1.44          CheckDLOPEN
    1.45 @@ -1755,6 +1775,7 @@
    1.46          CheckOpenGL
    1.47          CheckInputEvents
    1.48          CheckPTHREAD
    1.49 +        CheckAltivec
    1.50          # Set up files for the main() stub
    1.51          if test "x$video_qtopia" = "xyes"; then
    1.52            SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
     2.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 29 16:14:09 2004 +0000
     2.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 29 16:15:12 2004 +0000
     2.3 @@ -236,7 +236,7 @@
     2.4  	int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); 
     2.5  	if( 0 == error )
     2.6  		altivec = (hasVectorUnit != 0); 
     2.7 -#elseif defined(USE_SETJMP) && defined(__GNUC__) && defined(__powerpc__)
     2.8 +#elif defined(USE_SETJMP) && defined(GCC_ALTIVEC)
     2.9  	void (*handler)(int sig);
    2.10  	handler = signal(SIGILL, illegal_instruction);
    2.11  	if ( setjmp(jmpbuf) == 0 ) {