]> git.sesse.net Git - vlc/blobdiff - src/misc/cpu.c
* added a vlc_current_charset function. This tries to get the current charset
[vlc] / src / misc / cpu.c
index 41206685792de83f356b63584a42ec4f8fe8b944..4bb301f463b45f37a2d37a19d4bd51403e01b02d 100644 (file)
@@ -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.11 2003/05/22 12:00:57 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <signal.h>                               /* SIGHUP, SIGINT, SIGKILL */
-#include <setjmp.h>                                       /* longjmp, setjmp */
-
 #include <vlc/vlc.h>
 
+#ifdef HAVE_SIGNAL_H
+#   include <signal.h>                            /* SIGHUP, SIGINT, SIGKILL */
+#   include <setjmp.h>                                    /* longjmp, setjmp */
+#endif
+
 #ifdef SYS_DARWIN
 #   include <mach/mach.h>                               /* AltiVec detection */
 #   include <mach/mach_error.h>       /* some day the header files||compiler *
 /*****************************************************************************
  * 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;
@@ -273,6 +285,10 @@ u32 CPUCapabilities( void )
     i_capabilities |= CPU_CAPABILITY_FPU;
     return i_capabilities;
 
+#elif defined( _MSC_VER )
+    i_capabilities |= CPU_CAPABILITY_FPU;
+    return i_capabilities;
+
 #else
     /* default behaviour */
     return i_capabilities;
@@ -286,6 +302,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 +324,5 @@ static void SigHandler( int i_signal )
 
     longjmp( env, 1 );
 }
+#endif