From 32a589b1ea1365c8651b0692d0350403fde7b6ff Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 11 Mar 2003 23:26:35 +0000 Subject: Update. * cancellation.c (__pthread_enable_asynccancel_2): New function. * pthreadP.h: Declare __pthread_enable_asynccancel_2. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S (__pthread_cond_timedwait): Use __pthread_enable_asynccancel_2 instead of __pthread_enable_asynccancel. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S (__pthread_cond_wait): Likewise. * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise. * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Likewise. --- nptl/cancellation.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'nptl/cancellation.c') diff --git a/nptl/cancellation.c b/nptl/cancellation.c index f136bbb4c4..1dfbe4baca 100644 --- a/nptl/cancellation.c +++ b/nptl/cancellation.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -57,6 +57,35 @@ __pthread_enable_asynccancel (void) return oldval; } +/* XXX Ideally we have only one version. But this needs preparation. */ +void +internal_function attribute_hidden +__pthread_enable_asynccancel_2 (int *oldvalp) +{ + struct pthread *self = THREAD_SELF; + + while (1) + { + int oldval = *oldvalp = THREAD_GETMEM (self, cancelhandling); + int newval = oldval | CANCELTYPE_BITMASK; + + if (newval == oldval) + break; + + if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval, + oldval) == 0) + { + if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval)) + { + THREAD_SETMEM (self, result, PTHREAD_CANCELED); + __do_cancel (); + } + + break; + } + } +} + void internal_function attribute_hidden -- cgit v1.2.3