From 3fe8d46a15cea8859a7e49ec34c1346fab2e2bc5 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 27 Feb 2018 10:21:33 -0500 Subject: [PATCH] atomics: Add parameters to macros Making these functional rather than object macros will prevent later problems with complex macro expansion. Backports commit d1a9f2d12fcfc942924956fbe321aedf4226ccb7 from qemu --- qemu/include/qemu/atomic.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qemu/include/qemu/atomic.h b/qemu/include/qemu/atomic.h index 4de34a5f..bc143f89 100644 --- a/qemu/include/qemu/atomic.h +++ b/qemu/include/qemu/atomic.h @@ -316,11 +316,11 @@ void _ReadWriteBarrier(void); // these return the previous value #define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1) #define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1) -#define atomic_fetch_add __sync_fetch_and_add -#define atomic_fetch_sub __sync_fetch_and_sub -#define atomic_fetch_and __sync_fetch_and_and -#define atomic_fetch_or __sync_fetch_and_or -#define atomic_cmpxchg __sync_val_compare_and_swap +#define atomic_fetch_add(ptr, n) __sync_fetch_and_add(ptr, n) +#define atomic_fetch_sub(ptr, n) __sync_fetch_and_sub(ptr, n) +#define atomic_fetch_and(ptr, n) __sync_fetch_and_and(ptr, n) +#define atomic_fetch_or(ptr, n) __sync_fetch_and_or(ptr, n) +#define atomic_cmpxchg(ptr, old, new) __sync_val_compare_and_swap(ptr, old, new) #endif /* And even shorter names that return void. */