about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog21
-rw-r--r--nptl/cancellation.c12
-rw-r--r--nptl/cleanup_defer.c16
-rw-r--r--nptl/init.c4
-rw-r--r--nptl/libc-cancellation.c29
-rw-r--r--nptl/old_pthread_cond_broadcast.c2
-rw-r--r--nptl/old_pthread_cond_signal.c2
-rw-r--r--nptl/old_pthread_cond_timedwait.c2
-rw-r--r--nptl/old_pthread_cond_wait.c2
-rw-r--r--nptl/pthread_cancel.c18
-rw-r--r--nptl/pthread_create.c4
-rw-r--r--nptl/pthread_detach.c2
-rw-r--r--nptl/pthread_join.c5
-rw-r--r--nptl/pthread_key_delete.c6
-rw-r--r--nptl/pthread_setcancelstate.c6
-rw-r--r--nptl/pthread_setcanceltype.c6
-rw-r--r--nptl/pthread_timedjoin.c4
-rw-r--r--nptl/pthread_tryjoin.c4
-rw-r--r--nptl/sysdeps/pthread/createthread.c4
19 files changed, 85 insertions, 64 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index c68ad8df68..3029aaf6f9 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,24 @@
+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.
+
 2003-03-20  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Include <atomic.h>.
diff --git a/nptl/cancellation.c b/nptl/cancellation.c
index 1dfbe4baca..d88cae3aa7 100644
--- a/nptl/cancellation.c
+++ b/nptl/cancellation.c
@@ -41,8 +41,8 @@ __pthread_enable_asynccancel (void)
       if (newval == oldval)
 	break;
 
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
+      if (! atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						  newval, oldval))
 	{
 	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
 	    {
@@ -72,8 +72,8 @@ __pthread_enable_asynccancel_2 (int *oldvalp)
       if (newval == oldval)
 	break;
 
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
+      if (! atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						  newval, oldval))
 	{
 	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
 	    {
@@ -106,8 +106,8 @@ __pthread_disable_asynccancel (int oldtype)
       if (newval == oldval)
 	break;
 
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
+      if (! atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						  newval, oldval))
 	break;
     }
 }
diff --git a/nptl/cleanup_defer.c b/nptl/cleanup_defer.c
index 084216e44b..b72553bdc0 100644
--- a/nptl/cleanup_defer.c
+++ b/nptl/cleanup_defer.c
@@ -41,10 +41,10 @@ _pthread_cleanup_push_defer (buffer, routine, arg)
   /* Disable asynchronous cancellation for now.  */
   if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0))
     {
-      while (atomic_compare_and_exchange_acq (&self->cancelhandling,
-					      cancelhandling
-					      & ~CANCELTYPE_BITMASK,
-					      cancelhandling) != 0)
+      while (atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						   cancelhandling
+						   & ~CANCELTYPE_BITMASK,
+						   cancelhandling))
 	cancelhandling = self->cancelhandling;
     }
 
@@ -70,10 +70,10 @@ _pthread_cleanup_pop_restore (buffer, execute)
       && ((cancelhandling = THREAD_GETMEM (self, cancelhandling))
 	  & CANCELTYPE_BITMASK) == 0)
     {
-      while (atomic_compare_and_exchange_acq (&self->cancelhandling,
-					      cancelhandling
-					      | CANCELTYPE_BITMASK,
-					      cancelhandling) != 0)
+      while (atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						   cancelhandling
+						   | CANCELTYPE_BITMASK,
+						   cancelhandling))
 	cancelhandling = self->cancelhandling;
 
       CANCELLATION_P (self);
diff --git a/nptl/init.c b/nptl/init.c
index 7ad29716ae..4237c6eb48 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -147,8 +147,8 @@ sigcancel_handler (int sig __attribute ((unused)))
 	/* Already canceled or exiting.  */
 	break;
 
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
+      if (! atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						  newval, oldval))
 	{
 	  /* Set the return value.  */
 	  THREAD_SETMEM (self, result, PTHREAD_CANCELED);
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
diff --git a/nptl/old_pthread_cond_broadcast.c b/nptl/old_pthread_cond_broadcast.c
index 0db0aeab96..3852943fac 100644
--- a/nptl/old_pthread_cond_broadcast.c
+++ b/nptl/old_pthread_cond_broadcast.c
@@ -46,7 +46,7 @@ __pthread_cond_broadcast_2_0 (cond)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
-      if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0)
+      if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
 	/* Somebody else just initialized the condvar.  */
 	free (newcond);
     }
diff --git a/nptl/old_pthread_cond_signal.c b/nptl/old_pthread_cond_signal.c
index ae54209e4a..65beb0b9db 100644
--- a/nptl/old_pthread_cond_signal.c
+++ b/nptl/old_pthread_cond_signal.c
@@ -46,7 +46,7 @@ __pthread_cond_signal_2_0 (cond)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
-      if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0)
+      if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
 	/* Somebody else just initialized the condvar.  */
 	free (newcond);
     }
diff --git a/nptl/old_pthread_cond_timedwait.c b/nptl/old_pthread_cond_timedwait.c
index b30e182b40..27c10938d3 100644
--- a/nptl/old_pthread_cond_timedwait.c
+++ b/nptl/old_pthread_cond_timedwait.c
@@ -48,7 +48,7 @@ __pthread_cond_timedwait_2_0 (cond, mutex, abstime)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
-      if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0)
+      if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
 	/* Somebody else just initialized the condvar.  */
 	free (newcond);
     }
diff --git a/nptl/old_pthread_cond_wait.c b/nptl/old_pthread_cond_wait.c
index 50505a265e..0a503a1cdc 100644
--- a/nptl/old_pthread_cond_wait.c
+++ b/nptl/old_pthread_cond_wait.c
@@ -47,7 +47,7 @@ __pthread_cond_wait_2_0 (cond, mutex)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
-      if (atomic_compare_and_exchange_acq (&cond->cond, newcond, NULL) != 0)
+      if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
 	/* Somebody else just initialized the condvar.  */
 	free (newcond);
     }
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index f11a9243fb..43b65b6c02 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -36,10 +36,12 @@ pthread_cancel (th)
     return ESRCH;
 
   int result = 0;
-  while (1)
+  int oldval;
+  int newval;
+  do
     {
-      int oldval = pd->cancelhandling;
-      int newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
+      oldval = pd->cancelhandling;
+      newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
 
       /* Avoid doing unnecessary work.  The atomic operation can
 	 potentially be expensive if the bug has to be locked and
@@ -66,13 +68,11 @@ pthread_cancel (th)
 
 	  break;
 	}
-
-      /* Mark the thread as canceled.  This has to be done
-	 atomically since other bits could be modified as well.  */
-      if (atomic_compare_and_exchange_acq (&pd->cancelhandling, newval,
-					   oldval) == 0)
-	break;
     }
+  /* Mark the thread as canceled.  This has to be done
+     atomically since other bits could be modified as well.  */
+  while (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling, newval,
+					       oldval));
 
   return result;
 }
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index ea057473a0..41218745d6 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -260,8 +260,8 @@ start_thread (void *arg)
 
 	      do
 		pd->nextevent = __nptl_last_event;
-	      while (atomic_compare_and_exchange_acq (&__nptl_last_event, pd,
-						      pd->nextevent) != 0);
+	      while (atomic_compare_and_exchange_bool_acq (&__nptl_last_event,
+							   pd, pd->nextevent));
 	    }
 
 	  /* Now call the function to signal the event.  */
diff --git a/nptl/pthread_detach.c b/nptl/pthread_detach.c
index ff58e3bde5..ce13a2cfde 100644
--- a/nptl/pthread_detach.c
+++ b/nptl/pthread_detach.c
@@ -36,7 +36,7 @@ pthread_detach (th)
   int result = 0;
 
   /* Mark the thread as detached.  */
-  if (atomic_compare_and_exchange_acq (&pd->joinid, pd, NULL) != 0)
+  if (atomic_compare_and_exchange_bool_acq (&pd->joinid, pd, NULL))
     {
       /* There are two possibilities here.  First, the thread might
 	 already be detached.  In this case we return EINVAL.
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index 5a0ec95722..f77c2c9f98 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -66,8 +66,9 @@ pthread_join (threadid, thread_return)
 
   /* Wait for the thread to finish.  If it is already locked something
      is wrong.  There can only be one waiter.  */
-  if (__builtin_expect (atomic_compare_and_exchange_acq (&pd->joinid, self,
-							 NULL) != 0, 0))
+  if (__builtin_expect (atomic_compare_and_exchange_bool_acq (&pd->joinid,
+							      self,
+							      NULL), 0))
     /* There is already somebody waiting for the thread.  */
     return EINVAL;
 
diff --git a/nptl/pthread_key_delete.c b/nptl/pthread_key_delete.c
index a0145f8efa..ae7d7c459e 100644
--- a/nptl/pthread_key_delete.c
+++ b/nptl/pthread_key_delete.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 <drepper@redhat.com>, 2002.
 
@@ -33,8 +33,8 @@ pthread_key_delete (key)
       unsigned int seq = __pthread_keys[key].seq;
 
       if (__builtin_expect (! KEY_UNUSED (seq), 1)
-	  && atomic_compare_and_exchange_acq (&__pthread_keys[key].seq,
-					      seq + 1, seq) == 0)
+	  && ! atomic_compare_and_exchange_bool_acq (&__pthread_keys[key].seq,
+						     seq + 1, seq))
 	/* We deleted a valid key.  */
 	result = 0;
     }
diff --git a/nptl/pthread_setcancelstate.c b/nptl/pthread_setcancelstate.c
index 3f6ed863c3..a6af063d67 100644
--- a/nptl/pthread_setcancelstate.c
+++ b/nptl/pthread_setcancelstate.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 <drepper@redhat.com>, 2002.
 
@@ -54,8 +54,8 @@ __pthread_setcancelstate (state, oldstate)
 
       /* Update the cancel handling word.  This has to be done
 	 atomically since other bits could be modified as well.  */
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
+      if (! atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						  newval, oldval))
 	{
 	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
 	    __do_cancel ();
diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c
index bb4b24943e..5a046351b9 100644
--- a/nptl/pthread_setcanceltype.c
+++ b/nptl/pthread_setcanceltype.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 <drepper@redhat.com>, 2002.
 
@@ -54,8 +54,8 @@ __pthread_setcanceltype (type, oldtype)
 
       /* Update the cancel handling word.  This has to be done
 	 atomically since other bits could be modified as well.  */
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-					   oldval) == 0)
+      if (! atomic_compare_and_exchange_bool_acq (&self->cancelhandling,
+						  newval, oldval))
 	{
 	  if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
 	    {
diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c
index c83c0ef953..1cc07213c8 100644
--- a/nptl/pthread_timedjoin.c
+++ b/nptl/pthread_timedjoin.c
@@ -63,8 +63,8 @@ pthread_timedjoin_np (threadid, thread_return, abstime)
 
   /* Wait for the thread to finish.  If it is already locked something
      is wrong.  There can only be one waiter.  */
-  if (__builtin_expect (atomic_compare_and_exchange_acq (&pd->joinid, self,
-							 NULL) != 0, 0))
+  if (__builtin_expect (atomic_compare_and_exchange_bool_acq (&pd->joinid,
+							      self, NULL), 0))
     /* There is already somebody waiting for the thread.  */
     return EINVAL;
 
diff --git a/nptl/pthread_tryjoin.c b/nptl/pthread_tryjoin.c
index 88d2e8bd4e..904cb5280b 100644
--- a/nptl/pthread_tryjoin.c
+++ b/nptl/pthread_tryjoin.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 <drepper@redhat.com>, 2002.
 
@@ -59,7 +59,7 @@ pthread_tryjoin_np (threadid, thread_return)
 
   /* Wait for the thread to finish.  If it is already locked something
      is wrong.  There can only be one waiter.  */
-  if (atomic_compare_and_exchange_acq (&pd->joinid, self, NULL) != 0)
+  if (atomic_compare_and_exchange_bool_acq (&pd->joinid, self, NULL))
     /* There is already somebody waiting for the thread.  */
     return EINVAL;
 
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c
index 797176d0b6..fae744f298 100644
--- a/nptl/sysdeps/pthread/createthread.c
+++ b/nptl/sysdeps/pthread/createthread.c
@@ -100,8 +100,8 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
 	  /* Enqueue the descriptor.  */
 	  do
 	    pd->nextevent = __nptl_last_event;
-	  while (atomic_compare_and_exchange_acq (&__nptl_last_event, pd,
-						  pd->nextevent) != 0);
+	  while (atomic_compare_and_exchange_bool_acq (&__nptl_last_event, pd,
+						       pd->nextevent) != 0);
 
 	  /* Now call the function which signals the event.  */
 	  __nptl_create_event ();