|
|
|
@ -38,6 +38,7 @@ VLC_EXPORT( int, __vlc_mutex_init, ( vlc_object_t *, vlc_mutex_t * ) ); |
|
|
|
VLC_EXPORT( int, __vlc_mutex_destroy, ( const char *, int, vlc_mutex_t * ) ); |
|
|
|
VLC_EXPORT( int, __vlc_cond_init, ( vlc_object_t *, vlc_cond_t * ) ); |
|
|
|
VLC_EXPORT( int, __vlc_cond_destroy, ( const char *, int, vlc_cond_t * ) ); |
|
|
|
VLC_EXPORT( int, __vlc_threadvar_create, (vlc_object_t *, vlc_threadvar_t * ) ); |
|
|
|
VLC_EXPORT( int, __vlc_thread_create, ( vlc_object_t *, const char *, int, const char *, void * ( * ) ( void * ), int, vlc_bool_t ) ); |
|
|
|
VLC_EXPORT( int, __vlc_thread_set_priority, ( vlc_object_t *, const char *, int, int ) ); |
|
|
|
VLC_EXPORT( void, __vlc_thread_ready, ( vlc_object_t * ) ); |
|
|
|
@ -547,6 +548,71 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line, |
|
|
|
#define vlc_cond_destroy( P_COND ) \ |
|
|
|
__vlc_cond_destroy( __FILE__, __LINE__, P_COND ) |
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* vlc_threadvar_create: create a thread-local variable |
|
|
|
*****************************************************************************/ |
|
|
|
#define vlc_threadvar_create( PTHIS, P_TLS ) \ |
|
|
|
__vlc_threadvar_create( PTHIS, P_TLS ) |
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* vlc_threadvar_set: create: set the value of a thread-local variable |
|
|
|
*****************************************************************************/ |
|
|
|
#define vlc_threadvar_set( P_TLS , P_VAL ) \ |
|
|
|
__vlc_threadvar_set( __FILE__, __LINE__, P_TLS, P_VAL ) |
|
|
|
|
|
|
|
static inline int __vlc_threadvar_set( char* psz_file, int line, |
|
|
|
vlc_threadvar_t * p_tls, void *p_value ) |
|
|
|
{ |
|
|
|
int i_ret; |
|
|
|
|
|
|
|
#if defined( PTH_INIT_IN_PTH_H ) || \ |
|
|
|
defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H ) |
|
|
|
return -1; |
|
|
|
|
|
|
|
#elif defined( UNDER_CE ) || defined( WIN32 ) |
|
|
|
i_ret = ( TlsSetValue( &p_tls->handle, p_value ) != 0 ); |
|
|
|
|
|
|
|
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) |
|
|
|
i_ret = pthread_setspecific( p_tls->handle, p_value ); |
|
|
|
|
|
|
|
#elif defined( HAVE_CTHREADS_H ) |
|
|
|
i_ret = cthread_setspecific( p_tls->handle, p_value ); |
|
|
|
#endif |
|
|
|
|
|
|
|
return i_ret; |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* vlc_threadvar_get: create: get the value of a thread-local variable |
|
|
|
*****************************************************************************/ |
|
|
|
#define vlc_threadvar_get( P_TLS ) \ |
|
|
|
__vlc_threadvar_get( __FILE__, __LINE__, P_TLS ) |
|
|
|
|
|
|
|
static inline void* __vlc_threadvar_get( char* psz_file, int line, |
|
|
|
vlc_threadvar_t * p_tls ) |
|
|
|
{ |
|
|
|
void* p_ret; |
|
|
|
|
|
|
|
#if defined( PTH_INIT_IN_PTH_H ) || \ |
|
|
|
defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H ) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
#elif defined( UNDER_CE ) || defined( WIN32 ) |
|
|
|
p_ret = TlsGetValue( &p_tls->handle ); |
|
|
|
|
|
|
|
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) |
|
|
|
p_ret = pthread_getspecific( p_tls->handle ); |
|
|
|
|
|
|
|
#elif defined( HAVE_CTHREADS_H ) |
|
|
|
if ( !cthread_getspecific( p_tls->handle, &p_ret ) ) |
|
|
|
{ |
|
|
|
p_ret = NULL; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
return p_ret; |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* vlc_thread_create: create a thread |
|
|
|
*****************************************************************************/ |
|
|
|
|