summaryrefslogtreecommitdiffstats
path: root/src/glx/x11/glxclient.h
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2005-04-18 16:59:53 +0000
committerIan Romanick <[email protected]>2005-04-18 16:59:53 +0000
commit02986cb2cc1b1d47b26a653e9ae0fa508365f616 (patch)
treeaf65825963e7c70928e63fcec86ca402b55cf3b0 /src/glx/x11/glxclient.h
parent2e823f29e41d395c38804919076ba30f563266b5 (diff)
Add support for pthreads and TLS to libGL for __glXLock / __glXUnlock and
for tracking the current GLX context. This fixes bug #3024.
Diffstat (limited to 'src/glx/x11/glxclient.h')
-rw-r--r--src/glx/x11/glxclient.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index 4356ee8cf9c..83e1f27269a 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -60,8 +60,10 @@
#include "GL/internal/glcore.h"
#include "glapitable.h"
#include "glxextensions.h"
-#ifdef XTHREADS
-#include "Xthreads.h"
+#if defined( XTHREADS )
+# include "Xthreads.h"
+#elif defined( PTHREADS )
+# include <pthread.h>
#endif
#ifdef GLX_BUILT_IN_XMESA
#include "realglx.h" /* just silences prototype warnings */
@@ -625,24 +627,44 @@ extern __GLXdisplayPrivate *__glXInitialize(Display*);
extern int __glXDebug;
/* This is per-thread storage in an MT environment */
-#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
-extern __GLXcontext *__glXGetCurrentContext(void);
+#if defined( XTHREADS ) || defined( PTHREADS )
+
extern void __glXSetCurrentContext(__GLXcontext *c);
+
+# if defined( GLX_USE_TLS )
+
+extern __thread void * __glX_tls_Context
+ __attribute__((tls_model("initial-exec")));
+
+# define __glXGetCurrentContext() __glX_tls_Context
+
+# else
+
+extern __GLXcontext *__glXGetCurrentContext(void);
+
+# endif /* defined( GLX_USE_TLS ) */
+
#else
+
extern __GLXcontext *__glXcurrentContext;
#define __glXGetCurrentContext() __glXcurrentContext
#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
-#endif
+
+#endif /* defined( XTHREADS ) || defined( PTHREADS ) */
/*
** Global lock for all threads in this address space using the GLX
** extension
*/
-#if defined(GLX_DIRECT_RENDERING) && defined(XTHREADS)
+#if defined( XTHREADS )
extern xmutex_rec __glXmutex;
#define __glXLock() xmutex_lock(&__glXmutex)
#define __glXUnlock() xmutex_unlock(&__glXmutex)
+#elif defined( PTHREADS )
+extern pthread_mutex_t __glXmutex;
+#define __glXLock() pthread_mutex_lock(&__glXmutex)
+#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
#else
#define __glXLock()
#define __glXUnlock()