]> git.sesse.net Git - vlc/blobdiff - src/misc/cpu.c
fix compilation on Linux
[vlc] / src / misc / cpu.c
index 8bc3aa2bae951e7338cd95aaa58316eda2c6dcfc..611adad381eb0e313aed1da57c942b6da42f1aa6 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * cpu.c: CPU detection code
  *****************************************************************************
- * Copyright (C) 1998-2004 VideoLAN
+ * Copyright (C) 1998-2004 the VideoLAN team
  * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
@@ -20,7 +20,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
 #   include <setjmp.h>                                    /* longjmp, setjmp */
 #endif
 
-#ifdef SYS_DARWIN
+#include "libvlc.h"
+
+#if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__))
 #include <sys/sysctl.h>
 #endif
 
-#include "vlc_cpu.h"
-
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -53,7 +53,7 @@ static void SigHandler   ( int );
 static jmp_buf env;
 static int     i_illegal;
 #if defined( __i386__ ) || defined( __x86_64__ )
-static char   *psz_capability;
+static const char *psz_capability;
 #endif
 #endif
 
@@ -66,7 +66,7 @@ uint32_t CPUCapabilities( void )
 {
     volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE;
 
-#if defined( SYS_DARWIN )
+#if defined(__APPLE__) && (defined(__ppc__) || defined(__ppc64__))
     int selectors[2] = { CTL_HW, HW_VECTORUNIT };
     int i_has_altivec = 0;
     size_t i_length = sizeof( i_has_altivec );
@@ -86,12 +86,10 @@ uint32_t CPUCapabilities( void )
     /* Needed for x86 CPU capabilities detection */
 #   if defined( __x86_64__ )
 #       define cpuid( reg )                    \
-            asm volatile ( "push %%rbx\n\t"    \
-                           "cpuid\n\t"         \
+            asm volatile ( "cpuid\n\t"         \
                            "movl %%ebx,%1\n\t" \
-                           "pop %%rbx\n\t"     \
                          : "=a" ( i_eax ),     \
-                           "=r" ( i_ebx ),     \
+                           "=b" ( i_ebx ),     \
                            "=c" ( i_ecx ),     \
                            "=d" ( i_edx )      \
                          : "a"  ( reg )        \
@@ -269,7 +267,7 @@ uint32_t CPUCapabilities( void )
 #   endif
     return i_capabilities;
 
-#elif defined( __powerpc__ )
+#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
 
 #   ifdef CAN_COMPILE_ALTIVEC && defined( HAVE_SIGNAL_H )
     void (*pf_sigill) (int) = signal( SIGILL, SigHandler );
@@ -342,3 +340,15 @@ static void SigHandler( int i_signal )
 }
 #endif
 
+
+uint32_t cpu_flags = 0;
+
+
+/*****************************************************************************
+ * vlc_CPU: get pre-computed CPU capability flags
+ ****************************************************************************/
+unsigned vlc_CPU (void)
+{
+    return cpu_flags;
+}
+