@@ -78,37 +78,30 @@
/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
Return the old *MEM value. */
-#if !defined atomic_compare_and_exchange_val_acq \
- && defined __arch_compare_and_exchange_val_32_acq
+#undef atomic_compare_and_exchange_val_acq
# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
- __atomic_val_bysize (__arch_compare_and_exchange_val,acq, \
- mem, newval, oldval)
-#endif
-
-
-#ifndef atomic_compare_and_exchange_val_rel
-# define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \
- atomic_compare_and_exchange_val_acq (mem, newval, oldval)
-#endif
+ ({ \
+ __typeof (*(mem)) __atg3_old = (oldval); \
+ atomic_compare_exchange_acquire (mem, (void*)&__atg3_old, newval); \
+ __atg3_old; \
+ })
+#undef atomic_compare_and_exchange_val_rel
+#define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \
+ ({ \
+ __typeof (*(mem)) __atg3_old = (oldval); \
+ atomic_compare_exchange_release (mem, (void*)&__atg3_old, newval); \
+ __atg3_old; \
+ })
/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
Return zero if *MEM was changed or non-zero if no exchange happened. */
-#ifndef atomic_compare_and_exchange_bool_acq
-# ifdef __arch_compare_and_exchange_bool_32_acq
-# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
- __atomic_bool_bysize (__arch_compare_and_exchange_bool,acq, \
- mem, newval, oldval)
-# else
-# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
- ({ /* Cannot use __oldval here, because macros later in this file might \
- call this macro with __oldval argument. */ \
- __typeof (oldval) __atg3_old = (oldval); \
- atomic_compare_and_exchange_val_acq (mem, newval, __atg3_old) \
- != __atg3_old; \
+#undef atomic_compare_and_exchange_bool_acq
+#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ \
+ __typeof (*(mem)) __atg3_old = (oldval); \
+ !atomic_compare_exchange_acquire (mem, (void*)&__atg3_old, newval); \
})
-# endif
-#endif
/* Store NEWVALUE in *MEM and return the old value. */
@@ -333,6 +326,19 @@ void __atomic_link_error (void);
__atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
__ATOMIC_RELEASE, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_relaxed(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 0, \
+ __ATOMIC_RELAXED, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_acquire(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 0, \
+ __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_release(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 0, \
+ __ATOMIC_RELEASE, __ATOMIC_RELAXED); })
+
# define atomic_exchange_relaxed(mem, desired) \
({ __atomic_check_size((mem)); \
__atomic_exchange_n ((mem), (desired), __ATOMIC_RELAXED); })
@@ -367,8 +367,9 @@ struct locked_map_ptr
/* Try acquiring lock for mapptr, returns true if it succeeds, false
if not. */
static inline bool
-__nscd_acquire_maplock (volatile struct locked_map_ptr *mapptr)
+__nscd_acquire_maplock (volatile struct locked_map_ptr *mapptr_in)
{
+ struct locked_map_ptr *mapptr = (struct locked_map_ptr *) mapptr_in;
int cnt = 0;
while (__builtin_expect (atomic_compare_and_exchange_val_acq (&mapptr->lock,
1, 0) != 0, 0))