]> git.sesse.net Git - vlc/commitdiff
Untested states thread and gnu portable threads implementation of tls
authorClément Stenac <zorglub@videolan.org>
Mon, 18 Dec 2006 21:53:26 +0000 (21:53 +0000)
committerClément Stenac <zorglub@videolan.org>
Mon, 18 Dec 2006 21:53:26 +0000 (21:53 +0000)
Fix Win32 implementation

include/vlc_threads.h
include/vlc_threads_funcs.h
src/misc/threads.c

index 67ef7619d80b35d50f9375490c76d562eba30417..86edcdc99119a5a31bdf6e941c313a7864b8b5ff 100644 (file)
@@ -141,6 +141,7 @@ typedef struct
 } vlc_cond_t;
 typedef struct
 {
+    int handle;
 } vlc_threadvar_t;
 
 #elif defined( ST_INIT_IN_ST_H )
@@ -157,6 +158,7 @@ typedef struct
 } vlc_cond_t;
 typedef struct
 {
+    int handle;
 } vlc_threadvar_t;
 
 #elif defined( WIN32 ) || defined( UNDER_CE )
index 078f5d5090c4a8aed4ca62ce062eb1edc65eae0a..cc7878159684e39a253222dfd8d92bd8c3019357 100644 (file)
@@ -565,12 +565,15 @@ static inline int __vlc_threadvar_set( char* psz_file, int line,
 {
     int i_ret;
 
-#if defined( PTH_INIT_IN_PTH_H ) || \
-    defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H )
+#if defined( PTH_INIT_IN_PTH_H )
+    return pth_key_setdata( p_tls->handle, p_value );
+#elif  defined( ST_INIT_IN_ST_H )
+    return st_thread_setspecific( p_tls->handle, p_value );
+#elif defined( HAVE_KERNEL_SCHEDULER_H )
     return -1;
 
 #elif defined( UNDER_CE ) || defined( WIN32 )
-    i_ret = ( TlsSetValue( &p_tls->handle, p_value ) != 0 );
+    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 );
@@ -593,10 +596,12 @@ static inline void* __vlc_threadvar_get( char* psz_file, int line,
 {
     void* p_ret;
 
-#if defined( PTH_INIT_IN_PTH_H ) || \
-    defined( ST_INIT_IN_ST_H ) || defined( HAVE_KERNEL_SCHEDULER_H )
-    return NULL;
-
+#if defined( PTH_INIT_IN_PTH_H )
+    p_ret = pth_key_getdata( p_handle->key );
+#elif defined( ST_INIT_IN_ST_H )
+    p_ret = st_thread_getspecific( p_handle->key );
+#elif defined( HAVE_KERNEL_SCHEDULER_H )
+    p_ret = NULL;
 #elif defined( UNDER_CE ) || defined( WIN32 )
     p_ret = TlsGetValue( &p_tls->handle );
 
index 367511be2df359986856a8f5ea7e38b617df3d86..fb3bab6b00d65e14cefc1a568030455ecf50c995 100644 (file)
@@ -506,11 +506,12 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar
 int __vlc_threadvar_create( vlc_object_t *p_this, vlc_threadvar_t *p_tls )
 {
 #if defined( PTH_INIT_IN_PTH_H )
+    return pth_key_create( &p_tls->handle, NULL );
 #elif defined( HAVE_KERNEL_SCHEDULER_H )
-#elif defined( ST_INIT_IN_ST_H )
     msg_Err( p_this, "TLS not implemented" );
     return VLC_EGENERIC;
-
+#elif defined( ST_INIT_IN_ST_H )
+    return st_key_create( &p_tls->handle, NULL );
 #elif defined( UNDER_CE ) || defined( WIN32 )
 #elif defined( WIN32 )
     p_tls->handle = TlsAlloc();