From 492c73cf1f1b3e35b394aec991d1201726ec606d Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 21 Jul 1998 17:04:38 +0000 Subject: Wed Jul 22 00:16:22 1998 Ross Johnson * cleanup.c (_pthread_cleanup_push): Implement. (_pthread_cleanup_pop): Implement. (_pthread_do_cancellation): Implement. These are private to the implementation. The real cleanup functions are macros. See below. * pthread.h (pthread_cleanup_push): Implement as a macro. (pthread_cleanup_pop): Implement as a macro. Because these are macros which start and end a block, the POSIX scoping requirement is observed. See the comment in the file. * exit.c (pthread_exit): Refine the code. * create.c (pthread_create): Code cleanup. * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T) up to multiple of DWORD. Add function prototypes. * private.c (_pthread_getthreadindex): "*thread" should have been "thread". Detect empty slot fail condition. --- exit.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'exit.c') diff --git a/exit.c b/exit.c index a0b3b50..0778fc2 100644 --- a/exit.c +++ b/exit.c @@ -6,37 +6,29 @@ * a thread. */ +#include +#include #include "pthread.h" +#include "implement.h" void pthread_exit(void * value) { - /* The semantics are such that additional tasks must be done for - strict POSIX conformance. We must add code here later which - deals with executing cleanup handlers and such. For now, the - following is mostly correct: */ int t; t = _pthread_getthreadindex(pthread_self()); - handler = _pthread_threads_table[t]->cleanupstack->first; /* Run all the cleanup handlers */ - while (handler != NULL) { - void (* func)(void *); - void * arg; - _pthread_cleanup_node_t * next; - - func = handler->routine; - arg = handler->arg; - _pthread_threads_table[t]->cleanupstack->first = next = handler->next; - free(handler); - (void) func(arg); - } + _pthread_do_cancellation(t); /* CRITICAL SECTION */ pthread_mutex_lock(&_pthread_count_mutex); + + /* Frees attr and cleanupstack */ free(_pthread_threads_table[t]->attr); + _pthread_threads_table[t]->thread = NULL; + pthread_mutex_unlock(&_pthread_count_mutex); /* END CRITICAL SECTION */ -- cgit v1.2.3