Commit e8b8ef77 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Clean up CPU flags one-time initialization

parent 78b320f2
...@@ -191,8 +191,6 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -191,8 +191,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
vlc_mutex_lock( &global_lock ); vlc_mutex_lock( &global_lock );
if( i_instances == 0 ) if( i_instances == 0 )
{ {
/* Guess what CPU we have */
cpu_flags = CPUCapabilities();
/* The module bank will be initialized later */ /* The module bank will be initialized later */
} }
......
...@@ -41,6 +41,7 @@ void system_Init ( void ); ...@@ -41,6 +41,7 @@ void system_Init ( void );
void system_Configure ( libvlc_int_t *, int, const char *const [] ); void system_Configure ( libvlc_int_t *, int, const char *const [] );
void system_End ( void ); void system_End ( void );
void vlc_CPU_init(void);
void vlc_CPU_dump(vlc_object_t *); void vlc_CPU_dump(vlc_object_t *);
/* /*
...@@ -65,12 +66,6 @@ void vlc_assert_locked (vlc_mutex_t *); ...@@ -65,12 +66,6 @@ void vlc_assert_locked (vlc_mutex_t *);
# define vlc_assert_locked( m ) (void)m # define vlc_assert_locked( m ) (void)m
#endif #endif
/*
* CPU capabilities
*/
extern uint32_t cpu_flags;
uint32_t CPUCapabilities( void );
/* /*
* LibVLC exit event handling * LibVLC exit event handling
*/ */
......
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#include "libvlc.h" #include "libvlc.h"
static uint32_t cpu_flags;
#if defined( __i386__ ) || defined( __x86_64__ ) || defined( __powerpc__ ) \ #if defined( __i386__ ) || defined( __x86_64__ ) || defined( __powerpc__ ) \
|| defined( __ppc__ ) || defined( __ppc64__ ) || defined( __powerpc64__ ) || defined( __ppc__ ) || defined( __ppc64__ ) || defined( __powerpc64__ )
# ifndef WIN32 # ifndef WIN32
...@@ -90,12 +92,11 @@ static bool check_OS_capability( const char *psz_capability, pid_t pid ) ...@@ -90,12 +92,11 @@ static bool check_OS_capability( const char *psz_capability, pid_t pid )
# endif # endif
#endif #endif
/***************************************************************************** /**
* CPUCapabilities: get the CPU capabilities * Determines the CPU capabilities and stores them in cpu_flags.
***************************************************************************** * The result can be retrieved with vlc_CPU().
* This function is called to list extensions the CPU may have. */
*****************************************************************************/ void vlc_CPU_init (void)
uint32_t CPUCapabilities( void )
{ {
uint32_t i_capabilities = 0; uint32_t i_capabilities = 0;
...@@ -322,17 +323,19 @@ out: ...@@ -322,17 +323,19 @@ out:
# endif # endif
#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) 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; return cpu_flags;
} }
......
...@@ -82,6 +82,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) ...@@ -82,6 +82,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
vlc_threadvar_create (&thread_key, NULL); vlc_threadvar_create (&thread_key, NULL);
vlc_rwlock_init (&config_lock); vlc_rwlock_init (&config_lock);
vlc_rwlock_init (&msg_lock); vlc_rwlock_init (&msg_lock);
vlc_CPU_init ();
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment