X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fcpu.c;h=a5a0c8dce8bfadf625f97c5a4e5fd61440184744;hb=50eabda652cd9581b0d0c8e94017faa092db0d50;hp=41206685792de83f356b63584a42ec4f8fe8b944;hpb=145b1961b4825d2a8d807bf02db90440a8c45380;p=vlc diff --git a/src/misc/cpu.c b/src/misc/cpu.c index 4120668579..a5a0c8dce8 100644 --- a/src/misc/cpu.c +++ b/src/misc/cpu.c @@ -2,7 +2,7 @@ * cpu.c: CPU detection code ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: cpu.c,v 1.7 2002/10/03 13:21:55 sam Exp $ + * $Id: cpu.c,v 1.10 2002/12/06 16:34:08 sam Exp $ * * Authors: Samuel Hocevar * Christophe Massiot @@ -26,11 +26,13 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* SIGHUP, SIGINT, SIGKILL */ -#include /* longjmp, setjmp */ - #include +#ifdef HAVE_SIGNAL_H +# include /* SIGHUP, SIGINT, SIGKILL */ +# include /* longjmp, setjmp */ +#endif + #ifdef SYS_DARWIN # include /* AltiVec detection */ # include /* some day the header files||compiler * @@ -43,25 +45,29 @@ /***************************************************************************** * Local prototypes *****************************************************************************/ +#ifdef HAVE_SIGNAL_H static void SigHandler ( int ); +#endif /***************************************************************************** * Global variables - they're needed for signal handling *****************************************************************************/ +#ifdef HAVE_SIGNAL_H static jmp_buf env; static int i_illegal; #if defined( __i386__ ) static char *psz_capability; #endif +#endif /***************************************************************************** * CPUCapabilities: get the CPU capabilities ***************************************************************************** * This function is called to list extensions the CPU may have. *****************************************************************************/ -u32 CPUCapabilities( void ) +uint32_t CPUCapabilities( void ) { - volatile u32 i_capabilities = CPU_CAPABILITY_NONE; + volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE; #if defined( SYS_DARWIN ) struct host_basic_info hi; @@ -100,7 +106,7 @@ u32 CPUCapabilities( void ) volatile vlc_bool_t b_amd; /* Needed for x86 CPU capabilities detection */ -# define cpuid( a ) \ +# define cpuid( reg ) \ asm volatile ( "pushl %%ebx\n\t" \ "cpuid\n\t" \ "movl %%ebx,%1\n\t" \ @@ -109,10 +115,11 @@ u32 CPUCapabilities( void ) "=r" ( i_ebx ), \ "=c" ( i_ecx ), \ "=d" ( i_edx ) \ - : "a" ( a ) \ + : "a" ( reg ) \ : "cc" ); -# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) +# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) \ + && defined( HAVE_SIGNAL_H ) void (*pf_sigill) (int) = signal( SIGILL, SigHandler ); # endif @@ -137,7 +144,8 @@ u32 CPUCapabilities( void ) if( i_eax == i_ebx ) { -# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) +# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) \ + && defined( HAVE_SIGNAL_H ) signal( SIGILL, pf_sigill ); # endif return i_capabilities; @@ -150,7 +158,8 @@ u32 CPUCapabilities( void ) if( !i_eax ) { -# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) +# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) \ + && defined( HAVE_SIGNAL_H ) signal( SIGILL, pf_sigill ); # endif return i_capabilities; @@ -168,7 +177,8 @@ u32 CPUCapabilities( void ) if( ! (i_edx & 0x00800000) ) { -# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) +# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) \ + && defined( HAVE_SIGNAL_H ) signal( SIGILL, pf_sigill ); # endif return i_capabilities; @@ -203,7 +213,8 @@ u32 CPUCapabilities( void ) if( i_eax < 0x80000001 ) { -# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) +# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) \ + && defined( HAVE_SIGNAL_H ) signal( SIGILL, pf_sigill ); # endif return i_capabilities; @@ -236,14 +247,15 @@ u32 CPUCapabilities( void ) i_capabilities |= CPU_CAPABILITY_MMXEXT; } -# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) +# if defined( CAN_COMPILE_SSE ) || defined ( CAN_COMPILE_3DNOW ) \ + && defined( HAVE_SIGNAL_H ) signal( SIGILL, pf_sigill ); # endif return i_capabilities; #elif defined( __powerpc__ ) -# ifdef CAN_COMPILE_ALTIVEC +# ifdef CAN_COMPILE_ALTIVEC && defined( HAVE_SIGNAL_H ) void (*pf_sigill) (int) = signal( SIGILL, SigHandler ); i_capabilities |= CPU_CAPABILITY_FPU; @@ -286,6 +298,7 @@ u32 CPUCapabilities( void ) * This function is called when an illegal instruction signal is received by * the program. We use this function to test OS and CPU capabilities *****************************************************************************/ +#if defined( HAVE_SIGNAL_H ) static void SigHandler( int i_signal ) { /* Acknowledge the signal received */ @@ -307,4 +320,5 @@ static void SigHandler( int i_signal ) longjmp( env, 1 ); } +#endif