From a020e9e70af08c203df38086a52814cd75d84db5 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 11 Aug 2022 09:56:37 -0700 Subject: [PATCH] egl: Convert to simple_mtx_t Mostly because simple_mtx_assert_locked() will come in handy during locking re-work. Signed-off-by: Rob Clark Reviewed-by: Eric Engestrom Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 4 ++-- src/egl/drivers/dri2/platform_android.c | 4 ++-- src/egl/drivers/wgl/egl_wgl.c | 4 ++-- src/egl/main/eglapi.c | 24 ++++++++++++------------ src/egl/main/eglcurrent.c | 4 ++-- src/egl/main/egldevice.c | 12 ++++++------ src/egl/main/egldisplay.c | 10 +++++----- src/egl/main/egldisplay.h | 4 ++-- src/egl/main/eglglobals.c | 8 ++++---- src/egl/main/eglglobals.h | 4 ++-- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 1b08a46..ed30618 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -656,9 +656,9 @@ dri2_validate_egl_image(void *image, void *data) _EGLDisplay *disp = data; _EGLImage *img; - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); img = _eglLookupImage(image, disp); - mtx_unlock(&disp->Mutex); + simple_mtx_unlock(&disp->Mutex); if (img == NULL) { _eglError(EGL_BAD_PARAMETER, "dri2_validate_egl_image"); diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index e0ec9ae..ffd75ce 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -544,7 +544,7 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur * we enter droid_window_enqueue_buffer() and re-acquire the mutex upon * return. */ - mtx_unlock(&disp->Mutex); + simple_mtx_unlock(&disp->Mutex); /* Queue the buffer with stored out fence fd. The ANativeWindow or buffer * consumer may choose to wait for the fence to signal before accessing @@ -563,7 +563,7 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur dri2_surf->buffer = NULL; dri2_surf->back = NULL; - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); if (dri2_surf->dri_image_back) { dri2_dpy->image->destroyImage(dri2_surf->dri_image_back); diff --git a/src/egl/drivers/wgl/egl_wgl.c b/src/egl/drivers/wgl/egl_wgl.c index ccb5957..7ec1fcf 100644 --- a/src/egl/drivers/wgl/egl_wgl.c +++ b/src/egl/drivers/wgl/egl_wgl.c @@ -215,9 +215,9 @@ wgl_validate_egl_image(struct st_manager *smapi, void *image) _EGLDisplay *disp = wgl_dpy->parent; _EGLImage *img; - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); img = _eglLookupImage(image, disp); - mtx_unlock(&disp->Mutex); + simple_mtx_unlock(&disp->Mutex); if (img == NULL) { _eglError(EGL_BAD_PARAMETER, "wgl_validate_egl_image"); diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 5b25e2d..2fdf5d7 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -250,7 +250,7 @@ _eglLockDisplay(EGLDisplay dpy) { _EGLDisplay *disp = _eglLookupDisplay(dpy); if (disp) - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); return disp; } @@ -261,7 +261,7 @@ _eglLockDisplay(EGLDisplay dpy) static inline void _eglUnlockDisplay(_EGLDisplay *disp) { - mtx_unlock(&disp->Mutex); + simple_mtx_unlock(&disp->Mutex); } static void @@ -1518,7 +1518,7 @@ _eglWaitClientCommon(void) RETURN_EGL_SUCCESS(NULL, EGL_TRUE); disp = ctx->Resource.Display; - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -1561,7 +1561,7 @@ eglWaitNative(EGLint engine) _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL); disp = ctx->Resource.Display; - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); /* let bad current context imply bad current surface */ if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || @@ -1720,9 +1720,9 @@ eglReleaseThread(void) if (ctx) { _EGLDisplay *disp = ctx->Resource.Display; - mtx_lock(&disp->Mutex); + simple_mtx_lock(&disp->Mutex); (void) disp->Driver->MakeCurrent(disp, NULL, NULL, NULL); - mtx_unlock(&disp->Mutex); + simple_mtx_unlock(&disp->Mutex); } _eglDestroyCurrentThread(); @@ -2495,7 +2495,7 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, _EGL_FUNC_START(NULL, EGL_NONE, NULL); - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); newEnabled = _eglGlobal.debugTypesEnabled; if (attrib_list != NULL) { @@ -2515,7 +2515,7 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, default: // On error, set the last error code, call the current // debug callback, and return the error code. - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); _eglReportError(EGL_BAD_ATTRIBUTE, NULL, "Invalid attribute 0x%04lx", (unsigned long) attrib_list[i]); return EGL_BAD_ATTRIBUTE; @@ -2531,7 +2531,7 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, _eglGlobal.debugTypesEnabled = _EGL_DEBUG_BIT_CRITICAL | _EGL_DEBUG_BIT_ERROR; } - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return EGL_SUCCESS; } @@ -2540,7 +2540,7 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value) { _EGL_FUNC_START(NULL, EGL_NONE, NULL); - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); switch (attribute) { case EGL_DEBUG_MSG_CRITICAL_KHR: @@ -2556,13 +2556,13 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value) *value = (EGLAttrib) _eglGlobal.debugCallback; break; default: - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); _eglReportError(EGL_BAD_ATTRIBUTE, NULL, "Invalid attribute 0x%04lx", (unsigned long) attribute); return EGL_FALSE; } - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return EGL_TRUE; } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 17f9ccc..45ed741 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -182,11 +182,11 @@ _eglDebugReport(EGLenum error, const char *funcName, if (funcName == NULL) funcName = thr->CurrentFuncName; - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); if (_eglGlobal.debugTypesEnabled & DebugBitFromType(type)) callback = _eglGlobal.debugCallback; - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); char *message_buf = NULL; if (message != NULL) { diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c index a8ae128..c1c421b 100644 --- a/src/egl/main/egldevice.c +++ b/src/egl/main/egldevice.c @@ -86,14 +86,14 @@ _eglCheckDeviceHandle(EGLDeviceEXT device) { _EGLDevice *cur; - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); cur = _eglGlobal.DeviceList; while (cur) { if (cur == (_EGLDevice *) device) break; cur = cur->Next; } - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return (cur != NULL); } @@ -168,7 +168,7 @@ _eglAddDevice(int fd, bool software) { _EGLDevice *dev; - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); dev = _eglGlobal.DeviceList; /* The first device is always software */ @@ -194,7 +194,7 @@ _eglAddDevice(int fd, bool software) #endif out: - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return dev; } @@ -328,7 +328,7 @@ _eglQueryDevicesEXT(EGLint max_devices, if ((devices && max_devices <= 0) || !num_devices) return _eglError(EGL_BAD_PARAMETER, "eglQueryDevicesEXT"); - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); num_devs = _eglRefreshDeviceList(); devs = _eglGlobal.DeviceList; @@ -359,7 +359,7 @@ _eglQueryDevicesEXT(EGLint max_devices, } out: - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return EGL_TRUE; } diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 131fc22..9afa0e3 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -263,7 +263,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, if (plat == _EGL_INVALID_PLATFORM) return NULL; - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); /* search the display list first */ for (disp = _eglGlobal.DisplayList; disp; disp = disp->Next) { @@ -278,7 +278,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, if (!disp) goto out; - mtx_init(&disp->Mutex, mtx_plain); + simple_mtx_init(&disp->Mutex, mtx_plain); disp->Platform = plat; disp->PlatformDisplay = plat_dpy; num_attribs = _eglNumAttribs(attrib_list); @@ -298,7 +298,7 @@ _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy, _eglGlobal.DisplayList = disp; out: - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return disp; } @@ -379,14 +379,14 @@ _eglCheckDisplayHandle(EGLDisplay dpy) { _EGLDisplay *cur; - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); cur = _eglGlobal.DisplayList; while (cur) { if (cur == (_EGLDisplay *) dpy) break; cur = cur->Next; } - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); return (cur != NULL); } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 3d065f5..cf7cfb1 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -31,7 +31,7 @@ #ifndef EGLDISPLAY_INCLUDED #define EGLDISPLAY_INCLUDED -#include "c11/threads.h" +#include "util/simple_mtx.h" #include "egltypedefs.h" #include "egldefines.h" @@ -159,7 +159,7 @@ struct _egl_display /* used to link displays */ _EGLDisplay *Next; - mtx_t Mutex; + simple_mtx_t Mutex; _EGLPlatformType Platform; /**< The type of the platform display */ void *PlatformDisplay; /**< A pointer to the platform display */ diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 36213a2..93013ea 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -32,7 +32,7 @@ #include #include #include -#include "c11/threads.h" +#include "util/simple_mtx.h" #include "eglglobals.h" #include "egldevice.h" @@ -47,7 +47,7 @@ #endif -static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP; +static simple_mtx_t _eglGlobalMutex = _SIMPLE_MTX_INITIALIZER_NP; struct _egl_global _eglGlobal = { @@ -124,7 +124,7 @@ _eglAddAtExitCall(void (*func)(void)) if (func) { static EGLBoolean registered = EGL_FALSE; - mtx_lock(_eglGlobal.Mutex); + simple_mtx_lock(_eglGlobal.Mutex); if (!registered) { atexit(_eglAtExit); @@ -134,7 +134,7 @@ _eglAddAtExitCall(void (*func)(void)) assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls)); _eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func; - mtx_unlock(_eglGlobal.Mutex); + simple_mtx_unlock(_eglGlobal.Mutex); } } diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index fc3b6bd..dddc1f3 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -32,7 +32,7 @@ #define EGLGLOBALS_INCLUDED #include -#include "c11/threads.h" +#include "util/simple_mtx.h" #include "egltypedefs.h" @@ -49,7 +49,7 @@ enum */ struct _egl_global { - mtx_t *Mutex; + simple_mtx_t *Mutex; /* the list of all displays */ _EGLDisplay *DisplayList; -- 2.7.4