From 36dfdefb2c77879ceeef04e0b1094e5498b81b46 Mon Sep 17 00:00:00 2001 From: bje Date: Thu, 23 Jul 1998 15:17:46 +0000 Subject: 1998-07-24 Ben Elliston * cancel.c: New file. --- cancel.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 cancel.c (limited to 'cancel.c') diff --git a/cancel.c b/cancel.c new file mode 100644 index 0000000..72c41ad --- /dev/null +++ b/cancel.c @@ -0,0 +1,49 @@ +/* + * cancel.c + * + * Description: + * POSIX thread functions related to thread cancellation. + */ + +#include "pthread.h" + +int +pthread_setcancelstate(int state, + int *oldstate) +{ + _pthread_threads_thread_t * this = *_PTHREAD_THIS; + + /* Validate the new cancellation state. */ + if (state != PTHREAD_CANCEL_ENABLE || state != PTHREAD_CANCEL_DISABLE) + { + return EINVAL; + } + + if (oldstate != NULL) + { + *oldstate = this->cancelability; + } + + this->cancelability = state; + return 0; +} + +int +pthread_setcanceltype(int type, int *oldtype) +{ + _pthread_threads_thread_t * this = *_PTHREAD_THIS; + + /* Validate the new cancellation type. */ + if (type != PTHREAD_CANCEL_DEFERRED || type != PTHREAD_CANCEL_ASYNCHRONOUS) + { + return EINVAL; + } + + if (oldtype != NULL) + { + *oldtype = this->canceltype; + } + + this->canceltype = type; + return 0; +} -- cgit v1.2.3