1 /* $Id: exit.c,v 1.4 2002/10/29 04:45:38 rex Exp $
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/pthread/exit.c
7 * PURPOSE: Thread termination
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
13 #include <ddk/ntddk.h>
14 #include <ntdll/ldr.h>
18 #include <psx/debug.h>
20 void pthread_exit(void *value_ptr
)
25 /* terminate process if this is the last thread of the current process */
26 nErrCode
= NtQueryInformationThread
35 if(NT_SUCCESS(nErrCode
))
39 INFO("this thread is the last in the current process - about to call exit(0)");
47 "NtQueryInformationThread(ThreadAmILastThread) failed with status %#x. \
48 Can't determine if the current thread is the last in the process. The process \
55 TODO("Notify psxss of thread termination");
57 LdrShutdownThread(); /* detach DLLs */
59 /* kill this thread */
62 sizeof(ULONG
) < sizeof(typeof(value_ptr
)),
64 the value returned from the current thread will be truncated (pointers shorter \
65 than long integers on this architecture?) - expect trouble"
68 INFO("bye bye. Current thread about to die");
70 NtTerminateThread(NtCurrentThread(), (ULONG
)value_ptr
);
72 /* "The pthread_exit() function cannot return to its caller." */
73 NtDelayExecution(FALSE
, NULL
);