From d286b8a660b0435f9441a4ed4811848d0307060e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 1 Jun 2005 11:08:39 +0000 Subject: [PATCH] Use standard TLS functions instead of a TEB internal field to access per-thread data. --- dlls/x11drv/desktop.c | 8 ++++---- dlls/x11drv/event.c | 2 +- dlls/x11drv/init.c | 1 + dlls/x11drv/x11drv.h | 4 ++-- dlls/x11drv/x11drv_main.c | 8 ++++++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dlls/x11drv/desktop.c b/dlls/x11drv/desktop.c index 32e65374454..8b356df1fc2 100644 --- a/dlls/x11drv/desktop.c +++ b/dlls/x11drv/desktop.c @@ -68,7 +68,7 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data ) HWND hwnd; Atom atom = x11drv_atom(WM_DELETE_WINDOW); - NtCurrentTeb()->driver_data = driver_data; + TlsSetValue( thread_data_tls_index, driver_data ); display = thread_display(); hwnd = GetDesktopWindow(); @@ -94,15 +94,15 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data ) */ void X11DRV_create_desktop_thread(void) { - HANDLE handle = CreateThread( NULL, 0, desktop_thread, NtCurrentTeb()->driver_data, - 0, &desktop_tid ); + HANDLE handle = CreateThread( NULL, 0, desktop_thread, + TlsGetValue( thread_data_tls_index ), 0, &desktop_tid ); if (!handle) { MESSAGE( "Could not create desktop thread\n" ); ExitProcess(1); } /* we transferred our driver data to the new thread */ - NtCurrentTeb()->driver_data = NULL; + TlsSetValue( thread_data_tls_index, NULL ); CloseHandle( handle ); } diff --git a/dlls/x11drv/event.c b/dlls/x11drv/event.c index 8fb152d2212..8f7b3aa61f0 100644 --- a/dlls/x11drv/event.c +++ b/dlls/x11drv/event.c @@ -276,7 +276,7 @@ DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, { HANDLE new_handles[MAXIMUM_WAIT_OBJECTS+1]; /* FIXME! */ DWORD i, ret; - struct x11drv_thread_data *data = NtCurrentTeb()->driver_data; + struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index ); if (!data || data->process_event_count) return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL, diff --git a/dlls/x11drv/init.c b/dlls/x11drv/init.c index bc8664256ee..62470b84e3d 100644 --- a/dlls/x11drv/init.c +++ b/dlls/x11drv/init.c @@ -25,6 +25,7 @@ #include "windef.h" #include "winbase.h" +#include "winreg.h" #include "x11drv.h" #include "x11font.h" #include "ddrawi.h" diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h index df960fa96f3..6fe2983d7f4 100644 --- a/dlls/x11drv/x11drv.h +++ b/dlls/x11drv/x11drv.h @@ -63,7 +63,6 @@ typedef int Status; #include "wingdi.h" #include "winuser.h" #include "ddrawi.h" -#include "thread.h" #include "wine/list.h" #define MAX_PIXELFORMATS 8 @@ -517,10 +516,11 @@ struct x11drv_thread_data }; extern struct x11drv_thread_data *x11drv_init_thread_data(void); +extern DWORD thread_data_tls_index; inline static struct x11drv_thread_data *x11drv_thread_data(void) { - struct x11drv_thread_data *data = NtCurrentTeb()->driver_data; + struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index ); if (!data) data = x11drv_init_thread_data(); return data; } diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c index a66af96e4ac..38cf09a269c 100644 --- a/dlls/x11drv/x11drv_main.c +++ b/dlls/x11drv/x11drv_main.c @@ -81,6 +81,7 @@ int client_side_with_render = 1; int client_side_antialias_with_core = 1; int client_side_antialias_with_render = 1; int using_wine_desktop = 0; +DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES; static BOOL synchronous; /* run in synchronous mode? */ static BOOL desktop_dbl_buf = TRUE; @@ -315,6 +316,8 @@ static BOOL process_attach(void) setup_options(); + if ((thread_data_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE; + /* Open display */ if (!(display = XOpenDisplay( NULL ))) return FALSE; @@ -393,7 +396,7 @@ static BOOL process_attach(void) */ static void thread_detach(void) { - struct x11drv_thread_data *data = NtCurrentTeb()->driver_data; + struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index ); if (data) { @@ -427,6 +430,7 @@ static void process_detach(void) X11DRV_GDI_Finalize(); DeleteCriticalSection( &X11DRV_CritSection ); + TlsFree( thread_data_tls_index ); } @@ -479,7 +483,7 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) data->grab_window = None; data->last_focus = 0; data->selection_wnd = 0; - NtCurrentTeb()->driver_data = data; + TlsSetValue( thread_data_tls_index, data ); if (desktop_tid) AttachThreadInput( GetCurrentThreadId(), desktop_tid, TRUE ); return data; }