aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-03-21 07:37:36 +0000
committerUlrich Drepper <drepper@redhat.com>2003-03-21 07:37:36 +0000
commit18627f615b80b51778a65cf588f2741ad5f9b0a7 (patch)
treee83cc490c5571419ae0e953ea293766a44ec3f5f /include
parent* sysdeps/mips/bits/setjmp.h: n32 has only 6 call-saved fpregs. * sysdeps/mip... (diff)
downloadglibc-18627f615b80b51778a65cf588f2741ad5f9b0a7.tar.gz
glibc-18627f615b80b51778a65cf588f2741ad5f9b0a7.tar.bz2
glibc-18627f615b80b51778a65cf588f2741ad5f9b0a7.zip
Define atomic_compare_and_exchange_val_acq, atomic_compare_and_exchange_val_rel, atomic_compare_and_exchange_bool_acq, and atomic_compare_and_exchange_bool_rel instead of atomic_compare_and_exchange_acq and atomic_compare_and_exchange_rel.
Diffstat (limited to 'include')
-rw-r--r--include/atomic.h88
1 files changed, 63 insertions, 25 deletions
diff --git a/include/atomic.h b/include/atomic.h
index f0cc8cb643..3063037e0d 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -25,27 +25,60 @@
#include <bits/atomic.h>
-#ifndef atomic_compare_and_exchange_acq
-# define atomic_compare_and_exchange_acq(mem, newval, oldval) \
- ({ __typeof (__arch_compare_and_exchange_32_acq (mem, newval, oldval)) \
- __result; \
+#ifndef atomic_compare_and_exchange_val_acq
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ __typeof (*mem) __result; \
if (sizeof (*mem) == 1) \
- __result = __arch_compare_and_exchange_8_acq (mem, newval, oldval); \
+ __result = __arch_compare_and_exchange_val_8_acq (mem, newval, oldval);\
else if (sizeof (*mem) == 2) \
- __result = __arch_compare_and_exchange_16_acq (mem, newval, oldval); \
+ __result = __arch_compare_and_exchange_val_16_acq (mem, newval,oldval);\
else if (sizeof (*mem) == 4) \
- __result = __arch_compare_and_exchange_32_acq (mem, newval, oldval); \
+ __result = __arch_compare_and_exchange_val_32_acq (mem, newval,oldval);\
else if (sizeof (*mem) == 8) \
- __result = __arch_compare_and_exchange_64_acq (mem, newval, oldval); \
+ __result = __arch_compare_and_exchange_val_64_acq (mem, newval,oldval);\
else \
abort (); \
__result; })
#endif
-#ifndef atomic_compare_and_exchange_rel
-# define atomic_compare_and_exchange_rel(mem, oldval, newval) \
- atomic_compare_and_exchange_acq (mem, oldval, newval)
+#ifndef atomic_compare_and_exchange_val_rel
+# define atomic_compare_and_exchange_val_rel(mem, oldval, newval) \
+ atomic_compare_and_exchange_val_acq (mem, oldval, newval)
+#endif
+
+
+#ifndef atomic_compare_and_exchange_bool_acq
+# ifdef __arch_compare_and_exchange_bool_32_acq
+# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ ({ __typeof (__arch_compare_and_exchange_bool_32_acq (mem, 0, 0)) __result; \
+ if (sizeof (*mem) == 1) \
+ __result = __arch_compare_and_exchange_bool_8_acq (mem, newval, \
+ oldval); \
+ else if (sizeof (*mem) == 2) \
+ __result = __arch_compare_and_exchange_bool_16_acq (mem, newval, \
+ oldval); \
+ else if (sizeof (*mem) == 4) \
+ __result = __arch_compare_and_exchange_bool_32_acq (mem, newval, \
+ oldval); \
+ else if (sizeof (*mem) == 8) \
+ __result = __arch_compare_and_exchange_bool_64_acq (mem, newval, \
+ oldval); \
+ else \
+ abort (); \
+ __result; })
+# else
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ __typeof (oldval) __oldval = (oldval); \
+ atomic_compare_and_exchange_val_acq (mem, newval, __oldval) != __oldval; \
+ })
+# endif
+#endif
+
+
+#ifndef atomic_compare_and_exchange_bool_rel
+# define atomic_compare_and_exchange_bool_rel(mem, oldval, newval) \
+ atomic_compare_and_exchange_bool_acq (mem, oldval, newval)
#endif
@@ -58,9 +91,10 @@
\
do \
__oldval = (*__memp); \
- while (__builtin_expect (atomic_compare_and_exchange_acq (__memp, \
- __value, \
- __oldval), 0));\
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __value, \
+ __oldval),\
+ 0)); \
\
__oldval; })
#endif
@@ -75,10 +109,11 @@
\
do \
__oldval = (*__memp); \
- while (__builtin_expect (atomic_compare_and_exchange_acq (__memp, \
- __oldval \
- + __value, \
- __oldval), 0));\
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __oldval \
+ + __value,\
+ __oldval),\
+ 0)); \
\
__oldval; })
#endif
@@ -124,9 +159,11 @@
if (__builtin_expect (__oldval <= 0, 0)) \
break; \
} \
- while (__builtin_expect (atomic_compare_and_exchange_acq (__memp, \
- __oldval - 1, \
- __oldval), 0));\
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __oldval \
+ - 1, \
+ __oldval),\
+ 0));\
__oldval; })
#endif
@@ -157,10 +194,11 @@
\
do \
__oldval = (*__memp); \
- while (__builtin_expect (atomic_compare_and_exchange_acq (__memp, \
- __oldval \
- | __mask, \
- __oldval), 0));\
+ while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
+ __oldval \
+ | __mask, \
+ __oldval),\
+ 0)); \
\
__oldval & __mask; })
#endif