]> git.sesse.net Git - vlc/blobdiff - src/misc/tests.c
* Fixed the BeOS compile typo.
[vlc] / src / misc / tests.c
index 095f2a71e45df369a6a270b797c4a6ad9ec339b2..4ffb2c4a8ed0dfe52dd89100b5facb3c15decdcb 100644 (file)
@@ -3,6 +3,7 @@
  * Functions are prototyped in tests.h.
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
+ * $Id: tests.c,v 1.7 2001/05/30 17:03:12 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@via.ecp.fr>
  *
@@ -26,6 +27,8 @@
  *****************************************************************************/
 #include "defs.h"
 
+#include <string.h>                                    /* memcpy(), memset() */
+
 #include "config.h"
 #include "common.h"
 
 
 #include "main.h"
 
-/*****************************************************************************
- * TestVersion: tests if the given string equals the current version
- *****************************************************************************/
-int TestVersion( char * psz_version )
-{
-    return( !strcmp( psz_version, VERSION ) );
-}
-
 /*****************************************************************************
  * TestProgram: tests if the given string equals the program name
  *****************************************************************************/
@@ -59,84 +54,10 @@ int TestMethod( char * psz_var, char * psz_method )
 }
 
 /*****************************************************************************
- * TestMMX: tests if the processor has MMX support.
- *****************************************************************************
- * This function is called if HAVE_MMX is enabled, to check whether the
- * CPU really supports MMX.
+ * TestCPU: tests if the processor has MMX support and other capabilities
  *****************************************************************************/
-int TestMMX( void )
+int TestCPU( int i_capabilities )
 {
-#ifndef __i386__
-    return( 0 );
-#else
-/* FIXME: under beos, gcc does not support the following inline assembly */ 
-#ifdef SYS_BEOS
-    return( 1 );
-#else
-
-    int i_reg, i_dummy = 0;
-
-    /* test for a 386 CPU */
-    asm volatile ( "pushfl
-                    popl %%eax
-                    movl %%eax, %%ecx
-                    xorl $0x40000, %%eax
-                    pushl %%eax
-                    popfl
-                    pushfl
-                    popl %%eax
-                    xorl %%ecx, %%eax
-                    andl $0x40000, %%eax"
-                 : "=a" ( i_reg ) );
-
-    if( !i_reg )
-        return( 0 );
-
-    /* test for a 486 CPU */
-    asm volatile ( "movl %%ecx, %%eax
-                    xorl $0x200000, %%eax
-                    pushl %%eax
-                    popfl
-                    pushfl
-                    popl %%eax
-                    xorl %%ecx, %%eax
-                    pushl %%ecx
-                    popfl
-                    andl $0x200000, %%eax"
-                 : "=a" ( i_reg ) );
-
-    if( !i_reg )
-        return( 0 );
-
-    /* the CPU supports the CPUID instruction - get its level */
-    asm volatile ( "cpuid"
-                 : "=a" ( i_reg ),
-                   "=b" ( i_dummy ),
-                   "=c" ( i_dummy ),
-                   "=d" ( i_dummy )
-                 : "a"  ( 0 ),       /* level 0 */
-                   "b"  ( i_dummy ) ); /* buggy compiler shouldn't complain */
-
-    /* this shouldn't happen on a normal CPU */
-    if( !i_reg )
-        return( 0 );
-
-    /* test for the MMX flag */
-    asm volatile ( "cpuid
-                    andl $0x00800000, %%edx" /* X86_FEATURE_MMX */
-                 : "=a" ( i_dummy ),
-                   "=b" ( i_dummy ),
-                   "=c" ( i_dummy ),
-                   "=d" ( i_reg )
-                 : "a"  ( 1 ),       /* level 1 */
-                   "b"  ( i_dummy ) ); /* buggy compiler shouldn't complain */
-
-    if( !i_reg )
-        return( 0 );
-
-    return( 1 );
-#endif
-#endif
+    return( (i_capabilities & p_main->i_cpu_capabilities) == i_capabilities );
 }
 
-