]> git.sesse.net Git - vlc/blobdiff - include/vlc_threads_funcs.h
playlist: Make playlist_archived_services_discovery_t internal.
[vlc] / include / vlc_threads_funcs.h
index cc7878159684e39a253222dfd8d92bd8c3019357..b4822bce990a505f017adcaa6fd6f628135350ba 100644 (file)
   #error You are not libvlc or one of its plugins. You cannot include this file
 #endif
 
+#ifndef _VLC_THREADFUNCS_H_
+#define _VLC_THREADFUNCS_H_
+
 /*****************************************************************************
  * Function definitions
  *****************************************************************************/
-VLC_EXPORT( int,  __vlc_threads_init,  ( vlc_object_t * ) );
-VLC_EXPORT( int,  __vlc_threads_end,   ( vlc_object_t * ) );
 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 * ) );
@@ -119,6 +120,9 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
     }
 
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
+#   define vlc_assert_locked( m ) \
+           assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK)
+
     i_result = pthread_mutex_lock( &p_mutex->mutex );
     if ( i_result )
     {
@@ -141,6 +145,10 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
     return i_result;
 }
 
+#ifndef vlc_assert_locked
+# define vlc_assert_locked( m ) (void)0
+#endif
+
 /*****************************************************************************
  * vlc_mutex_unlock: unlock a mutex
  *****************************************************************************/
@@ -557,11 +565,7 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
 /*****************************************************************************
  * 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 )
+static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
 {
     int i_ret;
 
@@ -588,11 +592,7 @@ static inline int __vlc_threadvar_set( char* psz_file, int line,
 /*****************************************************************************
  * 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 )
+static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
 {
     void* p_ret;
 
@@ -603,7 +603,7 @@ static inline void* __vlc_threadvar_get( char* psz_file, int line,
 #elif defined( HAVE_KERNEL_SCHEDULER_H )
     p_ret = NULL;
 #elif defined( UNDER_CE ) || defined( WIN32 )
-    p_ret = TlsGetValue( &p_tls->handle );
+    p_ret = TlsGetValue( p_tls->handle );
 
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
     p_ret = pthread_getspecific( p_tls->handle );
@@ -641,3 +641,5 @@ static inline void* __vlc_threadvar_get( char* psz_file, int line,
  *****************************************************************************/
 #define vlc_thread_join( P_THIS )                                           \
     __vlc_thread_join( VLC_OBJECT(P_THIS), __FILE__, __LINE__ )
+
+#endif