Merge branch '7.8'
[mesa.git] / src / egl / main / eglmutex.h
1 #ifndef EGLMUTEX_INCLUDED
2 #define EGLMUTEX_INCLUDED
3
4 #include "eglcompiler.h"
5
6 #ifdef PTHREADS
7 #include <pthread.h>
8
9 typedef pthread_mutex_t _EGLMutex;
10
11 static INLINE void _eglInitMutex(_EGLMutex *m)
12 {
13 pthread_mutex_init(m, NULL);
14 }
15
16 static INLINE void
17 _eglDestroyMutex(_EGLMutex *m)
18 {
19 pthread_mutex_destroy(m);
20 }
21
22 static INLINE void
23 _eglLockMutex(_EGLMutex *m)
24 {
25 pthread_mutex_lock(m);
26 }
27
28 static INLINE void
29 _eglUnlockMutex(_EGLMutex *m)
30 {
31 pthread_mutex_unlock(m);
32 }
33
34 #define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
35 #define _EGL_DECLARE_MUTEX(m) \
36 _EGLMutex m = _EGL_MUTEX_INITIALIZER
37
38 #else
39
40 typedef int _EGLMutex;
41 static INLINE void _eglInitMutex(_EGLMutex *m) { (void) m; }
42 static INLINE void _eglDestroyMutex(_EGLMutex *m) { (void) m; }
43 static INLINE void _eglLockMutex(_EGLMutex *m) { (void) m; }
44 static INLINE void _eglUnlockMutex(_EGLMutex *m) { (void) m; }
45
46 #define _EGL_MUTEX_INITIALIZER 0
47 #define _EGL_DECLARE_MUTEX(m) \
48 _EGLMutex m = _EGL_MUTEX_INITIALIZER
49
50 #endif
51
52 #endif /* EGLMUTEX_INCLUDED */