summaryrefslogtreecommitdiffstats
path: root/src/egl/main
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2009-08-10 12:46:08 +0800
committerBrian Paul <[email protected]>2009-08-11 22:14:35 -0600
commit56d2119280a202b7714821bc324b07df4b36d559 (patch)
treecced27279a8eb9d7231ec358c79c7238631a8e26 /src/egl/main
parentf6c2f5e37925abe3ea7036b7a3bd6ca1721e4f73 (diff)
egl: Initialize current thread management on demand.
Current thread management was initialized in _eglInitGlobals, which is called only in eglGetDisplay. Since EGL does not require eglGetDisplay to be called first, the initialization is better to be done on demand. _eglFiniCurrent is removed, as it is not called at all. Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/eglcurrent.c37
-rw-r--r--src/egl/main/eglcurrent.h8
-rw-r--r--src/egl/main/eglglobals.c4
3 files changed, 19 insertions, 30 deletions
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index e1b35485176..f92719cfbc6 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -6,8 +6,12 @@
#include "eglmutex.h"
+/* This should be kept in sync with _eglInitThreadInfo() */
+#define _EGL_THREAD_INFO_INITIALIZER \
+ { EGL_SUCCESS, { NULL }, 1 }
+
/* a fallback thread info to guarantee that every thread always has one */
-static _EGLThreadInfo dummy_thread;
+static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
#ifdef GLX_USE_TLS
@@ -32,6 +36,7 @@ static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
{
/* TODO destroy TSD */
(void) dtor;
+ (void) _eglFiniTSD;
return EGL_TRUE;
}
@@ -79,6 +84,7 @@ static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
return EGL_FALSE;
}
_egl_FreeTSD = dtor;
+ (void) _eglFiniTSD;
_egl_TSDInitialized = EGL_TRUE;
}
@@ -112,6 +118,7 @@ static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
{
if (!_egl_FreeTSD && dtor) {
_egl_FreeTSD = dtor;
+ (void) _eglFiniTSD;
}
return EGL_TRUE;
}
@@ -156,23 +163,17 @@ _eglDestroyThreadInfo(_EGLThreadInfo *t)
/**
- * Initialize "current thread" management.
+ * Make sure TSD is initialized and return current value.
*/
-EGLBoolean
-_eglInitCurrent(void)
+static INLINE _EGLThreadInfo *
+_eglCheckedGetTSD(void)
{
- _eglInitThreadInfo(&dummy_thread);
- return _eglInitTSD((void (*)(void *)) _eglDestroyThreadInfo);
-}
-
+ if (_eglInitTSD(&_eglDestroyThreadInfo) != EGL_TRUE) {
+ _eglLog(_EGL_FATAL, "failed to initialize \"current\" system");
+ return NULL;
+ }
-/**
- * Finish "current thread" management.
- */
-void
-_eglFiniCurrent(void)
-{
- _eglFiniTSD();
+ return _eglGetTSD();
}
@@ -186,7 +187,7 @@ _eglFiniCurrent(void)
_EGLThreadInfo *
_eglGetCurrentThread(void)
{
- _EGLThreadInfo *t = _eglGetTSD();
+ _EGLThreadInfo *t = _eglCheckedGetTSD();
if (!t) {
t = _eglCreateThreadInfo();
_eglSetTSD(t);
@@ -202,7 +203,7 @@ _eglGetCurrentThread(void)
void
_eglDestroyCurrentThread(void)
{
- _EGLThreadInfo *t = _eglGetTSD();
+ _EGLThreadInfo *t = _eglCheckedGetTSD();
if (t) {
_eglDestroyThreadInfo(t);
_eglSetTSD(NULL);
@@ -219,7 +220,7 @@ _eglDestroyCurrentThread(void)
EGLBoolean
_eglIsCurrentThreadDummy(void)
{
- _EGLThreadInfo *t = _eglGetTSD();
+ _EGLThreadInfo *t = _eglCheckedGetTSD();
return (!t || t == &dummy_thread);
}
diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h
index f9fdf7bd0f0..8eb241029ec 100644
--- a/src/egl/main/eglcurrent.h
+++ b/src/egl/main/eglcurrent.h
@@ -20,14 +20,6 @@ struct _egl_thread_info
};
-extern EGLBoolean
-_eglInitCurrent(void);
-
-
-extern void
-_eglFiniCurrent(void);
-
-
/**
* Return true if a client API enum can be converted to an index.
*/
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c
index 55de394ef5f..23a3ef5ca82 100644
--- a/src/egl/main/eglglobals.c
+++ b/src/egl/main/eglglobals.c
@@ -21,9 +21,6 @@ _eglInitGlobals(void)
_eglGlobal.Initialized = EGL_TRUE;
_eglGlobal.ClientAPIsMask = 0x0;
-
- if (!_eglInitCurrent())
- _eglLog(_EGL_FATAL, "failed to initialize \"current\" system");
}
}
@@ -34,7 +31,6 @@ _eglInitGlobals(void)
void
_eglDestroyGlobals(void)
{
- _eglFiniCurrent();
/* XXX TODO walk over table entries, deleting each */
_eglDeleteHashTable(_eglGlobal.Displays);
_eglDeleteHashTable(_eglGlobal.Surfaces);