From 78a4589b10b765dfb2a5862f292e51e0f4b06dce Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 5 Sep 2008 16:47:06 +0200 Subject: [PATCH] gallium: Add pipe_thread primitives for PIPE_OS_LINUX. --- src/gallium/include/pipe/p_thread.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h index d4b1c3f4869..e01d5a602b8 100644 --- a/src/gallium/include/pipe/p_thread.h +++ b/src/gallium/include/pipe/p_thread.h @@ -41,8 +41,29 @@ #include /* POSIX threads headers */ #include /* for perror() */ - typedef pthread_t pipe_thread; + +#define PIPE_THREAD_ROUTINE( name, param ) \ + void *name( void *param ) + +static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param ) +{ + pipe_thread thread; + if (pthread_create( &thread, NULL, routine, param )) + return 0; + return thread; +} + +static INLINE int pipe_thread_wait( pipe_thread thread ) +{ + return pthread_join( thread, NULL ); +} + +static INLINE int pipe_thread_destroy( pipe_thread thread ) +{ + return pthread_detach( thread ); +} + typedef pthread_mutex_t pipe_mutex; typedef pthread_cond_t pipe_condvar;