Richard Henderson <address@hidden> writes:
Add all of cmpxchg, op_fetch, fetch_op, and xchg.
Handle both endian-ness, and sizes up to 8.
Handle expanding non-atomically, when emulating in serial.
Reviewed-by: Emilio G. Cota <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
<snip>
/* Provide shorter names for GCC atomic builtins, return old value */
#define atomic_fetch_inc(ptr) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)
@@ -308,8 +321,11 @@
/* These will only be atomic if the processor does the fetch or store
* in a single issue memory operation
*/
-#define atomic_read(ptr) (*(__typeof__(*ptr) volatile*) (ptr))
-#define atomic_set(ptr, i) ((*(__typeof__(*ptr) volatile*) (ptr)) = (i))
+#define atomic_read__nocheck(p) (*(__typeof__(*ptr) volatile*) (p))
+#define atomic_set__nocheck(p, i) ((*(__typeof__(*ptr) volatile*) (p)) = (i))
+
+#define atomic_read(ptr) atomic_read__nocheck(ptr)
+#define atomic_set(ptr, i) atomic_set__nocheck(ptr,i)
s/ptr/p/ during the transposition:
/* These will only be atomic if the processor does the fetch or store
* in a single issue memory operation
*/
#define atomic_read__nocheck(p) (*(__typeof__(*p) volatile*) (p))
#define atomic_set__nocheck(p, i) ((*(__typeof__(*p) volatile*) (p)) = (i))
#define atomic_read(ptr) atomic_read__nocheck(ptr)
#define atomic_set(ptr, i) atomic_set__nocheck(ptr, i)
Otherwise fine.