about summary refs log tree commit diff
path: root/nptl/libc-cancellation.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-03-21 08:03:25 +0000
committerUlrich Drepper <drepper@redhat.com>2003-03-21 08:03:25 +0000
commit5a3ab2fc180056cb14eaeae0f571421be81e371b (patch)
treeaf48122e19c238a39db145412a11b1b551d472e6 /nptl/libc-cancellation.c
parent18627f615b80b51778a65cf588f2741ad5f9b0a7 (diff)
downloadglibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.tar.gz
glibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.tar.xz
glibc-5a3ab2fc180056cb14eaeae0f571421be81e371b.zip
Update.
2003-03-21  Ulrich Drepper  <drepper@redhat.com>

	* cancellation.c: Adjust for new form of compare&exchange macros.
	* cleanup_defer.c: Likewise.
	* init.c: Likewise.
	* libc-cancellation.c: Likewise.
	* old_pthread_cond_broadcast.c: Likewise.
	* old_pthread_cond_signal.c: Likewise.
	* old_pthread_cond_timedwait.c: Likewise.
	* old_pthread_cond_wait.c: Likewise.
	* pthread_cancel.c: Likewise.
	* pthread_create.c: Likewise.
	* pthread_detach.c: Likewise.
	* pthread_join.c: Likewise.
	* pthread_key_delete.c: Likewise.
	* pthread_setcancelstate.c: Likewise.
	* pthread_setcanceltype.c: Likewise.
	* pthread_timedjoin.c: Likewise.
	* pthread_tryjoin.c: Likewise.
	* sysdeps/pthread/createthread.c: Likewise.
Diffstat (limited to 'nptl/libc-cancellation.c')
-rw-r--r--nptl/libc-cancellation.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/nptl/libc-cancellation.c b/nptl/libc-cancellation.c
index d9ad94fa61..0d584fbb33 100644
--- a/nptl/libc-cancellation.c
+++ b/nptl/libc-cancellation.c
@@ -34,11 +34,12 @@ __libc_enable_asynccancel (void)
 {
   struct pthread *self = THREAD_SELF;
   int oldval;
+  int newval;
 
-  while (1)
+  do
     {
       oldval = THREAD_GETMEM (self, cancelhandling);
-      int newval = oldval | CANCELTYPE_BITMASK;
+      newval = oldval | CANCELTYPE_BITMASK;
 
       if (__builtin_expect ((oldval & CANCELED_BITMASK) != 0, 0))
 	{
@@ -46,8 +47,8 @@ __libc_enable_asynccancel (void)
 	  if ((oldval & EXITING_BITMASK) != 0)
 	    break;
 
-	  if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					       oldval) != 0)
+	  if (atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						    newval, oldval))
 	    /* Somebody else modified the word, try again.  */
 	    continue;
 
@@ -60,11 +61,9 @@ __libc_enable_asynccancel (void)
 
 	  /* NOTREACHED */
 	}
-
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
-	break;
     }
+  while (atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+					       newval, oldval));
 
   return oldval;
 }
@@ -80,19 +79,19 @@ __libc_disable_asynccancel (int oldtype)
     return;
 
   struct pthread *self = THREAD_SELF;
+  int oldval;
+  int newval;
 
-  while (1)
+  do
     {
-      int oldval = THREAD_GETMEM (self, cancelhandling);
-      int newval = oldval & ~CANCELTYPE_BITMASK;
+      oldval = THREAD_GETMEM (self, cancelhandling);
+      newval = oldval & ~CANCELTYPE_BITMASK;
 
       if (newval == oldval)
 	break;
-
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
-	break;
     }
+  while (atomic_compare_and_exchange_bool_acq (&self->cancelhandling, newval,
+					       oldval));
 }
 
 #endif