vlc_mutex_lock( &global_lock );
if( i_instances == 0 )
{
- /* Guess what CPU we have */
- cpu_flags = CPUCapabilities();
/* The module bank will be initialized later */
}
void system_Configure ( libvlc_int_t *, int, const char *const [] );
void system_End ( void );
+void vlc_CPU_init(void);
void vlc_CPU_dump(vlc_object_t *);
/*
# define vlc_assert_locked( m ) (void)m
#endif
-/*
- * CPU capabilities
- */
-extern uint32_t cpu_flags;
-uint32_t CPUCapabilities( void );
-
/*
* LibVLC exit event handling
*/
#include "libvlc.h"
+static uint32_t cpu_flags;
+
#if defined( __i386__ ) || defined( __x86_64__ ) || defined( __powerpc__ ) \
|| defined( __ppc__ ) || defined( __ppc64__ ) || defined( __powerpc64__ )
# ifndef WIN32
# endif
#endif
-/*****************************************************************************
- * CPUCapabilities: get the CPU capabilities
- *****************************************************************************
- * This function is called to list extensions the CPU may have.
- *****************************************************************************/
-uint32_t CPUCapabilities( void )
+/**
+ * Determines the CPU capabilities and stores them in cpu_flags.
+ * The result can be retrieved with vlc_CPU().
+ */
+void vlc_CPU_init (void)
{
uint32_t i_capabilities = 0;
# endif
#endif
- return i_capabilities;
-}
-
-uint32_t cpu_flags = 0;
+ cpu_flags = i_capabilities;
+}
-/*****************************************************************************
- * vlc_CPU: get pre-computed CPU capability flags
- ****************************************************************************/
+/**
+ * Retrieves pre-computed CPU capability flags
+ */
unsigned vlc_CPU (void)
{
+#ifndef WIN32 /* On Windows, initialized from DllMain() instead */
+ static pthread_once_t once = PTHREAD_ONCE_INIT;
+ pthread_once (&once, vlc_CPU_init);
+#endif
return cpu_flags;
}