@@ -205,6 +205,14 @@
atomic_cmpxchg__nocheck(ptr, old, new); \
})
+#define atomic_bool_cmpxchg(ptr, old, new) \
+ ({ \
+ typeof(*ptr) _old = (old), _new = (new); \
+ __atomic_compare_exchange(ptr, &_old, &_new, false, \
+ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
+ })
+
+
/* Provide shorter names for GCC atomic builtins, return old value */
#define atomic_fetch_inc(ptr) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)
#define atomic_fetch_dec(ptr) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST)
@@ -432,6 +440,7 @@
#define atomic_cmpxchg(ptr, old, new) __sync_val_compare_and_swap(ptr, old, new)
#define atomic_cmpxchg__nocheck(ptr, old, new) atomic_cmpxchg(ptr, old, new)
+#define atomic_bool_cmpxchg(ptr, old, new) __sync_bool_compare_and_swap(ptr, old, new)
/* And even shorter names that return void. */
#define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1))
This allows for slightly neater code when checking for success of a cmpxchg operation. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- v4 (base-patches) - brought forward from ARM enabling patches - remove the un-needed extra temps --- include/qemu/atomic.h | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.10.1