summaryrefslogtreecommitdiff
path: root/src/egl/main/eglcurrent.c
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2010-11-03 01:11:54 +0800
committerChia-I Wu <olv@lunarg.com>2010-11-03 13:34:17 +0800
commitc9186bd5886f4e05fd62a98d42404eda2a99416c (patch)
tree7c8e782a8801f2ea10fc23ae0b8d843623169af2 /src/egl/main/eglcurrent.c
parent93a7e6d94e09a25bdbe31eedb0759e390ccb6a86 (diff)
egl: Set up the pthread key even TLS is used.
We have to rely on the pthread key destructor to free the current thread info when a thread exits.
Diffstat (limited to 'src/egl/main/eglcurrent.c')
-rw-r--r--src/egl/main/eglcurrent.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index c0e8c119a94..cbca9ff2c2f 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -14,33 +14,7 @@
static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
-#ifdef GLX_USE_TLS
-static __thread const _EGLThreadInfo *_egl_TSD
- __attribute__ ((tls_model("initial-exec")));
-
-static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
-{
- _egl_TSD = t;
-}
-
-static INLINE _EGLThreadInfo *_eglGetTSD(void)
-{
- return (_EGLThreadInfo *) _egl_TSD;
-}
-
-static INLINE void _eglFiniTSD(void)
-{
-}
-
-static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
-{
- /* TODO destroy TSD */
- (void) dtor;
- (void) _eglFiniTSD;
- return EGL_TRUE;
-}
-
-#elif PTHREADS
+#if PTHREADS
#include <pthread.h>
static _EGL_DECLARE_MUTEX(_egl_TSDMutex);
@@ -48,14 +22,26 @@ static EGLBoolean _egl_TSDInitialized;
static pthread_key_t _egl_TSD;
static void (*_egl_FreeTSD)(_EGLThreadInfo *);
+#ifdef GLX_USE_TLS
+static __thread const _EGLThreadInfo *_egl_TLS
+ __attribute__ ((tls_model("initial-exec")));
+#endif
+
static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
{
pthread_setspecific(_egl_TSD, (const void *) t);
+#ifdef GLX_USE_TLS
+ _egl_TLS = t;
+#endif
}
static INLINE _EGLThreadInfo *_eglGetTSD(void)
{
+#ifdef GLX_USE_TLS
+ return (_EGLThreadInfo *) _egl_TLS;
+#else
return (_EGLThreadInfo *) pthread_getspecific(_egl_TSD);
+#endif
}
static INLINE void _eglFiniTSD(void)