Adjust for new form of compare&exchange macros.
authordrepper <drepper>
Fri, 21 Mar 2003 08:02:04 +0000 (08:02 +0000)
committerdrepper <drepper>
Fri, 21 Mar 2003 08:02:04 +0000 (08:02 +0000)
18 files changed:
nptl/cancellation.c
nptl/cleanup_defer.c
nptl/init.c
nptl/libc-cancellation.c
nptl/old_pthread_cond_broadcast.c
nptl/old_pthread_cond_signal.c
nptl/old_pthread_cond_timedwait.c
nptl/old_pthread_cond_wait.c
nptl/pthread_cancel.c
nptl/pthread_create.c
nptl/pthread_detach.c
nptl/pthread_join.c
nptl/pthread_key_delete.c
nptl/pthread_setcancelstate.c
nptl/pthread_setcanceltype.c
nptl/pthread_timedjoin.c
nptl/pthread_tryjoin.c
nptl/sysdeps/pthread/createthread.c

index 1dfbe4b..d88cae3 100644 (file)
@@ -41,8 +41,8 @@ __pthread_enable_asynccancel (void)
       if (newval == oldval)
        break;
 
       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))
            {
        {
          if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
            {
@@ -72,8 +72,8 @@ __pthread_enable_asynccancel_2 (int *oldvalp)
       if (newval == oldval)
        break;
 
       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))
            {
        {
          if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
            {
@@ -106,8 +106,8 @@ __pthread_disable_asynccancel (int oldtype)
       if (newval == oldval)
        break;
 
       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;
     }
 }
        break;
     }
 }
index 084216e..b72553b 100644 (file)
@@ -41,10 +41,10 @@ _pthread_cleanup_push_defer (buffer, routine, arg)
   /* Disable asynchronous cancellation for now.  */
   if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0))
     {
   /* 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;
     }
 
        cancelhandling = self->cancelhandling;
     }
 
@@ -70,10 +70,10 @@ _pthread_cleanup_pop_restore (buffer, execute)
       && ((cancelhandling = THREAD_GETMEM (self, cancelhandling))
          & CANCELTYPE_BITMASK) == 0)
     {
       && ((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);
        cancelhandling = self->cancelhandling;
 
       CANCELLATION_P (self);
index 7ad2971..4237c6e 100644 (file)
@@ -147,8 +147,8 @@ sigcancel_handler (int sig __attribute ((unused)))
        /* Already canceled or exiting.  */
        break;
 
        /* 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);
        {
          /* Set the return value.  */
          THREAD_SETMEM (self, result, PTHREAD_CANCELED);
index d9ad94f..0d584fb 100644 (file)
@@ -34,11 +34,12 @@ __libc_enable_asynccancel (void)
 {
   struct pthread *self = THREAD_SELF;
   int oldval;
 {
   struct pthread *self = THREAD_SELF;
   int oldval;
+  int newval;
 
 
-  while (1)
+  do
     {
       oldval = THREAD_GETMEM (self, cancelhandling);
     {
       oldval = THREAD_GETMEM (self, cancelhandling);
-      int newval = oldval | CANCELTYPE_BITMASK;
+      newval = oldval | CANCELTYPE_BITMASK;
 
       if (__builtin_expect ((oldval & CANCELED_BITMASK) != 0, 0))
        {
 
       if (__builtin_expect ((oldval & CANCELED_BITMASK) != 0, 0))
        {
@@ -46,8 +47,8 @@ __libc_enable_asynccancel (void)
          if ((oldval & EXITING_BITMASK) != 0)
            break;
 
          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;
 
            /* Somebody else modified the word, try again.  */
            continue;
 
@@ -60,11 +61,9 @@ __libc_enable_asynccancel (void)
 
          /* NOTREACHED */
        }
 
          /* 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;
 }
 
   return oldval;
 }
@@ -80,19 +79,19 @@ __libc_disable_asynccancel (int oldtype)
     return;
 
   struct pthread *self = THREAD_SELF;
     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 (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
 }
 
 #endif
index 0db0aea..3852943 100644 (file)
@@ -46,7 +46,7 @@ __pthread_cond_broadcast_2_0 (cond)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
       (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);
     }
        /* Somebody else just initialized the condvar.  */
        free (newcond);
     }
index ae54209..65beb0b 100644 (file)
@@ -46,7 +46,7 @@ __pthread_cond_signal_2_0 (cond)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
       (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);
     }
        /* Somebody else just initialized the condvar.  */
        free (newcond);
     }
index b30e182..27c1093 100644 (file)
@@ -48,7 +48,7 @@ __pthread_cond_timedwait_2_0 (cond, mutex, abstime)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
       (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);
     }
        /* Somebody else just initialized the condvar.  */
        free (newcond);
     }
index 50505a2..0a503a1 100644 (file)
@@ -47,7 +47,7 @@ __pthread_cond_wait_2_0 (cond, mutex)
       (void) pthread_cond_init (newcond, NULL);
 #endif
 
       (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);
     }
        /* Somebody else just initialized the condvar.  */
        free (newcond);
     }
index f11a924..43b65b6 100644 (file)
@@ -36,10 +36,12 @@ pthread_cancel (th)
     return ESRCH;
 
   int result = 0;
     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
 
       /* 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;
        }
 
          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;
 }
 
   return result;
 }
index ea05747..4121874 100644 (file)
@@ -260,8 +260,8 @@ start_thread (void *arg)
 
              do
                pd->nextevent = __nptl_last_event;
 
              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.  */
            }
 
          /* Now call the function to signal the event.  */
index ff58e3b..ce13a2c 100644 (file)
@@ -36,7 +36,7 @@ pthread_detach (th)
   int result = 0;
 
   /* Mark the thread as detached.  */
   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.
     {
       /* There are two possibilities here.  First, the thread might
         already be detached.  In this case we return EINVAL.
index 5a0ec95..f77c2c9 100644 (file)
@@ -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.  */
 
   /* 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;
 
     /* There is already somebody waiting for the thread.  */
     return EINVAL;
 
index a0145f8..ae7d7c4 100644 (file)
@@ -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.
 
    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)
       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;
     }
        /* We deleted a valid key.  */
        result = 0;
     }
index 3f6ed86..a6af063 100644 (file)
@@ -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.
 
    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.  */
 
       /* 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 ();
        {
          if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
            __do_cancel ();
index bb4b249..5a04635 100644 (file)
@@ -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.
 
    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.  */
 
       /* 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))
            {
        {
          if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
            {
index c83c0ef..1cc0721 100644 (file)
@@ -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.  */
 
   /* 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;
 
     /* There is already somebody waiting for the thread.  */
     return EINVAL;
 
index 88d2e8b..904cb52 100644 (file)
@@ -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.
 
    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.  */
 
   /* 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;
 
     /* There is already somebody waiting for the thread.  */
     return EINVAL;
 
index 797176d..fae744f 100644 (file)
@@ -100,8 +100,8 @@ create_thread (struct pthread *pd, STACK_VARIABLES_PARMS)
          /* Enqueue the descriptor.  */
          do
            pd->nextevent = __nptl_last_event;
          /* 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 ();
 
          /* Now call the function which signals the event.  */
          __nptl_create_event ();