Use standard TLS functions instead of a TEB internal field to access

per-thread data.
This commit is contained in:
Alexandre Julliard 2005-06-01 11:08:39 +00:00
parent a55450da8c
commit d286b8a660
5 changed files with 14 additions and 9 deletions

View File

@ -68,7 +68,7 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
HWND hwnd; HWND hwnd;
Atom atom = x11drv_atom(WM_DELETE_WINDOW); Atom atom = x11drv_atom(WM_DELETE_WINDOW);
NtCurrentTeb()->driver_data = driver_data; TlsSetValue( thread_data_tls_index, driver_data );
display = thread_display(); display = thread_display();
hwnd = GetDesktopWindow(); hwnd = GetDesktopWindow();
@ -94,15 +94,15 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
*/ */
void X11DRV_create_desktop_thread(void) void X11DRV_create_desktop_thread(void)
{ {
HANDLE handle = CreateThread( NULL, 0, desktop_thread, NtCurrentTeb()->driver_data, HANDLE handle = CreateThread( NULL, 0, desktop_thread,
0, &desktop_tid ); TlsGetValue( thread_data_tls_index ), 0, &desktop_tid );
if (!handle) if (!handle)
{ {
MESSAGE( "Could not create desktop thread\n" ); MESSAGE( "Could not create desktop thread\n" );
ExitProcess(1); ExitProcess(1);
} }
/* we transferred our driver data to the new thread */ /* we transferred our driver data to the new thread */
NtCurrentTeb()->driver_data = NULL; TlsSetValue( thread_data_tls_index, NULL );
CloseHandle( handle ); CloseHandle( handle );
} }

View File

@ -276,7 +276,7 @@ DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
{ {
HANDLE new_handles[MAXIMUM_WAIT_OBJECTS+1]; /* FIXME! */ HANDLE new_handles[MAXIMUM_WAIT_OBJECTS+1]; /* FIXME! */
DWORD i, ret; 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) if (!data || data->process_event_count)
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL, return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,

View File

@ -25,6 +25,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winreg.h"
#include "x11drv.h" #include "x11drv.h"
#include "x11font.h" #include "x11font.h"
#include "ddrawi.h" #include "ddrawi.h"

View File

@ -63,7 +63,6 @@ typedef int Status;
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "ddrawi.h" #include "ddrawi.h"
#include "thread.h"
#include "wine/list.h" #include "wine/list.h"
#define MAX_PIXELFORMATS 8 #define MAX_PIXELFORMATS 8
@ -517,10 +516,11 @@ struct x11drv_thread_data
}; };
extern struct x11drv_thread_data *x11drv_init_thread_data(void); 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) 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(); if (!data) data = x11drv_init_thread_data();
return data; return data;
} }

View File

@ -81,6 +81,7 @@ int client_side_with_render = 1;
int client_side_antialias_with_core = 1; int client_side_antialias_with_core = 1;
int client_side_antialias_with_render = 1; int client_side_antialias_with_render = 1;
int using_wine_desktop = 0; int using_wine_desktop = 0;
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
static BOOL synchronous; /* run in synchronous mode? */ static BOOL synchronous; /* run in synchronous mode? */
static BOOL desktop_dbl_buf = TRUE; static BOOL desktop_dbl_buf = TRUE;
@ -315,6 +316,8 @@ static BOOL process_attach(void)
setup_options(); setup_options();
if ((thread_data_tls_index = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE;
/* Open display */ /* Open display */
if (!(display = XOpenDisplay( NULL ))) return FALSE; if (!(display = XOpenDisplay( NULL ))) return FALSE;
@ -393,7 +396,7 @@ static BOOL process_attach(void)
*/ */
static void thread_detach(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) if (data)
{ {
@ -427,6 +430,7 @@ static void process_detach(void)
X11DRV_GDI_Finalize(); X11DRV_GDI_Finalize();
DeleteCriticalSection( &X11DRV_CritSection ); 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->grab_window = None;
data->last_focus = 0; data->last_focus = 0;
data->selection_wnd = 0; data->selection_wnd = 0;
NtCurrentTeb()->driver_data = data; TlsSetValue( thread_data_tls_index, data );
if (desktop_tid) AttachThreadInput( GetCurrentThreadId(), desktop_tid, TRUE ); if (desktop_tid) AttachThreadInput( GetCurrentThreadId(), desktop_tid, TRUE );
return data; return data;
} }