Commit f1d40d48 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move more of the thread exit code to the Unix library.

parent 35b063a4
......@@ -284,9 +284,6 @@ TEB *thread_init(void)
*/
void WINAPI RtlExitUserThread( ULONG status )
{
static void *prev_teb;
TEB *teb;
if (status) /* send the exit code to the server (0 is already the default) */
{
SERVER_START_REQ( terminate_thread )
......@@ -306,20 +303,6 @@ void WINAPI RtlExitUserThread( ULONG status )
LdrShutdownThread();
RtlFreeThreadActivationContextStack();
pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
if ((teb = InterlockedExchangePointer( &prev_teb, NtCurrentTeb() )))
{
struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
if (thread_data->pthread_id)
{
pthread_join( thread_data->pthread_id, NULL );
unix_funcs->virtual_free_teb( teb );
}
}
for (;;) unix_funcs->exit_thread( status );
}
......
......@@ -1017,7 +1017,6 @@ static struct unix_funcs unix_funcs =
virtual_get_system_info,
virtual_create_builtin_view,
virtual_alloc_first_teb,
virtual_free_teb,
virtual_alloc_thread_stack,
virtual_handle_fault,
virtual_locked_server_call,
......
......@@ -218,7 +218,21 @@ void CDECL abort_thread( int status )
*/
void CDECL exit_thread( int status )
{
static void *prev_teb;
TEB *teb;
pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
if ((teb = InterlockedExchangePointer( &prev_teb, NtCurrentTeb() )))
{
struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
if (thread_data->pthread_id)
{
pthread_join( thread_data->pthread_id, NULL );
virtual_free_teb( teb );
}
}
signal_exit_thread( status, pthread_exit_wrapper );
}
......
......@@ -63,7 +63,6 @@ extern NTSTATUS CDECL virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsig
extern void CDECL virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN;
extern TEB * CDECL virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
extern void CDECL virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) DECLSPEC_HIDDEN;
extern unsigned int CDECL virtual_locked_server_call( void *req_ptr ) DECLSPEC_HIDDEN;
......@@ -134,6 +133,7 @@ extern NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOO
extern NTSTATUS get_thread_context( HANDLE handle, context_t *context, unsigned int flags, BOOL *self ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
extern void signal_init_threading(void) DECLSPEC_HIDDEN;
extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN;
......
......@@ -2628,7 +2628,7 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb )
/***********************************************************************
* virtual_free_teb
*/
void CDECL virtual_free_teb( TEB *teb )
void virtual_free_teb( TEB *teb )
{
struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
SIZE_T size;
......
......@@ -28,7 +28,7 @@ struct ldt_copy;
struct msghdr;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 18
#define NTDLL_UNIXLIB_VERSION 19
struct unix_funcs
{
......@@ -92,7 +92,6 @@ struct unix_funcs
void (CDECL *virtual_get_system_info)( SYSTEM_BASIC_INFORMATION *info );
NTSTATUS (CDECL *virtual_create_builtin_view)( void *module );
TEB * (CDECL *virtual_alloc_first_teb)(void);
void (CDECL *virtual_free_teb)( TEB *teb );
NTSTATUS (CDECL *virtual_alloc_thread_stack)( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size );
NTSTATUS (CDECL *virtual_handle_fault)( LPCVOID addr, DWORD err, BOOL on_signal_stack );
unsigned int (CDECL *virtual_locked_server_call)( void *req_ptr );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment