Commit 06105495 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move all thread exit processing to exit_thread(), and make RtlExitUserThread() CPU-specific.

parent f124c7cc
...@@ -78,6 +78,7 @@ extern size_t server_init_thread( void *entry_point ); ...@@ -78,6 +78,7 @@ extern size_t server_init_thread( void *entry_point );
extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... ); extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... );
extern void DECLSPEC_NORETURN server_protocol_perror( const char *err ); extern void DECLSPEC_NORETURN server_protocol_perror( const char *err );
extern void DECLSPEC_NORETURN abort_thread( int status ); extern void DECLSPEC_NORETURN abort_thread( int status );
extern void DECLSPEC_NORETURN exit_thread( int status );
extern sigset_t server_block_set; extern sigset_t server_block_set;
extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ); extern void server_enter_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset );
extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset ); extern void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sigset );
......
...@@ -2274,7 +2274,7 @@ __ASM_GLOBAL_FUNC(call_thread_func, ...@@ -2274,7 +2274,7 @@ __ASM_GLOBAL_FUNC(call_thread_func,
"call *8(%ebp)\n\t" "call *8(%ebp)\n\t"
"leal -4(%ebp),%esp\n\t" "leal -4(%ebp),%esp\n\t"
"pushl %eax\n\t" "pushl %eax\n\t"
"call " __ASM_NAME("RtlExitUserThread") "\n\t" "call " __ASM_NAME("exit_thread") "\n\t"
"int $3" ) "int $3" )
/*********************************************************************** /***********************************************************************
...@@ -2294,6 +2294,13 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -2294,6 +2294,13 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
abort(); /* should not be reached */ abort(); /* should not be reached */
} }
/***********************************************************************
* RtlExitUserThread (NTDLL.@)
*/
void WINAPI RtlExitUserThread( ULONG status )
{
exit_thread( status );
}
/********************************************************************** /**********************************************************************
* DbgBreakPoint (NTDLL.@) * DbgBreakPoint (NTDLL.@)
......
...@@ -1093,7 +1093,7 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -1093,7 +1093,7 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
{ {
__TRY __TRY
{ {
RtlExitUserThread( entry( arg )); exit_thread( entry( arg ));
} }
__EXCEPT(unhandled_exception_filter) __EXCEPT(unhandled_exception_filter)
{ {
...@@ -1103,6 +1103,14 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -1103,6 +1103,14 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
abort(); /* should not be reached */ abort(); /* should not be reached */
} }
/***********************************************************************
* RtlExitUserThread (NTDLL.@)
*/
void WINAPI RtlExitUserThread( ULONG status )
{
exit_thread( status );
}
/********************************************************************** /**********************************************************************
* DbgBreakPoint (NTDLL.@) * DbgBreakPoint (NTDLL.@)
*/ */
......
...@@ -835,7 +835,7 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -835,7 +835,7 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
{ {
__TRY __TRY
{ {
RtlExitUserThread( entry( arg )); exit_thread( entry( arg ));
} }
__EXCEPT(unhandled_exception_filter) __EXCEPT(unhandled_exception_filter)
{ {
...@@ -845,6 +845,14 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -845,6 +845,14 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
abort(); /* should not be reached */ abort(); /* should not be reached */
} }
/***********************************************************************
* RtlExitUserThread (NTDLL.@)
*/
void WINAPI RtlExitUserThread( ULONG status )
{
exit_thread( status );
}
/********************************************************************** /**********************************************************************
* DbgBreakPoint (NTDLL.@) * DbgBreakPoint (NTDLL.@)
*/ */
......
...@@ -2558,7 +2558,7 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -2558,7 +2558,7 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
{ {
__TRY __TRY
{ {
RtlExitUserThread( entry( arg )); exit_thread( entry( arg ));
} }
__EXCEPT(unhandled_exception_filter) __EXCEPT(unhandled_exception_filter)
{ {
...@@ -2569,6 +2569,15 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) ...@@ -2569,6 +2569,15 @@ void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg )
} }
/***********************************************************************
* RtlExitUserThread (NTDLL.@)
*/
void WINAPI RtlExitUserThread( ULONG status )
{
exit_thread( status );
}
/********************************************************************** /**********************************************************************
* __wine_enter_vm86 (NTDLL.@) * __wine_enter_vm86 (NTDLL.@)
*/ */
......
...@@ -353,11 +353,29 @@ void abort_thread( int status ) ...@@ -353,11 +353,29 @@ void abort_thread( int status )
/*********************************************************************** /***********************************************************************
* exit_thread * exit_thread
*/ */
static void DECLSPEC_NORETURN exit_thread( int status ) void exit_thread( int status )
{ {
static void *prev_teb; static void *prev_teb;
TEB *teb; TEB *teb;
if (status) /* send the exit code to the server (0 is already the default) */
{
SERVER_START_REQ( terminate_thread )
{
req->handle = wine_server_obj_handle( GetCurrentThread() );
req->exit_code = status;
wine_server_call( req );
}
SERVER_END_REQ;
}
if (interlocked_xchg_add( &nb_threads, -1 ) <= 1)
{
LdrShutdownProcess();
exit( status );
}
LdrShutdownThread();
RtlAcquirePebLock(); RtlAcquirePebLock();
RemoveEntryList( &NtCurrentTeb()->TlsLinks ); RemoveEntryList( &NtCurrentTeb()->TlsLinks );
RtlReleasePebLock(); RtlReleasePebLock();
...@@ -365,7 +383,6 @@ static void DECLSPEC_NORETURN exit_thread( int status ) ...@@ -365,7 +383,6 @@ static void DECLSPEC_NORETURN exit_thread( int status )
RtlFreeHeap( GetProcessHeap(), 0, NtCurrentTeb()->TlsExpansionSlots ); RtlFreeHeap( GetProcessHeap(), 0, NtCurrentTeb()->TlsExpansionSlots );
pthread_sigmask( SIG_BLOCK, &server_block_set, NULL ); pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
if (interlocked_xchg_add( &nb_threads, -1 ) <= 1) exit( status );
if ((teb = interlocked_xchg_ptr( &prev_teb, NtCurrentTeb() ))) if ((teb = interlocked_xchg_ptr( &prev_teb, NtCurrentTeb() )))
{ {
...@@ -567,36 +584,6 @@ error: ...@@ -567,36 +584,6 @@ error:
/*********************************************************************** /***********************************************************************
* RtlExitUserThread (NTDLL.@)
*/
void WINAPI RtlExitUserThread( ULONG status )
{
BOOL last;
SERVER_START_REQ( terminate_thread )
{
/* send the exit code to the server */
req->handle = wine_server_obj_handle( GetCurrentThread() );
req->exit_code = status;
wine_server_call( req );
last = reply->last;
}
SERVER_END_REQ;
if (last)
{
LdrShutdownProcess();
exit( status );
}
else
{
LdrShutdownThread();
exit_thread( status );
}
}
/***********************************************************************
* NtOpenThread (NTDLL.@) * NtOpenThread (NTDLL.@)
* ZwOpenThread (NTDLL.@) * ZwOpenThread (NTDLL.@)
*/ */
......
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