summaryrefslogtreecommitdiff
path: root/cancel.c
diff options
context:
space:
mode:
Diffstat (limited to 'cancel.c')
-rw-r--r--cancel.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/cancel.c b/cancel.c
index 72c41ad..e9e33f1 100644
--- a/cancel.c
+++ b/cancel.c
@@ -47,3 +47,41 @@ pthread_setcanceltype(int type, int *oldtype)
this->canceltype = type;
return 0;
}
+
+int
+pthread_cancel(pthread_t thread)
+{
+ _pthread_threads_thread_t * this;
+
+ this = _PTHREAD_THIS;
+
+ if (this == NULL)
+ {
+ return ESRCH;
+ }
+
+ this->cancelthread = _PTHREAD_YES;
+
+ return 0;
+}
+
+void
+pthread_testcancel(void)
+{
+ _pthread_threads_thread_t * this;
+
+ this = _PTHREAD_THIS;
+
+ if (this == NULL ||
+ this->attr.cancelstate == PTHREAD_CANCEL_DISABLE)
+ {
+ return;
+ }
+
+ if (this->cancelthread == _PTHREAD_YES)
+ {
+ pthread_exit(PTHREAD_CANCELED);
+
+ /* Never reached. */
+ }
+}