Commit e1a4ae9e authored by Sam Hocevar's avatar Sam Hocevar

* common/cpu.c: runtime AltiVec autodetection on Linux.

  * configure, Makefile: do not build the whole project with -maltivec because
    it generates AltiVec code in weird places.


git-svn-id: svn://svn.videolan.org/x264/trunk@629 df754926-b1dd-0310-bc7b-ec298dee348c
parent f81c3eaf
......@@ -43,8 +43,10 @@ endif
# AltiVec optims
ifeq ($(ARCH),PPC)
SRCS += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
common/ppc/quant.c
ALTIVECSRC += common/ppc/mc.c common/ppc/pixel.c common/ppc/dct.c \
common/ppc/quant.c
SRCS += $(ALTIVECSRC)
$(ALTIVECSRC:%.c=%.o): CFLAGS += $(ALTIVECFLAGS)
endif
# VIS optims
......
......@@ -132,9 +132,43 @@ uint32_t x264_cpu_detect( void )
}
#elif defined( SYS_LINUX )
#include <signal.h>
#include <setjmp.h>
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 );
}
uint32_t x264_cpu_detect( void )
{
/* FIXME (Linux PPC) */
static void (* oldsig)( int );
oldsig = signal( SIGILL, sigill_handler );
if( sigsetjmp( jmpbuf, 1 ) )
{
signal( SIGILL, oldsig );
return 0;
}
canjump = 1;
asm volatile( "mtspr 256, %0\n\t"
"vand 0, 0, 0\n\t"
:
: "r"(-1) );
canjump = 0;
signal( SIGILL, oldsig );
return X264_CPU_ALTIVEC;
}
#endif
......
......@@ -161,9 +161,9 @@ case "${MACHINE%%-*}" in
ARCH="PPC"
if [ $SYS = MACOSX ]
then
CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
else
CFLAGS="$CFLAGS -maltivec -mabi=altivec"
ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec"
fi
;;
sparc)
......@@ -385,6 +385,7 @@ ARCH=$ARCH
SYS=$SYS
CC=$CC
CFLAGS=$CFLAGS
ALTIVECFLAGS=$ALTIVECFLAGS
LDFLAGS=$LDFLAGS
AS=$AS
ASFLAGS=$ASFLAGS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment