Mesa (master): egl: Add eglmutex.h.

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 12 04:15:22 UTC 2009


Module: Mesa
Branch: master
Commit: e79d21ca1f11e5b584db0930eb0cf49869b0e77d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e79d21ca1f11e5b584db0930eb0cf49869b0e77d

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Mon Aug 10 11:35:06 2009 +0800

egl: Add eglmutex.h.

The implementation uses pthread mutex when available.  Otherwise, it is
no-op.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>

---

 src/egl/main/Makefile   |    1 +
 src/egl/main/eglmutex.h |   52 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile
index 1d64d94..ab61d68 100644
--- a/src/egl/main/Makefile
+++ b/src/egl/main/Makefile
@@ -20,6 +20,7 @@ HEADERS = \
 	eglhash.h \
 	eglmisc.h \
 	eglmode.h \
+	eglmutex.h \
 	eglscreen.h \
 	eglstring.h \
 	eglsurface.h \
diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h
new file mode 100644
index 0000000..29faba0
--- /dev/null
+++ b/src/egl/main/eglmutex.h
@@ -0,0 +1,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 */




More information about the mesa-commit mailing list