From eafdb5db2871e893574fd0da01554d1a50b7471f Mon Sep 17 00:00:00 2001 From: rpj Date: Fri, 24 Jul 1998 12:21:27 +0000 Subject: Fri Jul 24 21:13:55 1998 Ross Johnson * cancel.c (pthread_cancel): Implement. (pthread_testcancel): Implement. * exit.c (pthread_exit): Add comment explaining the longjmp(). * implement.h (_pthread_threads_thread_t): New member cancelthread. (_PTHREAD_YES): Define. (_PTHREAD_NO): Define. (RND_SIZEOF): Remove. * create.c (pthread_create): Rename cancelability to cancelstate. * pthread.h (pthread_attr_t): Rename cancelability to cancelstate. (PTHREAD_CANCELED): Define. --- create.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'create.c') diff --git a/create.c b/create.c index 74d207d..ce12849 100644 --- a/create.c +++ b/create.c @@ -19,13 +19,15 @@ _pthread_start_call(void * thisarg) /* We're now in a running thread. Any local variables here are on this threads private stack so we're safe to leave data in them until we leave. */ - _pthread_threads_thread__t * this = thisarg; + _pthread_threads_thread__t * this; _pthread_call_t * call; unsigned (*func)(void *); void * arg; unsigned ret; int from; + this = (_pthread_threads_thread__t *) thisarg; + if (this->detached == PTHREAD_CREATE_DETACHED) { (void) CloseHandle(this->thread); @@ -39,13 +41,15 @@ _pthread_start_call(void * thisarg) if (from == 0) { + /* Normal return from setjmp(). */ ret = (*func)(arg); _pthread_vacuum(); } else { - /* func() called pthread_exit() which called longjmp(). */ + /* longjmp() teleported us here. + func() called pthread_exit() which called longjmp(). */ _pthread_vacuum(); /* Never returns. */ @@ -82,7 +86,7 @@ pthread_create(pthread_t *thread, attr_copy->stacksize = PTHREAD_STACK_MIN; } - attr_copy->cancelability = attr->cancelability; + attr_copy->cancelstate = attr->cancelstate; attr_copy->canceltype = attr->canceltype; attr_copy->detached = attr->detached; attr_copy->priority = attr->priority; @@ -119,7 +123,7 @@ pthread_create(pthread_t *thread, } else { - /* Undo everything. */ + /* Remove the failed thread entry. */ _pthread_delete_thread_entry(this); } -- cgit v1.2.3