Split out TLS code into separate modules.

This allows the TLS code to be re-used by partial ports like EGL.
This commit is contained in:
Camilla Berglund
2014-03-30 14:37:20 +02:00
parent 2889f484f4
commit 78efc18079
16 changed files with 278 additions and 88 deletions
+6 -22
View File
@@ -32,22 +32,6 @@
#include <assert.h>
// Thread local storage attribute macro
//
#if defined(_MSC_VER)
#define _GLFW_TLS __declspec(thread)
#elif defined(__GNUC__)
#define _GLFW_TLS __thread
#else
#define _GLFW_TLS
#endif
// The per-thread current context/window pointer
//
static _GLFW_TLS _GLFWwindow* _glfwCurrentWindow = NULL;
// Return a description of the specified EGL error
//
static const char* getErrorString(EGLint error)
@@ -207,6 +191,9 @@ static GLboolean chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
//
int _glfwInitContextAPI(void)
{
if (!_glfwInitTLS())
return GL_FALSE;
_glfw.egl.display = eglGetDisplay((EGLNativeDisplayType)_GLFW_EGL_NATIVE_DISPLAY);
if (_glfw.egl.display == EGL_NO_DISPLAY)
{
@@ -237,6 +224,8 @@ int _glfwInitContextAPI(void)
void _glfwTerminateContextAPI(void)
{
eglTerminate(_glfw.egl.display);
_glfwTerminateTLS();
}
#define setEGLattrib(attribName, attribValue) \
@@ -482,12 +471,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
_glfwCurrentWindow = window;
}
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
{
return _glfwCurrentWindow;
_glfwSetCurrentContext(window);
}
void _glfwPlatformSwapBuffers(_GLFWwindow* window)