From 67de808c4bd4601310a053272a2822b8d5c0e0c6 Mon Sep 17 00:00:00 2001 From: roblabla Date: Thu, 28 Dec 2017 21:11:43 +0100 Subject: [PATCH] Implement pthread_setcancelstate --- pthread/rthread_thread.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pthread/rthread_thread.c b/pthread/rthread_thread.c index a82be0ce..a2b13591 100644 --- a/pthread/rthread_thread.c +++ b/pthread/rthread_thread.c @@ -431,17 +431,17 @@ pthread_testcancel(void) int pthread_setcancelstate(int state, int *oldstatep) { - return ENOSYS; -#if 0 - struct tib *tib = TIB_GET(); + pthread_t self = pthread_self(); int oldstate; - oldstate = tib->tib_cantcancel & CANCEL_DISABLED ? + if (self == NULL) + return (EINVAL); + oldstate = self->tib_cantcancel & CANCEL_DISABLED ? PTHREAD_CANCEL_DISABLE : PTHREAD_CANCEL_ENABLE; if (state == PTHREAD_CANCEL_ENABLE) { - tib->tib_cantcancel &= ~CANCEL_DISABLED; + self->tib_cantcancel &= ~CANCEL_DISABLED; } else if (state == PTHREAD_CANCEL_DISABLE) { - tib->tib_cantcancel |= CANCEL_DISABLED; + self->tib_cantcancel |= CANCEL_DISABLED; } else { return (EINVAL); } @@ -449,7 +449,6 @@ pthread_setcancelstate(int state, int *oldstatep) *oldstatep = oldstate; return (0); -#endif } int