mirror of git://sourceware.org/git/glibc.git
(atomic_decrement_if_positive): Adjust for the correct atomic_compare_and_exchange_acq semantics.
This commit is contained in:
parent
f1f8a9ec6f
commit
972209dd7a
|
@ -114,21 +114,20 @@
|
||||||
/* Decrement *MEM if it is > 0, and return the old value. */
|
/* Decrement *MEM if it is > 0, and return the old value. */
|
||||||
#ifndef atomic_decrement_if_positive
|
#ifndef atomic_decrement_if_positive
|
||||||
# define atomic_decrement_if_positive(mem) \
|
# define atomic_decrement_if_positive(mem) \
|
||||||
({ __typeof (*mem) __val; \
|
({ __typeof (*mem) __oldval; \
|
||||||
__typeof (*mem) __oldval; \
|
|
||||||
__typeof (mem) __memp; \
|
__typeof (mem) __memp; \
|
||||||
\
|
\
|
||||||
__val = *__memp; \
|
__val = *__memp; \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (__builtin_expect (__val <= 0, 0)) \
|
__oldval = *__memp; \
|
||||||
|
if (__builtin_expect (__oldval <= 0, 0)) \
|
||||||
break; \
|
break; \
|
||||||
__oldval = __val; \
|
|
||||||
__val = atomic_compare_and_exchange_acq (__memp, __oldval - 1, \
|
|
||||||
__oldval); \
|
|
||||||
} \
|
} \
|
||||||
while (__builtin_expect (__val != __oldval, 0)); \
|
while (__builtin_expect (atomic_compare_and_exchange_acq (__memp, \
|
||||||
__val; })
|
__oldval - 1, \
|
||||||
|
__oldval), 0));\
|
||||||
|
__oldval; })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue