[Mesa-dev] [PATCH 5/7] egl: Use C11 thread abstractions.

Ian Romanick idr at freedesktop.org
Thu Jan 9 11:36:50 PST 2014


I'd like to hear Kristian and / or Chad's opinion, but I'd like to take
this a step further and remove the _egl* wrappers altogether... as a
follow-on patch.

For now, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 01/09/2014 11:20 AM, jfonseca at vmware.com wrote:
> From: José Fonseca <jfonseca at vmware.com>
> 
> ---
>  src/egl/main/eglmutex.h | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h
> index 1349e9e..2ec965c 100644
> --- a/src/egl/main/eglmutex.h
> +++ b/src/egl/main/eglmutex.h
> @@ -31,46 +31,34 @@
>  
>  #include "eglcompiler.h"
>  
> -#ifdef HAVE_PTHREAD
> -#include <pthread.h>
> +#include "c11/threads.h"
>  
> -typedef pthread_mutex_t _EGLMutex;
> +typedef mtx_t _EGLMutex;
>  
>  static INLINE void _eglInitMutex(_EGLMutex *m)
>  {
> -   pthread_mutex_init(m, NULL);
> +   mtx_init(m, mtx_plain);
>  }
>  
>  static INLINE void
>  _eglDestroyMutex(_EGLMutex *m)
>  {
> -   pthread_mutex_destroy(m);
> +   mtx_destroy(m);
>  }
>  
>  static INLINE void
>  _eglLockMutex(_EGLMutex *m)
>  {
> -   pthread_mutex_lock(m);
> +   mtx_lock(m);
>  }
>  
>  static INLINE void
>  _eglUnlockMutex(_EGLMutex *m)
>  {
> -   pthread_mutex_unlock(m);
> +   mtx_unlock(m);
>  }
>  
> -#define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
> +#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP
>  
> -#else
> -
> -typedef int _EGLMutex;
> -static INLINE void _eglInitMutex(_EGLMutex *m) { (void) m; }
> -static INLINE void _eglDestroyMutex(_EGLMutex *m) { (void) m; }
> -static INLINE void _eglLockMutex(_EGLMutex *m) { (void) m; }
> -static INLINE void _eglUnlockMutex(_EGLMutex *m) { (void) m; }
> -
> -#define _EGL_MUTEX_INITIALIZER 0
> -
> -#endif
>  
>  #endif /* EGLMUTEX_INCLUDED */
> 



More information about the mesa-dev mailing list