Mesa (master): glapi: Static mutex does not work on WIN32_THREADS.
Brian Paul
brianp at kemper.freedesktop.org
Mon Aug 24 17:49:12 UTC 2009
Module: Mesa
Branch: master
Commit: 3076d1617db67d49ff773096123c1fa47af58272
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3076d1617db67d49ff773096123c1fa47af58272
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Tue Jul 14 13:17:25 2009 +0800
glapi: Static mutex does not work on WIN32_THREADS.
This re-introduces the race in _glapi_check_multithread, but avoids a
crash on windows.
Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
---
src/mesa/glapi/glapi.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
index b9ab9c0..e36fccb 100644
--- a/src/mesa/glapi/glapi.c
+++ b/src/mesa/glapi/glapi.c
@@ -198,7 +198,16 @@ PUBLIC const void *_glapi_Context = NULL;
#if defined(THREADS)
+#ifdef WIN32_THREADS
+/* _glthread_DECLARE_STATIC_MUTEX is broken on windows. There will be race! */
+#define CHECK_MULTITHREAD_LOCK()
+#define CHECK_MULTITHREAD_UNLOCK()
+#else
_glthread_DECLARE_STATIC_MUTEX(ThreadCheckMutex);
+#define CHECK_MULTITHREAD_LOCK() _glthread_LOCK_MUTEX(ThreadCheckMutex)
+#define CHECK_MULTITHREAD_UNLOCK() _glthread_UNLOCK_MUTEX(ThreadCheckMutex)
+#endif
+
static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */
_glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */
static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
@@ -238,7 +247,7 @@ _glapi_check_multithread(void)
if (ThreadSafe)
return;
- _glthread_LOCK_MUTEX(ThreadCheckMutex);
+ CHECK_MULTITHREAD_LOCK();
if (firstCall) {
/* initialize TSDs */
(void) _glthread_GetTSD(&ContextTSD);
@@ -252,7 +261,7 @@ _glapi_check_multithread(void)
_glapi_set_dispatch(NULL);
_glapi_set_context(NULL);
}
- _glthread_UNLOCK_MUTEX(ThreadCheckMutex);
+ CHECK_MULTITHREAD_UNLOCK();
#endif
}
More information about the mesa-commit
mailing list