summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbje <bje>1998-07-23 15:17:46 +0000
committerbje <bje>1998-07-23 15:17:46 +0000
commit36dfdefb2c77879ceeef04e0b1094e5498b81b46 (patch)
tree91a52f35c0824e4ca7aa67b37d6dae5016e8facf
parenta7d20a157ab17cd479c2a4af62e67ac4f6349cb0 (diff)
1998-07-24 Ben Elliston <bje@cygnus.com>
* cancel.c: New file.
-rw-r--r--cancel.c49
1 files changed, 49 insertions, 0 deletions
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;
+}