https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4067eb1454912b363bb71…
commit 4067eb1454912b363bb710b0aa78607dad703f5a
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Nov 20 19:55:21 2017 +0100
[OPENGL32]
- Get rid of the TLS based implementation
CORE-14024
---
dll/opengl/opengl32/dllmain.c | 48 ---------------------
dll/opengl/opengl32/glapi_x86.s | 17 +-------
dll/opengl/opengl32/opengl32.h | 95 -----------------------------------------
3 files changed, 1 insertion(+), 159 deletions(-)
diff --git a/dll/opengl/opengl32/dllmain.c b/dll/opengl/opengl32/dllmain.c
index 65649751fa..1aefff046b 100644
--- a/dll/opengl/opengl32/dllmain.c
+++ b/dll/opengl/opengl32/dllmain.c
@@ -7,61 +7,21 @@
#include "opengl32.h"
-#ifdef OPENGL32_USE_TLS
-DWORD OglTlsIndex = 0xFFFFFFFF;
-
-BOOL init_tls_data(void)
-{
- struct Opengl32_ThreadData* ThreadData;
-
- ThreadData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ThreadData));
- if(!ThreadData)
- return FALSE;
- TlsSetValue(OglTlsIndex, ThreadData);
- ThreadData->glDispatchTable = &StubTable.glDispatchTable;
- ThreadData->hglrc = NULL;
- ThreadData->hdc = NULL;
- ThreadData->dc_data = NULL;
- return TRUE;
-}
-
-#endif
-
BOOL WINAPI
DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
{
-#ifdef OPENGL32_USE_TLS
- struct Opengl32_ThreadData* ThreadData;
-#endif
switch ( Reason )
{
case DLL_PROCESS_ATTACH:
-#ifdef OPENGL32_USE_TLS
- OglTlsIndex = TlsAlloc();
- if(OglTlsIndex == TLS_OUT_OF_INDEXES)
- return FALSE;
-#endif
/* Initialize Context list */
InitializeListHead(&ContextListHead);
/* no break */
case DLL_THREAD_ATTACH:
-#ifdef OPENGL32_USE_TLS
- if (!init_tls_data())
- return FALSE;
-#endif // defined(OPENGL32_USE_TLS)
break;
case DLL_THREAD_DETACH:
/* Set NULL context for this thread */
wglMakeCurrent(NULL, NULL);
- /* Clean up */
-#ifdef OPENGL32_USE_TLS
- ThreadData = TlsGetValue(OglTlsIndex);
- if(ThreadData)
- HeapFree(GetProcessHeap(), 0, ThreadData);
-#else
- NtCurrentTeb()->glTable = NULL;
-#endif // defined(OPENGL32_USE_TLS)
break;
case DLL_PROCESS_DETACH:
/* Clean up */
@@ -71,15 +31,7 @@ DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
wglMakeCurrent(NULL, NULL);
IntDeleteAllContexts();
IntDeleteAllICDs();
-#ifdef OPENGL32_USE_TLS
- ThreadData = TlsGetValue(OglTlsIndex);
- if(ThreadData)
- HeapFree(GetProcessHeap(), 0, ThreadData);
-#endif
}
-#ifdef OPENGL32_USE_TLS
- TlsFree(OglTlsIndex);
-#endif
break;
}
diff --git a/dll/opengl/opengl32/glapi_x86.s b/dll/opengl/opengl32/glapi_x86.s
index 017dc7ef81..a1eec929d0 100644
--- a/dll/opengl/opengl32/glapi_x86.s
+++ b/dll/opengl/opengl32/glapi_x86.s
@@ -16,31 +16,16 @@ ASSUME nothing
.code
-#ifdef OPENG32_USE_TLS
-EXTERN _OglTlsIndex:DWORD
-EXTERN _TlsGetValue@4:PROC
-#endif
-
MACRO(USE_GL_FUNC, name, offset, stack)
PUBLIC _gl&name&@&stack
.PROC _gl&name&@&stack
-FPO 0, 0, 0, 0, 0, FRAME_FPO
+ FPO 0, 0, 0, 0, 0, FRAME_FPO
-#ifdef OPENG32_USE_TLS
- push _OglTlsIndex
- call _TlsGetValue@4
- /* If we don't have a thread data, this is a nop */
- test eax, eax
- jz name&_fast_ret
- /* Get the GL table */
- mov eax, [eax]
-#else
/* Get the TEB */
mov eax, fs:[TEB_SELF]
/* Get the GL table */
mov eax, [eax + TEB_GL_TABLE]
-#endif
/* If we don't have a dispatch table, this is a nop */
test eax, eax
diff --git a/dll/opengl/opengl32/opengl32.h b/dll/opengl/opengl32/opengl32.h
index b454ac5051..8808ca55ff 100644
--- a/dll/opengl/opengl32/opengl32.h
+++ b/dll/opengl/opengl32/opengl32.h
@@ -112,99 +112,6 @@ struct wgl_dc_data
void IntDeleteAllContexts(void);
void IntDeleteAllICDs(void);
-#ifdef OPENGL32_USE_TLS
-extern DWORD OglTlsIndex;
-
-struct Opengl32_ThreadData
-{
- const GLDISPATCHTABLE* glDispatchTable;
- HGLRC hglrc;
- HDC hdc;
- struct wgl_dc_data* dc_data;
- PVOID* icdData;
-};
-C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0);
-
-/* dllmain.c */
-BOOL init_tls_data(void);
-
-FORCEINLINE
-void
-IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
-{
- struct Opengl32_ThreadData* thread_data = TlsGetValue(OglTlsIndex);
- if (!thread_data)
- {
- OutputDebugStringA("Calling init_tls_data from IntMakeCurrent\n");
- if (!init_tls_data())
- OutputDebugStringA("init_tls_data failed, brace for impact...\n");
-
- thread_data = TlsGetValue(OglTlsIndex);
- }
-
- thread_data->hglrc = hglrc;
- thread_data->hdc = hdc;
- thread_data->dc_data = dc_data;
-}
-
-FORCEINLINE
-HGLRC
-IntGetCurrentRC(void)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- return data ? data->hglrc : NULL;
-}
-
-FORCEINLINE
-HDC
-IntGetCurrentDC(void)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- return data ? data->hdc : NULL;
-}
-
-FORCEINLINE
-struct wgl_dc_data*
-IntGetCurrentDcData(void)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- return data->dc_data;
-}
-
-FORCEINLINE
-const GLDISPATCHTABLE *
-IntGetCurrentDispatchTable(void)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- return data->glDispatchTable;
-}
-
-FORCEINLINE
-void
-IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- data->glDispatchTable = table;
-}
-
-FORCEINLINE
-void
-IntSetCurrentICDPrivate(void* value)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- data->icdData = value;
-}
-
-FORCEINLINE
-void*
-IntGetCurrentICDPrivate(void)
-{
- struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
- return data->icdData;
-}
-
-
-#else
FORCEINLINE
const GLDISPATCHTABLE*
IntGetCurrentDispatchTable(void)
@@ -265,8 +172,6 @@ IntGetCurrentICDPrivate(void)
return (void*)NtCurrentTeb()->glReserved1[0];
}
-#endif // defined(OPENGL32_USE_TLS)
-
FORCEINLINE
DHGLRC
IntGetCurrentDHGLRC(void)