summaryrefslogtreecommitdiff
path: root/exit.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-01-03 18:47:50 +0000
committerrpj <rpj>1999-01-03 18:47:50 +0000
commit36f0ed4155fdab7b12c5c5ddf4252170fac0a77e (patch)
tree2d8ed62df0b72d42a74b383d389ee7c28a0324da /exit.c
parent4650bcf1f1efd88a0c8f502c28945bfabd7ef6db (diff)
Merge John Bossom's code into the main trunk. See ChangeLog for details.snapshot-1999-01-04-1305
This will be tagged as snapshot-1999-01-04-1305
Diffstat (limited to 'exit.c')
-rw-r--r--exit.c87
1 files changed, 31 insertions, 56 deletions
diff --git a/exit.c b/exit.c
index 3472dca..5177e88 100644
--- a/exit.c
+++ b/exit.c
@@ -6,69 +6,44 @@
* a thread.
*/
-#include <windows.h>
-#include <process.h>
#include "pthread.h"
#include "implement.h"
-void
-_pthread_vacuum(void)
-{
- /* Run all the handlers. */
- _pthread_handler_pop_all(_PTHREAD_CLEANUP_STACK,
- _PTHREAD_HANDLER_EXECUTE);
-
- /* Pop any atfork handlers without executing them. */
- _pthread_handler_pop_all(_PTHREAD_FORKPREPARE_STACK,
- _PTHREAD_HANDLER_NOEXECUTE);
-
- _pthread_handler_pop_all(_PTHREAD_FORKPARENT_STACK,
- _PTHREAD_HANDLER_NOEXECUTE);
-
- _pthread_handler_pop_all(_PTHREAD_FORKCHILD_STACK,
- _PTHREAD_HANDLER_NOEXECUTE);
-}
+/*
+ * Code contributed by John E. Bossom <JEB>.
+ */
-void
-_pthread_exit(pthread_t thread, void * value, int return_code)
+int
+pthread_exit (void *value_ptr)
+ /*
+ * ------------------------------------------------------
+ * DOCPUBLIC
+ * This function terminates the calling thread, returning
+ * the value 'value_ptr' to any joining thread.
+ *
+ * PARAMETERS
+ * value_ptr
+ * a generic data value (i.e. not the address of a value)
+ *
+ *
+ * DESCRIPTION
+ * This function terminates the calling thread, returning
+ * the value 'value_ptr' to any joining thread.
+ * NOTE: thread should be joinable.
+ *
+ * RESULTS
+ * N/A
+ *
+ * ------------------------------------------------------
+ */
{
- int detachstate;
+ _pthread_callUserDestroyRoutines(pthread_getspecific(_pthread_selfThreadKey));
- /* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_table_mutex);
+ _endthreadex ((unsigned) value_ptr);
- /* Copy value into the thread entry so it can be given
- to any joining threads. */
- thread->joinvalueptr = value;
+ return (0);
- pthread_mutex_unlock(&_pthread_table_mutex);
- /* END CRITICAL SECTION */
+} /* pthread_exit */
- _pthread_vacuum();
+/* </JEB> */
- /* CRITICAL SECTION */
- pthread_mutex_lock(&_pthread_table_mutex);
-
- /* Remove the thread entry on exit only if the thread is detached
- AND there are no waiting joins. Otherwise the thread entry will
- be deleted by the last waiting pthread_join() after this thread
- has terminated. */
-
- if (pthread_attr_getdetachstate(&thread->attr, &detachstate) == 0
- && detachstate == PTHREAD_CREATE_DETACHED
- && thread->join_count == 0)
- {
- (void) _pthread_delete_thread(thread);
- }
-
- pthread_mutex_unlock(&_pthread_table_mutex);
- /* END CRITICAL SECTION */
-
- _endthreadex(return_code);
-}
-
-void
-pthread_exit(void * value)
-{
- _pthread_exit(pthread_self(), value, 0);
-}