Remove the inline wrappers/abstraction layer.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
eglmisc.h \
eglmode.c \
eglmode.h \
- eglmutex.h \
eglscreen.c \
eglscreen.h \
eglstring.c \
#include <stdlib.h>
#include <string.h>
#include "c99_compat.h"
+#include "c11/threads.h"
+#include "eglcompiler.h"
#include "eglglobals.h"
#include "eglcontext.h"
{
_EGLDisplay *dpy = _eglLookupDisplay(display);
if (dpy)
- _eglLockMutex(&dpy->Mutex);
+ mtx_lock(&dpy->Mutex);
return dpy;
}
static inline void
_eglUnlockDisplay(_EGLDisplay *dpy)
{
- _eglUnlockMutex(&dpy->Mutex);
+ mtx_unlock(&dpy->Mutex);
}
RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
disp = ctx->Resource.Display;
- _eglLockMutex(&disp->Mutex);
+ mtx_lock(&disp->Mutex);
/* let bad current context imply bad current surface */
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
disp = ctx->Resource.Display;
- _eglLockMutex(&disp->Mutex);
+ mtx_lock(&disp->Mutex);
/* let bad current context imply bad current surface */
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
t->CurrentAPIIndex = i;
- _eglLockMutex(&disp->Mutex);
+ mtx_lock(&disp->Mutex);
drv = disp->Driver;
(void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL);
- _eglUnlockMutex(&disp->Mutex);
+ mtx_unlock(&disp->Mutex);
}
}
#include "c99_compat.h"
#include "egllog.h"
-#include "eglmutex.h"
#include "eglcurrent.h"
#include "eglglobals.h"
#if HAVE_PTHREAD
#include <pthread.h>
-static _EGLMutex _egl_TSDMutex = _EGL_MUTEX_INITIALIZER;
+static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP;
static EGLBoolean _egl_TSDInitialized;
static pthread_key_t _egl_TSD;
static void (*_egl_FreeTSD)(_EGLThreadInfo *);
static inline void _eglFiniTSD(void)
{
- _eglLockMutex(&_egl_TSDMutex);
+ mtx_lock(&_egl_TSDMutex);
if (_egl_TSDInitialized) {
_EGLThreadInfo *t = _eglGetTSD();
_egl_FreeTSD((void *) t);
pthread_key_delete(_egl_TSD);
}
- _eglUnlockMutex(&_egl_TSDMutex);
+ mtx_unlock(&_egl_TSDMutex);
}
static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
{
if (!_egl_TSDInitialized) {
- _eglLockMutex(&_egl_TSDMutex);
+ mtx_lock(&_egl_TSDMutex);
/* check again after acquiring lock */
if (!_egl_TSDInitialized) {
if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) {
- _eglUnlockMutex(&_egl_TSDMutex);
+ mtx_unlock(&_egl_TSDMutex);
return EGL_FALSE;
}
_egl_FreeTSD = dtor;
_egl_TSDInitialized = EGL_TRUE;
}
- _eglUnlockMutex(&_egl_TSDMutex);
+ mtx_unlock(&_egl_TSDMutex);
}
return EGL_TRUE;
#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 */
if (plat == _EGL_INVALID_PLATFORM)
return NULL;
- _eglLockMutex(_eglGlobal.Mutex);
+ mtx_lock(_eglGlobal.Mutex);
/* search the display list first */
dpy = _eglGlobal.DisplayList;
if (!dpy) {
dpy = calloc(1, sizeof(_EGLDisplay));
if (dpy) {
- _eglInitMutex(&dpy->Mutex);
+ mtx_init(&dpy->Mutex, mtx_plain);
dpy->Platform = plat;
dpy->PlatformDisplay = plat_dpy;
}
}
- _eglUnlockMutex(_eglGlobal.Mutex);
+ mtx_unlock(_eglGlobal.Mutex);
return dpy;
}
{
_EGLDisplay *cur;
- _eglLockMutex(_eglGlobal.Mutex);
+ mtx_lock(_eglGlobal.Mutex);
cur = _eglGlobal.DisplayList;
while (cur) {
if (cur == (_EGLDisplay *) dpy)
break;
cur = cur->Next;
}
- _eglUnlockMutex(_eglGlobal.Mutex);
+ mtx_unlock(_eglGlobal.Mutex);
return (cur != NULL);
}
#define EGLDISPLAY_INCLUDED
#include "c99_compat.h"
+#include "c11/threads.h"
#include "egltypedefs.h"
#include "egldefines.h"
-#include "eglmutex.h"
#include "eglarray.h"
/* used to link displays */
_EGLDisplay *Next;
- _EGLMutex Mutex;
+ mtx_t Mutex;
_EGLPlatformType Platform; /**< The type of the platform display */
void *PlatformDisplay; /**< A pointer to the platform display */
#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>
_EGLDriver *Driver;
} _EGLModule;
-static _EGLMutex _eglModuleMutex = _EGL_MUTEX_INITIALIZER;
+static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP;
static _EGLArray *_eglModules;
const struct {
assert(!dpy->Initialized);
- _eglLockMutex(&_eglModuleMutex);
+ mtx_lock(&_eglModuleMutex);
/* set options */
dpy->Options.TestOnly = test_only;
best_drv = _eglMatchAndInitialize(dpy);
}
- _eglUnlockMutex(&_eglModuleMutex);
+ mtx_unlock(&_eglModuleMutex);
if (best_drv) {
_eglLog(_EGL_DEBUG, "the best driver is %s%s",
#include <stdlib.h>
#include <assert.h>
+#include "c11/threads.h"
+
#include "eglglobals.h"
#include "egldisplay.h"
#include "egldriver.h"
-#include "eglmutex.h"
-static _EGLMutex _eglGlobalMutex = _EGL_MUTEX_INITIALIZER;
+static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP;
struct _egl_global _eglGlobal =
{
if (func) {
static EGLBoolean registered = EGL_FALSE;
- _eglLockMutex(_eglGlobal.Mutex);
+ mtx_lock(_eglGlobal.Mutex);
if (!registered) {
atexit(_eglAtExit);
assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls));
_eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func;
- _eglUnlockMutex(_eglGlobal.Mutex);
+ mtx_unlock(_eglGlobal.Mutex);
}
}
#define EGLGLOBALS_INCLUDED
#include <stdbool.h>
+#include "c11/threads.h"
#include "egltypedefs.h"
-#include "eglmutex.h"
/**
*/
struct _egl_global
{
- _EGLMutex *Mutex;
+ mtx_t *Mutex;
/* the list of all displays */
_EGLDisplay *DisplayList;
#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 {
- _EGLMutex mutex;
+ mtx_t mutex;
EGLBoolean initialized;
EGLint level;
_EGLLogProc logger;
EGLint num_messages;
} logging = {
- _EGL_MUTEX_INITIALIZER,
+ _MTX_INITIALIZER_NP,
EGL_FALSE,
FALLBACK_LOG_LEVEL,
NULL,
{
EGLint num_messages = 0;
- _eglLockMutex(&logging.mutex);
+ mtx_lock(&logging.mutex);
if (logging.logger != logger) {
logging.logger = logger;
logging.num_messages = 0;
}
- _eglUnlockMutex(&logging.mutex);
+ mtx_unlock(&logging.mutex);
if (num_messages)
_eglLog(_EGL_DEBUG,
case _EGL_WARNING:
case _EGL_INFO:
case _EGL_DEBUG:
- _eglLockMutex(&logging.mutex);
+ mtx_lock(&logging.mutex);
logging.level = level;
- _eglUnlockMutex(&logging.mutex);
+ mtx_unlock(&logging.mutex);
break;
default:
break;
if (level > logging.level || level < 0)
return;
- _eglLockMutex(&logging.mutex);
+ mtx_lock(&logging.mutex);
if (logging.logger) {
va_start(args, fmtStr);
logging.num_messages++;
}
- _eglUnlockMutex(&logging.mutex);
+ mtx_unlock(&logging.mutex);
if (level == _EGL_FATAL)
exit(1); /* or abort()? */
+++ /dev/null
-/**************************************************************************
- *
- * Copyright 2009 Chia-I Wu <olvaffe@gmail.com>
- * 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 */
#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 _EGLMutex _eglNextScreenHandleMutex = _EGL_MUTEX_INITIALIZER;
+static mtx_t _eglNextScreenHandleMutex = _MTX_INITIALIZER_NP;
static EGLScreenMESA _eglNextScreenHandle = 1;
{
EGLScreenMESA s;
- _eglLockMutex(&_eglNextScreenHandleMutex);
+ mtx_lock(&_eglNextScreenHandleMutex);
s = _eglNextScreenHandle;
_eglNextScreenHandle += _EGL_SCREEN_MAX_MODES;
- _eglUnlockMutex(&_eglNextScreenHandleMutex);
+ mtx_unlock(&_eglNextScreenHandleMutex);
return s;
}