aboutsummaryrefslogtreecommitdiff
path: root/include/atomic.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-03-20 19:42:54 +0000
committerUlrich Drepper <drepper@redhat.com>2003-03-20 19:42:54 +0000
commit972209dd7a4df65e335ca1f9200929e412c0871c (patch)
treedac418868a771c28830ab0c7433c603eb8669065 /include/atomic.h
parentf1f8a9ec6f428ccf7ff1b73252b69d57576fe7bb (diff)
downloadglibc-972209dd7a4df65e335ca1f9200929e412c0871c.zip
glibc-972209dd7a4df65e335ca1f9200929e412c0871c.tar.gz
glibc-972209dd7a4df65e335ca1f9200929e412c0871c.tar.bz2
(atomic_decrement_if_positive): Adjust for the correct atomic_compare_and_exchange_acq semantics.
Diffstat (limited to 'include/atomic.h')
-rw-r--r--include/atomic.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/include/atomic.h b/include/atomic.h
index 87b2df8..f0cc8cb 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -113,22 +113,21 @@
/* 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