(atomic_decrement_if_positive): Adjust for the correct atomic_compare_and_exchange_ac...
authorUlrich Drepper <drepper@redhat.com>
Thu, 20 Mar 2003 19:42:54 +0000 (19:42 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 20 Mar 2003 19:42:54 +0000 (19:42 +0000)
include/atomic.h

index 87b2df8d21378a1e93b2443f0508bd28c83b2d54..f0cc8cb6432517ca4f21da899164c7d314bed1be 100644 (file)
 
 /* Decrement *MEM if it is > 0, and return the old value.  */
 #ifndef atomic_decrement_if_positive
-# define atomic_decrement_if_positive(mem)                                   \
-  ({ __typeof (*mem) __val;                                                  \
-     __typeof (*mem) __oldval;                                               \
+# define atomic_decrement_if_positive(mem) \
+  ({ __typeof (*mem) __oldval;                                               \
      __typeof (mem) __memp;                                                  \
-                                                                             \
+                                                                             \
      __val = *__memp;                                                        \
      do                                                                              \
        {                                                                     \
-        if (__builtin_expect (__val <= 0, 0))                                \
+        __oldval = *__memp;                                                  \
+        if (__builtin_expect (__oldval <= 0, 0))                             \
           break;                                                             \
-        __oldval = __val;                                                    \
-        __val = atomic_compare_and_exchange_acq (__memp, __oldval - 1,       \
-                                                 __oldval);                  \
        }                                                                     \
-     while (__builtin_expect (__val != __oldval, 0));                        \
-     __val; })
+     while (__builtin_expect (atomic_compare_and_exchange_acq (__memp,       \
+                                                              __oldval - 1,  \
+                                                              __oldval), 0));\
+     __oldval; })
 #endif