aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglmutex.h
blob: 29faba0f241fd82458e532c13b108b7c4396b46a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef EGLMUTEX_INCLUDED
#define EGLMUTEX_INCLUDED

#include "eglcompiler.h"

#ifdef PTHREADS
#include <pthread.h>

typedef pthread_mutex_t _EGLMutex;

static INLINE void _eglInitMutex(_EGLMutex *m)
{
   pthread_mutex_init(m, NULL);
}

static INLINE void
_eglDestroyMutex(_EGLMutex *m)
{
   pthread_mutex_destroy(m);
}

static INLINE void
_eglLockMutex(_EGLMutex *m)
{
   pthread_mutex_lock(m);
}

static INLINE void
_eglUnlockMutex(_EGLMutex *m)
{
   pthread_mutex_unlock(m);
}

#define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#define _EGL_DECLARE_MUTEX(m) \
   _EGLMutex m = _EGL_MUTEX_INITIALIZER

#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
#define _EGL_DECLARE_MUTEX(m) \
   _EGLMutex m = _EGL_MUTEX_INITIALIZER

#endif

#endif /* EGLMUTEX_INCLUDED */