summaryrefslogtreecommitdiff
path: root/cancel.c
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-28 09:29:22 +0000
committerrpj <rpj>1998-07-28 09:29:22 +0000
commiteca19329e11c472df9b62da0a643de6f90bb7f46 (patch)
tree89fc591dd9db80cc47ab57ca5be2b1e9f116b15c /cancel.c
parent1f340918c533dfa73140cbc72a11a7bdc7acc5b9 (diff)
Tue Jul 28 14:04:29 1998 Ross Johnson <rpj@swan.canberra.edu.au>
* implement.h: Add _PTHREAD_VALID macro. * sync.c (pthread_join): Modify to use the new thread type and _pthread_delete_thread(). Rename "target" to "thread". Remove extra local variable "target". (pthread_detach): Ditto. * signal.c (pthread_sigmask): Move init of "us" out of inner block. Fix instance of "this" should have been "us". Rename "us" to "thread". * sched.c (pthread_setschedparam): Modify to use the new thread type. (pthread_getschedparam): Ditto. * private.c (_pthread_find_thread): Fix return type and arg. * implement.h: Remove _PTHREAD_YES and _PTHREAD_NO. (_pthread_new_thread): Add prototype. (_pthread_find_thread): Ditto. (_pthread_delete_thread): Ditto. (_pthread_new_thread_entry): Remove prototype. (_pthread_find_thread_entry): Ditto. (_pthread_delete_thread_entry): Ditto. ( _PTHREAD_NEW, _PTHREAD_INUSE, _PTHREAD_EXITED, _PTHREAD_REUSE): Add. * create.c (pthread_create): Minor rename "us" to "new" (I need these cues but it doesn't stop me coming out with some major bugs at times). Load start_routine and arg into the thread so the wrapper can call it. * exit.c (pthread_exit): Fix pthread_this should be pthread_self. * cancel.c (pthread_setcancelstate): Change _pthread_threads_thread_t * to pthread_t and init with pthread_this(). (pthread_setcanceltype): Ditto.
Diffstat (limited to 'cancel.c')
-rw-r--r--cancel.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/cancel.c b/cancel.c
index 8974e5c..e79ee08 100644
--- a/cancel.c
+++ b/cancel.c
@@ -12,7 +12,7 @@ int
pthread_setcancelstate(int state,
int *oldstate)
{
- _pthread_threads_thread_t * us = _PTHREAD_THIS;
+ pthread_t us = pthread_self();
/* Validate the new cancellation state. */
if (state != PTHREAD_CANCEL_ENABLE
@@ -33,7 +33,7 @@ pthread_setcancelstate(int state,
int
pthread_setcanceltype(int type, int *oldtype)
{
- _pthread_threads_thread_t * us = _PTHREAD_THIS;
+ pthread_t us = pthread_self();
/* Validate the new cancellation type. */
if (type != PTHREAD_CANCEL_DEFERRED
@@ -54,32 +54,29 @@ pthread_setcanceltype(int type, int *oldtype)
int
pthread_cancel(pthread_t thread)
{
- _pthread_threads_thread_t * us = _PTHREAD_THIS;
-
- if (us == NULL)
+ if (_PTHREAD_VALID(thread)
+ && thread->ptstatus != _PTHREAD_REUSE)
{
- return ESRCH;
+ thread->cancel_pending = TRUE;
+ return 0;
}
- us->cancel_pending = TRUE;
-
- return 0;
+ return ESRCH;
}
void
pthread_testcancel(void)
{
- _pthread_threads_thread_t * us;
+ pthread_t thread;
- us = _PTHREAD_THIS;
+ thread = pthread_self();
- if (us == NULL
- || us->cancelstate == PTHREAD_CANCEL_DISABLE)
+ if (thread->cancelstate == PTHREAD_CANCEL_DISABLE)
{
return;
}
- if (us->cancel_pending == TRUE)
+ if (thread->cancel_pending == TRUE)
{
pthread_exit(PTHREAD_CANCELED);