aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/egl/main/Makefile.sources1
-rw-r--r--src/egl/main/eglapi.c14
-rw-r--r--src/egl/main/eglcurrent.c13
-rw-r--r--src/egl/main/egldisplay.c13
-rw-r--r--src/egl/main/egldisplay.h4
-rw-r--r--src/egl/main/egldriver.c8
-rw-r--r--src/egl/main/eglglobals.c9
-rw-r--r--src/egl/main/eglglobals.h4
-rw-r--r--src/egl/main/egllog.c18
-rw-r--r--src/egl/main/eglmutex.h66
-rw-r--r--src/egl/main/eglscreen.c8
11 files changed, 111 insertions, 47 deletions
diff --git a/src/egl/main/Makefile.sources b/src/egl/main/Makefile.sources
index 75f060a456a..6a917e22022 100644
--- a/src/egl/main/Makefile.sources
+++ b/src/egl/main/Makefile.sources
@@ -26,6 +26,7 @@ LIBEGL_C_FILES := \
eglmisc.h \
eglmode.c \
eglmode.h \
+ eglmutex.h \
eglscreen.c \
eglscreen.h \
eglstring.c \
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index a74efcd8f99..22588300644 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -87,8 +87,6 @@
#include <stdlib.h>
#include <string.h>
#include "c99_compat.h"
-#include "c11/threads.h"
-#include "eglcompiler.h"
#include "eglglobals.h"
#include "eglcontext.h"
@@ -277,7 +275,7 @@ _eglLockDisplay(EGLDisplay display)
{
_EGLDisplay *dpy = _eglLookupDisplay(display);
if (dpy)
- mtx_lock(&dpy->Mutex);
+ _eglLockMutex(&dpy->Mutex);
return dpy;
}
@@ -288,7 +286,7 @@ _eglLockDisplay(EGLDisplay display)
static inline void
_eglUnlockDisplay(_EGLDisplay *dpy)
{
- mtx_unlock(&dpy->Mutex);
+ _eglUnlockMutex(&dpy->Mutex);
}
@@ -898,7 +896,7 @@ eglWaitClient(void)
RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
disp = ctx->Resource.Display;
- mtx_lock(&disp->Mutex);
+ _eglLockMutex(&disp->Mutex);
/* let bad current context imply bad current surface */
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
@@ -944,7 +942,7 @@ eglWaitNative(EGLint engine)
RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
disp = ctx->Resource.Display;
- mtx_lock(&disp->Mutex);
+ _eglLockMutex(&disp->Mutex);
/* let bad current context imply bad current surface */
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
@@ -1459,10 +1457,10 @@ eglReleaseThread(void)
t->CurrentAPIIndex = i;
- mtx_lock(&disp->Mutex);
+ _eglLockMutex(&disp->Mutex);
drv = disp->Driver;
(void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
- mtx_unlock(&disp->Mutex);
+ _eglUnlockMutex(&disp->Mutex);
}
}
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index dc32ed4c210..3d496411cbb 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -31,6 +31,7 @@
#include "c99_compat.h"
#include "egllog.h"
+#include "eglmutex.h"
#include "eglcurrent.h"
#include "eglglobals.h"
@@ -46,7 +47,7 @@ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
#if HAVE_PTHREAD
#include <pthread.h>
-static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP;
+static _EGLMutex _egl_TSDMutex = _EGL_MUTEX_INITIALIZER;
static EGLBoolean _egl_TSDInitialized;
static pthread_key_t _egl_TSD;
static void (*_egl_FreeTSD)(_EGLThreadInfo *);
@@ -75,7 +76,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void)
static inline void _eglFiniTSD(void)
{
- mtx_lock(&_egl_TSDMutex);
+ _eglLockMutex(&_egl_TSDMutex);
if (_egl_TSDInitialized) {
_EGLThreadInfo *t = _eglGetTSD();
@@ -84,18 +85,18 @@ static inline void _eglFiniTSD(void)
_egl_FreeTSD((void *) t);
pthread_key_delete(_egl_TSD);
}
- mtx_unlock(&_egl_TSDMutex);
+ _eglUnlockMutex(&_egl_TSDMutex);
}
static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
{
if (!_egl_TSDInitialized) {
- mtx_lock(&_egl_TSDMutex);
+ _eglLockMutex(&_egl_TSDMutex);
/* check again after acquiring lock */
if (!_egl_TSDInitialized) {
if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) {
- mtx_unlock(&_egl_TSDMutex);
+ _eglUnlockMutex(&_egl_TSDMutex);
return EGL_FALSE;
}
_egl_FreeTSD = dtor;
@@ -103,7 +104,7 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
_egl_TSDInitialized = EGL_TRUE;
}
- mtx_unlock(&_egl_TSDMutex);
+ _eglUnlockMutex(&_egl_TSDMutex);
}
return EGL_TRUE;
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index b7a5b8fb9d9..a167ae5c738 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -35,14 +35,13 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "c11/threads.h"
-
#include "eglcontext.h"
#include "eglcurrent.h"
#include "eglsurface.h"
#include "egldisplay.h"
#include "egldriver.h"
#include "eglglobals.h"
+#include "eglmutex.h"
#include "egllog.h"
/* Includes for _eglNativePlatformDetectNativeDisplay */
@@ -261,7 +260,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy)
if (plat == _EGL_INVALID_PLATFORM)
return NULL;
- mtx_lock(_eglGlobal.Mutex);
+ _eglLockMutex(_eglGlobal.Mutex);
/* search the display list first */
dpy = _eglGlobal.DisplayList;
@@ -275,7 +274,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy)
if (!dpy) {
dpy = calloc(1, sizeof(_EGLDisplay));
if (dpy) {
- mtx_init(&dpy->Mutex, mtx_plain);
+ _eglInitMutex(&dpy->Mutex);
dpy->Platform = plat;
dpy->PlatformDisplay = plat_dpy;
@@ -285,7 +284,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy)
}
}
- mtx_unlock(_eglGlobal.Mutex);
+ _eglUnlockMutex(_eglGlobal.Mutex);
return dpy;
}
@@ -345,14 +344,14 @@ _eglCheckDisplayHandle(EGLDisplay dpy)
{
_EGLDisplay *cur;
- mtx_lock(_eglGlobal.Mutex);
+ _eglLockMutex(_eglGlobal.Mutex);
cur = _eglGlobal.DisplayList;
while (cur) {
if (cur == (_EGLDisplay *) dpy)
break;
cur = cur->Next;
}
- mtx_unlock(_eglGlobal.Mutex);
+ _eglUnlockMutex(_eglGlobal.Mutex);
return (cur != NULL);
}
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 5a845d89962..9c3c8c7cf16 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -32,10 +32,10 @@
#define EGLDISPLAY_INCLUDED
#include "c99_compat.h"
-#include "c11/threads.h"
#include "egltypedefs.h"
#include "egldefines.h"
+#include "eglmutex.h"
#include "eglarray.h"
@@ -132,7 +132,7 @@ struct _egl_display
/* used to link displays */
_EGLDisplay *Next;
- mtx_t Mutex;
+ _EGLMutex Mutex;
_EGLPlatformType Platform; /**< The type of the platform display */
void *PlatformDisplay; /**< A pointer to the platform display */
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 6983af966b6..e6a61f3108b 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -37,13 +37,13 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include "c11/threads.h"
#include "eglstring.h"
#include "egldefines.h"
#include "egldisplay.h"
#include "egldriver.h"
#include "egllog.h"
+#include "eglmutex.h"
#if defined(_EGL_OS_UNIX)
#include <dlfcn.h>
@@ -63,7 +63,7 @@ typedef struct _egl_module {
_EGLDriver *Driver;
} _EGLModule;
-static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP;
+static _EGLMutex _eglModuleMutex = _EGL_MUTEX_INITIALIZER;
static _EGLArray *_eglModules;
const struct {
@@ -616,7 +616,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only)
assert(!dpy->Initialized);
- mtx_lock(&_eglModuleMutex);
+ _eglLockMutex(&_eglModuleMutex);
/* set options */
dpy->Options.TestOnly = test_only;
@@ -628,7 +628,7 @@ _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only)
best_drv = _eglMatchAndInitialize(dpy);
}
- mtx_unlock(&_eglModuleMutex);
+ _eglUnlockMutex(&_eglModuleMutex);
if (best_drv) {
_eglLog(_EGL_DEBUG, "the best driver is %s%s",
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c
index 129bf29f1e9..56fe9e29d8b 100644
--- a/src/egl/main/eglglobals.c
+++ b/src/egl/main/eglglobals.c
@@ -30,14 +30,13 @@
#include <stdlib.h>
#include <assert.h>
-#include "c11/threads.h"
-
#include "eglglobals.h"
#include "egldisplay.h"
#include "egldriver.h"
+#include "eglmutex.h"
-static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP;
+static _EGLMutex _eglGlobalMutex = _EGL_MUTEX_INITIALIZER;
struct _egl_global _eglGlobal =
{
@@ -85,7 +84,7 @@ _eglAddAtExitCall(void (*func)(void))
if (func) {
static EGLBoolean registered = EGL_FALSE;
- mtx_lock(_eglGlobal.Mutex);
+ _eglLockMutex(_eglGlobal.Mutex);
if (!registered) {
atexit(_eglAtExit);
@@ -95,6 +94,6 @@ _eglAddAtExitCall(void (*func)(void))
assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls));
_eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func;
- mtx_unlock(_eglGlobal.Mutex);
+ _eglUnlockMutex(_eglGlobal.Mutex);
}
}
diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h
index 04b96099a3b..a8cf6d69124 100644
--- a/src/egl/main/eglglobals.h
+++ b/src/egl/main/eglglobals.h
@@ -32,9 +32,9 @@
#define EGLGLOBALS_INCLUDED
#include <stdbool.h>
-#include "c11/threads.h"
#include "egltypedefs.h"
+#include "eglmutex.h"
/**
@@ -42,7 +42,7 @@
*/
struct _egl_global
{
- mtx_t *Mutex;
+ _EGLMutex *Mutex;
/* the list of all displays */
_EGLDisplay *DisplayList;
diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
index 1877d8bfd10..babab07d8eb 100644
--- a/src/egl/main/egllog.c
+++ b/src/egl/main/egllog.c
@@ -38,24 +38,24 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include "c11/threads.h"
#include "egllog.h"
#include "eglstring.h"
+#include "eglmutex.h"
#define MAXSTRING 1000
#define FALLBACK_LOG_LEVEL _EGL_WARNING
static struct {
- mtx_t mutex;
+ _EGLMutex mutex;
EGLBoolean initialized;
EGLint level;
_EGLLogProc logger;
EGLint num_messages;
} logging = {
- _MTX_INITIALIZER_NP,
+ _EGL_MUTEX_INITIALIZER,
EGL_FALSE,
FALLBACK_LOG_LEVEL,
NULL,
@@ -82,7 +82,7 @@ _eglSetLogProc(_EGLLogProc logger)
{
EGLint num_messages = 0;
- mtx_lock(&logging.mutex);
+ _eglLockMutex(&logging.mutex);
if (logging.logger != logger) {
logging.logger = logger;
@@ -91,7 +91,7 @@ _eglSetLogProc(_EGLLogProc logger)
logging.num_messages = 0;
}
- mtx_unlock(&logging.mutex);
+ _eglUnlockMutex(&logging.mutex);
if (num_messages)
_eglLog(_EGL_DEBUG,
@@ -111,9 +111,9 @@ _eglSetLogLevel(EGLint level)
case _EGL_WARNING:
case _EGL_INFO:
case _EGL_DEBUG:
- mtx_lock(&logging.mutex);
+ _eglLockMutex(&logging.mutex);
logging.level = level;
- mtx_unlock(&logging.mutex);
+ _eglUnlockMutex(&logging.mutex);
break;
default:
break;
@@ -188,7 +188,7 @@ _eglLog(EGLint level, const char *fmtStr, ...)
if (level > logging.level || level < 0)
return;
- mtx_lock(&logging.mutex);
+ _eglLockMutex(&logging.mutex);
if (logging.logger) {
va_start(args, fmtStr);
@@ -201,7 +201,7 @@ _eglLog(EGLint level, const char *fmtStr, ...)
logging.num_messages++;
}
- mtx_unlock(&logging.mutex);
+ _eglUnlockMutex(&logging.mutex);
if (level == _EGL_FATAL)
exit(1); /* or abort()? */
diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h
new file mode 100644
index 00000000000..b58f0e3faef
--- /dev/null
+++ b/src/egl/main/eglmutex.h
@@ -0,0 +1,66 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Chia-I Wu <[email protected]>
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef EGLMUTEX_INCLUDED
+#define EGLMUTEX_INCLUDED
+
+#include "c99_compat.h"
+
+#include "eglcompiler.h"
+
+#include "c11/threads.h"
+
+typedef mtx_t _EGLMutex;
+
+static inline void _eglInitMutex(_EGLMutex *m)
+{
+ mtx_init(m, mtx_plain);
+}
+
+static inline void
+_eglDestroyMutex(_EGLMutex *m)
+{
+ mtx_destroy(m);
+}
+
+static inline void
+_eglLockMutex(_EGLMutex *m)
+{
+ mtx_lock(m);
+}
+
+static inline void
+_eglUnlockMutex(_EGLMutex *m)
+{
+ mtx_unlock(m);
+}
+
+#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP
+
+
+#endif /* EGLMUTEX_INCLUDED */
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c
index 42ac621fcd9..b8f2b39c7b9 100644
--- a/src/egl/main/eglscreen.c
+++ b/src/egl/main/eglscreen.c
@@ -44,20 +44,20 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "c11/threads.h"
#include "egldisplay.h"
#include "eglcurrent.h"
#include "eglmode.h"
#include "eglsurface.h"
#include "eglscreen.h"
+#include "eglmutex.h"
#ifdef EGL_MESA_screen_surface
/* ugh, no atomic op? */
-static mtx_t _eglNextScreenHandleMutex = _MTX_INITIALIZER_NP;
+static _EGLMutex _eglNextScreenHandleMutex = _EGL_MUTEX_INITIALIZER;
static EGLScreenMESA _eglNextScreenHandle = 1;
@@ -70,10 +70,10 @@ _eglAllocScreenHandle(void)
{
EGLScreenMESA s;
- mtx_lock(&_eglNextScreenHandleMutex);
+ _eglLockMutex(&_eglNextScreenHandleMutex);
s = _eglNextScreenHandle;
_eglNextScreenHandle += _EGL_SCREEN_MAX_MODES;
- mtx_unlock(&_eglNextScreenHandleMutex);
+ _eglUnlockMutex(&_eglNextScreenHandleMutex);
return s;
}