[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 02/35] atomics: add atomic_op_fetch variants
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v4 02/35] atomics: add atomic_op_fetch variants |
Date: |
Fri, 16 Sep 2016 10:46:24 -0700 |
From: "Emilio G. Cota" <address@hidden>
This paves the way for upcoming work.
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
Message-Id: <address@hidden>
---
include/qemu/atomic.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h
index 0124289..725144c 100644
--- a/include/qemu/atomic.h
+++ b/include/qemu/atomic.h
@@ -195,6 +195,14 @@
#define atomic_fetch_or(ptr, n) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST)
#define atomic_fetch_xor(ptr, n) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST)
+#define atomic_inc_fetch(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
+#define atomic_dec_fetch(ptr) __atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST)
+#define atomic_add_fetch(ptr, n) __atomic_add_fetch(ptr, n, __ATOMIC_SEQ_CST)
+#define atomic_sub_fetch(ptr, n) __atomic_sub_fetch(ptr, n, __ATOMIC_SEQ_CST)
+#define atomic_and_fetch(ptr, n) __atomic_and_fetch(ptr, n, __ATOMIC_SEQ_CST)
+#define atomic_or_fetch(ptr, n) __atomic_or_fetch(ptr, n, __ATOMIC_SEQ_CST)
+#define atomic_xor_fetch(ptr, n) __atomic_xor_fetch(ptr, n, __ATOMIC_SEQ_CST)
+
/* And even shorter names that return void. */
#define atomic_inc(ptr) ((void) __atomic_fetch_add(ptr, 1,
__ATOMIC_SEQ_CST))
#define atomic_dec(ptr) ((void) __atomic_fetch_sub(ptr, 1,
__ATOMIC_SEQ_CST))
@@ -390,6 +398,15 @@
#define atomic_fetch_and __sync_fetch_and_and
#define atomic_fetch_or __sync_fetch_and_or
#define atomic_fetch_xor __sync_fetch_and_xor
+
+#define atomic_inc_fetch(ptr) __sync_add_and_fetch(ptr, 1)
+#define atomic_dec_fetch(ptr) __sync_add_and_fetch(ptr, -1)
+#define atomic_add_fetch __sync_add_and_fetch
+#define atomic_sub_fetch __sync_sub_and_fetch
+#define atomic_and_fetch __sync_and_and_fetch
+#define atomic_or_fetch __sync_or_and_fetch
+#define atomic_xor_fetch __sync_xor_and_fetch
+
#define atomic_cmpxchg __sync_val_compare_and_swap
/* And even shorter names that return void. */
--
2.5.5
- [Qemu-devel] [PATCH v4 00/35] cmpxchg-based emulation of atomics, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 01/35] atomics: add atomic_xor, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 02/35] atomics: add atomic_op_fetch variants,
Richard Henderson <=
- [Qemu-devel] [PATCH v4 04/35] int128: Use __int128 if available, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 03/35] exec: Avoid direct references to Int128 parts, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 05/35] int128: Add int128_make128, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 07/35] HACK: Always enable parallel_cpus, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 08/35] cputlb: Replace SHIFT with DATA_SIZE, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 10/35] cputlb: Remove includes from softmmu_template.h, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 09/35] cputlb: Move probe_write out of softmmu_template.h, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 12/35] cputlb: Tidy some macros, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 16/35] tcg: Emit barriers with parallel_cpus, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 11/35] cputlb: Move most of iotlb code out of line, Richard Henderson, 2016/09/16