Index: common/cpu.c =================================================================== --- common/cpu.c (revision 627) +++ common/cpu.c (working copy) @@ -32,6 +32,10 @@ #include #include #endif +#ifdef SYS_LINUX +#include +#include +#endif #include @@ -111,7 +115,20 @@ } #elif defined( ARCH_PPC ) +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); +} + #ifdef SYS_MACOSX #include uint32_t x264_cpu_detect( void ) @@ -134,8 +151,22 @@ #elif defined( SYS_LINUX ) uint32_t x264_cpu_detect( void ) { - /* FIXME (Linux PPC) */ - return X264_CPU_ALTIVEC; + signal (SIGILL, sigill_handler); + if (sigsetjmp (jmpbuf, 1)) { + signal (SIGILL, SIG_DFL); + } else { + canjump = 1; + + asm volatile ("mtspr 256, %0\n\t" + "vand %%v0, %%v0, %%v0" + : + : "r" (-1)); + + signal (SIGILL, SIG_DFL); + return X264_CPU_ALTIVEC; + } + } + return 0; } #endif