summaryrefslogtreecommitdiff
path: root/cancel.c
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-25 14:26:49 +0000
committerrpj <rpj>1998-07-25 14:26:49 +0000
commitee95385721e0dbd4ba637e78b30101f1c9d24e75 (patch)
tree679e77e5555d60e74d3b748be295a67c3b13e9d6 /cancel.c
parent74c0f91a6baa41a437cf2b45a209d5041820c131 (diff)
Sun Jul 26 00:09:59 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* private.c (_pthread_delete_thread_entry): Mutex locks removed. Mutexes must be applied at the caller level. (_pthread_new_thread_entry): Ditto. (_pthread_new_thread_entry): Init cancelstate, canceltype, and cancel_pending to default values. (_pthread_new_thread_entry): Rename "this" to "new". (_pthread_find_thread_entry): Rename "this" to "entry". (_pthread_delete_thread_entry): Rename "thread_entry" to "entry". * create.c (_pthread_start_call): Mutexes changed to _pthread_count_mutex. All access to the threads table entries is under the one mutex. Otherwise chaos reigns. Sat Jul 25 23:16:51 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au> * implement.h (_pthread_threads_thread): Move cancelstate and canceltype members out of pthread_attr_t into here.
Diffstat (limited to 'cancel.c')
-rw-r--r--cancel.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/cancel.c b/cancel.c
index e9e33f1..1b48b28 100644
--- a/cancel.c
+++ b/cancel.c
@@ -6,6 +6,7 @@
*/
#include "pthread.h"
+#include "implement.h"
int
pthread_setcancelstate(int state,
@@ -14,53 +15,53 @@ pthread_setcancelstate(int state,
_pthread_threads_thread_t * this = *_PTHREAD_THIS;
/* Validate the new cancellation state. */
- if (state != PTHREAD_CANCEL_ENABLE || state != PTHREAD_CANCEL_DISABLE)
+ if (state != PTHREAD_CANCEL_ENABLE
+ || state != PTHREAD_CANCEL_DISABLE)
{
return EINVAL;
}
if (oldstate != NULL)
{
- *oldstate = this->cancelability;
+ *oldstate = this->cancelstate;
}
- this->cancelability = state;
+ this->cancelstate = state;
return 0;
}
int
pthread_setcanceltype(int type, int *oldtype)
{
- _pthread_threads_thread_t * this = *_PTHREAD_THIS;
+ _pthread_threads_thread_t * us = _PTHREAD_THIS;
/* Validate the new cancellation type. */
- if (type != PTHREAD_CANCEL_DEFERRED || type != PTHREAD_CANCEL_ASYNCHRONOUS)
+ if (type != PTHREAD_CANCEL_DEFERRED
+ || type != PTHREAD_CANCEL_ASYNCHRONOUS)
{
return EINVAL;
}
if (oldtype != NULL)
{
- *oldtype = this->canceltype;
+ *oldtype = us->canceltype;
}
- this->canceltype = type;
+ us->canceltype = type;
return 0;
}
int
pthread_cancel(pthread_t thread)
{
- _pthread_threads_thread_t * this;
-
- this = _PTHREAD_THIS;
+ _pthread_threads_thread_t * us = _PTHREAD_THIS;
- if (this == NULL)
+ if (us == NULL)
{
return ESRCH;
}
- this->cancelthread = _PTHREAD_YES;
+ us->cancel_pending = TRUE;
return 0;
}
@@ -68,17 +69,17 @@ pthread_cancel(pthread_t thread)
void
pthread_testcancel(void)
{
- _pthread_threads_thread_t * this;
+ _pthread_threads_thread_t * us;
- this = _PTHREAD_THIS;
+ us = _PTHREAD_THIS;
- if (this == NULL ||
- this->attr.cancelstate == PTHREAD_CANCEL_DISABLE)
+ if (us == NULL
+ || us->cancelstate == PTHREAD_CANCEL_DISABLE)
{
return;
}
- if (this->cancelthread == _PTHREAD_YES)
+ if (us->cancel_pending == TRUE)
{
pthread_exit(PTHREAD_CANCELED);