/* WinCE API */
#elif defined( WIN32 )
# include <process.h> /* Win32 API */
+# include <errno.h>
#elif defined( HAVE_KERNEL_SCHEDULER_H ) /* BeOS */
# include <kernel/OS.h>
int i_win9x_cv;
} vlc_cond_t;
-typedef struct
-{
- DWORD handle;
-} vlc_threadvar_t;
+typedef DWORD vlc_threadvar_t;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
/* This is the BeOS implementation of the vlc threads, note that the mutex is
#else
typedef pthread_t vlc_thread_t;
-typedef struct
-{
- pthread_mutex_t mutex;
-} vlc_mutex_t;
-typedef struct
-{
- pthread_cond_t cond;
-} vlc_cond_t;
-
-typedef struct
-{
- pthread_key_t handle;
-} vlc_threadvar_t;
+typedef pthread_mutex_t vlc_mutex_t;
+typedef pthread_cond_t vlc_cond_t;
+typedef pthread_key_t vlc_threadvar_t;
#endif
#elif defined(LIBVLC_USE_PTHREAD)
# define vlc_assert_locked( m ) \
- assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK)
- int val = pthread_mutex_lock( &p_mutex->mutex );
+ assert (pthread_mutex_lock (m) == EDEADLK)
+ int val = pthread_mutex_lock( p_mutex );
VLC_THREAD_ASSERT ("locking mutex");
#endif
release_sem( p_mutex->lock );
#elif defined(LIBVLC_USE_PTHREAD)
- int val = pthread_mutex_unlock( &p_mutex->mutex );
+ int val = pthread_mutex_unlock( p_mutex );
VLC_THREAD_ASSERT ("unlocking mutex");
#endif
}
#elif defined(LIBVLC_USE_PTHREAD)
- int val = pthread_cond_signal( &p_condvar->cond );
+ int val = pthread_cond_signal( p_condvar );
VLC_THREAD_ASSERT ("signaling condition variable");
#endif
vlc_mutex_lock( p_mutex );
#elif defined(LIBVLC_USE_PTHREAD)
- int val = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex );
+ int val = pthread_cond_wait( p_condvar, p_mutex );
VLC_THREAD_ASSERT ("waiting on condition");
#endif
lldiv_t d = lldiv( deadline, 1000000 );
struct timespec ts = { d.quot, d.rem * 1000 };
- int val = pthread_cond_timedwait (&p_condvar->cond, &p_mutex->mutex, &ts);
+ int val = pthread_cond_timedwait (p_condvar, p_mutex, &ts);
if (val == ETIMEDOUT)
return ETIMEDOUT; /* this error is perfectly normal */
VLC_THREAD_ASSERT ("timed-waiting on condition");
int i_ret;
#if defined( HAVE_KERNEL_SCHEDULER_H )
- return -1;
+ i_ret = EINVAL;
#elif defined( UNDER_CE ) || defined( WIN32 )
- i_ret = ( TlsSetValue( p_tls->handle, p_value ) != 0 );
+ i_ret = TlsSetValue( *p_tls, p_value ) ? EINVAL : 0;
#elif defined(LIBVLC_USE_PTHREAD)
- i_ret = pthread_setspecific( p_tls->handle, p_value );
+ i_ret = pthread_setspecific( *p_tls, p_value );
#endif
*****************************************************************************/
static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
{
- void* p_ret;
+ void *p_ret;
#if 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 );
#elif defined(LIBVLC_USE_PTHREAD)
- p_ret = pthread_getspecific( p_tls->handle );
+ p_ret = pthread_getspecific( *p_tls );
#endif
return B_OK;
#elif defined( LIBVLC_USE_PTHREAD )
-# ifndef NDEBUG
- {
- /* Create error-checking mutex to detect problems more easily. */
- pthread_mutexattr_t attr;
- int i_result;
-
- pthread_mutexattr_init( &attr );
-# if defined(SYS_LINUX)
- pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
-# else
- pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
-# endif
+ pthread_mutexattr_t attr;
+ int i_result;
- i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
- pthread_mutexattr_destroy( &attr );
- return( i_result );
- }
-# endif /* NDEBUG */
- return pthread_mutex_init( &p_mutex->mutex, NULL );
+ pthread_mutexattr_init( &attr );
+# ifndef NDEBUG
+ /* Create error-checking mutex to detect problems more easily. */
+# if defined(SYS_LINUX)
+ pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
+# else
+ pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
+# endif
+# endif
+ i_result = pthread_mutex_init( p_mutex, &attr );
+ pthread_mutexattr_destroy( &attr );
+ return i_result;
#endif
}
# endif
# endif
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
- i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
+ i_result = pthread_mutex_init( p_mutex, &attr );
pthread_mutexattr_destroy( &attr );
return( i_result );
#else
p_mutex->init = 0;
#elif defined( LIBVLC_USE_PTHREAD )
- int val = pthread_mutex_destroy( &p_mutex->mutex );
+ int val = pthread_mutex_destroy( p_mutex );
VLC_THREAD_ASSERT ("destroying mutex");
#endif
pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
# endif
- ret = pthread_cond_init (&p_condvar->cond, &attr);
+ ret = pthread_cond_init (p_condvar, &attr);
pthread_condattr_destroy (&attr);
return ret;
p_condvar->init = 0;
#elif defined( LIBVLC_USE_PTHREAD )
- int val = pthread_cond_destroy( &p_condvar->cond );
+ int val = pthread_cond_destroy( p_condvar );
VLC_THREAD_ASSERT ("destroying condition");
#endif
# error Unimplemented!
#elif defined( UNDER_CE ) || defined( WIN32 )
#elif defined( WIN32 )
- p_tls->handle = TlsAlloc();
- i_ret = !( p_tls->handle == 0xFFFFFFFF );
+ *p_tls = TlsAlloc();
+ i_ret = (*p_tls == INVALID_HANDLE_VALUE) ? EAGAIN : 0;
#elif defined( LIBVLC_USE_PTHREAD )
- i_ret = pthread_key_create( &p_tls->handle, NULL );
+ i_ret = pthread_key_create( p_tls, NULL );
#endif
return i_ret;
}