X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fvlc_threads.h;h=e35ce880936754e2fb1d40832f0be2b1e1439f56;hb=0a7044077201ff47826bbf1f9bb596aff827a97f;hp=f8bd9fb50dbc992bf19503f065b3418fc14d7a99;hpb=2ff0745fad56fe093646e1d774cf4c6282c71eb2;p=vlc diff --git a/include/vlc_threads.h b/include/vlc_threads.h index f8bd9fb50d..e35ce88093 100644 --- a/include/vlc_threads.h +++ b/include/vlc_threads.h @@ -34,17 +34,7 @@ #include -#if defined(DEBUG) && defined(HAVE_SYS_TIME_H) -# include -#endif - -#if defined( PTH_INIT_IN_PTH_H ) /* GNU Pth */ -# include - -#elif defined( ST_INIT_IN_ST_H ) /* State threads */ -# include - -#elif defined( UNDER_CE ) +#if defined( UNDER_CE ) /* WinCE API */ #elif defined( WIN32 ) # include /* Win32 API */ @@ -54,23 +44,15 @@ # include # include -#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) /* pthreads (like Linux & BSD) */ +#else /* pthreads (like Linux & BSD) */ # define LIBVLC_USE_PTHREAD 1 # define _APPLE_C_SOURCE 1 /* Proper pthread semantics on OSX */ +# include /* _POSIX_SPIN_LOCKS */ # include -# ifdef DEBUG - /* Needed for pthread_cond_timedwait */ -# include -# endif - /* This is not prototyped under Linux, though it exists. */ - int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind ); - -#elif defined( HAVE_CTHREADS_H ) /* GNUMach */ -# include - -#else -# error no threads available on your system ! + /* Needed for pthread_cond_timedwait */ +# include +# include #endif @@ -95,7 +77,7 @@ # define VLC_THREAD_PRIORITY_OUTPUT 15 # define VLC_THREAD_PRIORITY_HIGHEST 15 -#elif defined(PTHREAD_COND_T_IN_PTHREAD_H) +#elif defined(LIBVLC_USE_PTHREAD) # define VLC_THREAD_PRIORITY_LOW 0 # define VLC_THREAD_PRIORITY_INPUT 20 # define VLC_THREAD_PRIORITY_AUDIO 10 @@ -131,44 +113,19 @@ * Type definitions *****************************************************************************/ -#if defined( PTH_INIT_IN_PTH_H ) -typedef pth_t vlc_thread_t; -typedef struct -{ - pth_mutex_t mutex; - vlc_object_t * p_this; -} vlc_mutex_t; +#if defined( WIN32 ) || defined( UNDER_CE ) typedef struct { - pth_cond_t cond; - vlc_object_t * p_this; -} vlc_cond_t; -typedef struct -{ - int handle; -} vlc_threadvar_t; + /* thread id */ + DWORD id; + /* + ** handle to created thread, needs be closed to dispose of it + ** even after thread has exited + */ + HANDLE hThread; +} vlc_thread_t; -#elif defined( ST_INIT_IN_ST_H ) -typedef st_thread_t vlc_thread_t; -typedef struct -{ - st_mutex_t mutex; - vlc_object_t * p_this; -} vlc_mutex_t; -typedef struct -{ - st_cond_t cond; - vlc_object_t * p_this; -} vlc_cond_t; -typedef struct -{ - int handle; -} vlc_threadvar_t; - -#elif defined( WIN32 ) || defined( UNDER_CE ) -typedef HANDLE vlc_thread_t; typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL ); -typedef unsigned (WINAPI *PTHREAD_START) (void *); typedef struct { @@ -176,8 +133,6 @@ typedef struct HANDLE mutex; /* Win95/98/ME implementation */ CRITICAL_SECTION csection; - - vlc_object_t * p_this; } vlc_mutex_t; typedef struct @@ -190,8 +145,6 @@ typedef struct HANDLE semaphore; CRITICAL_SECTION csection; int i_win9x_cv; - - vlc_object_t * p_this; } vlc_cond_t; typedef struct @@ -210,16 +163,12 @@ typedef struct { int32_t init; sem_id lock; - - vlc_object_t * p_this; } vlc_mutex_t; typedef struct { int32_t init; thread_id thread; - - vlc_object_t * p_this; } vlc_cond_t; typedef struct @@ -227,17 +176,15 @@ typedef struct } vlc_threadvar_t; -#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) +#else typedef pthread_t vlc_thread_t; typedef struct { pthread_mutex_t mutex; - vlc_object_t * p_this; } vlc_mutex_t; typedef struct { pthread_cond_t cond; - vlc_object_t * p_this; } vlc_cond_t; typedef struct @@ -245,37 +192,6 @@ typedef struct pthread_key_t handle; } vlc_threadvar_t; -#elif defined( HAVE_CTHREADS_H ) -typedef cthread_t vlc_thread_t; - -/* Those structs are the ones defined in /include/cthreads.h but we need - * to handle (&foo) where foo is a (mutex_t) while they handle (foo) where - * foo is a (mutex_t*) */ -typedef struct -{ - spin_lock_t held; - spin_lock_t lock; - char *name; - struct cthread_queue queue; - - vlc_object_t * p_this; -} vlc_mutex_t; - -typedef struct -{ - spin_lock_t lock; - struct cthread_queue queue; - char *name; - struct cond_imp *implications; - - vlc_object_t * p_this; -} vlc_cond_t; - -typedef struct -{ - cthread_key_t handle; -} vlc_threadvar_t; - #endif -#endif +#endif /* !_VLC_THREADS_H */