diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-12-08 01:19:54 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-12-08 01:19:54 +0000 |
commit | 2887e16506cf5bcb6bf848e2155216b470ef67f0 (patch) | |
tree | 78d82bdad8fb1d49988e503d58b998e2c7e376c6 | |
parent | 08f2c64473ba4dac063e3cc66011b0b2320065ca (diff) | |
download | xine-lib-2887e16506cf5bcb6bf848e2155216b470ef67f0.tar.gz xine-lib-2887e16506cf5bcb6bf848e2155216b470ef67f0.tar.bz2 |
improved altivec detection by Bill Fink <billfink@mindspring.com>
CVS patchset: 1178
CVS date: 2001/12/08 01:19:54
-rw-r--r-- | src/xine-utils/cpu_accel.c | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/xine-utils/cpu_accel.c b/src/xine-utils/cpu_accel.c index 41baa5d5e..03e047aa0 100644 --- a/src/xine-utils/cpu_accel.c +++ b/src/xine-utils/cpu_accel.c @@ -30,7 +30,7 @@ #include "xineutils.h" #ifdef ARCH_X86 -static uint32_t x86_accel (void) +static uint32_t arch_accel (void) { uint32_t eax, ebx, ecx, edx; int AMD; @@ -108,8 +108,6 @@ static uint32_t x86_accel (void) return caps; } -#endif - static jmp_buf sigill_return; @@ -117,14 +115,51 @@ static void sigill_handler (int n) { printf ("cpu_accel: OS doesn't support SSE instructions.\n"); longjmp(sigill_return, 1); } +#endif /* ARCH_X86 */ + +#if defined (ARCH_PPC) && defined (ENABLE_ALTIVEC) +static sigjmp_buf jmpbuf; +static volatile sig_atomic_t canjump = 0; + +static void sigill_handler (int sig) +{ + if (!canjump) { + signal (sig, SIG_DFL); + raise (sig); + } + + canjump = 0; + siglongjmp (jmpbuf, 1); +} + +static uint32_t arch_accel (void) +{ + signal (SIGILL, sigill_handler); + if (sigsetjmp (jmpbuf, 1)) { + signal (SIGILL, SIG_DFL); + return 0; + } + + canjump = 1; + + asm volatile ("mtspr 256, %0\n\t" + "vand %%v0, %%v0, %%v0" + : + : "r" (-1)); + + signal (SIGILL, SIG_DFL); + return MM_ACCEL_PPC_ALTIVEC; +} +#endif /* ARCH_PPC */ uint32_t xine_mm_accel (void) { -#ifdef ARCH_X86 +#if defined (ARCH_X86) || (defined (ARCH_PPC) && defined (ENABLE_ALTIVEC)) static uint32_t accel; - accel = x86_accel (); + accel = arch_accel (); +#ifdef ARCH_X86 /* test OS support for SSE */ if( accel & MM_ACCEL_X86_SSE ) { if (setjmp(sigill_return)) { @@ -135,17 +170,16 @@ uint32_t xine_mm_accel (void) signal (SIGILL, SIG_DFL); } } +#endif /* ARCH_X86 */ return accel; -#endif + +#else /* !ARCH_X86 && !ARCH_PPC/ENABLE_ALTIVEC */ #ifdef HAVE_MLIB return MM_ACCEL_MLIB; -#endif -#ifdef ARCH_PPC -#ifdef ENABLE_ALTIVEC - return MM_ACCEL_PPC_ALTIVEC; -#endif -#endif +#else return 0; +#endif +#endif /* !ARCH_X86 && !ARCH_PPC/ENABLE_ALTIVEC */ } |