1 #ifndef _ASM_GENERIC_ATOMIC_H_ 2 #define _ASM_GENERIC_ATOMIC_H_ 3 4 /* From QEMU include/qemu/atomic.h */ 5 #define atomic_fetch_inc(ptr) __sync_fetch_and_add(ptr, 1) 6 #define atomic_fetch_dec(ptr) __sync_fetch_and_add(ptr, -1) 7 #define atomic_fetch_add(ptr, n) __sync_fetch_and_add(ptr, n) 8 #define atomic_fetch_sub(ptr, n) __sync_fetch_and_sub(ptr, n) 9 #define atomic_fetch_and(ptr, n) __sync_fetch_and_and(ptr, n) 10 #define atomic_fetch_or(ptr, n) __sync_fetch_and_or(ptr, n) 11 #define atomic_fetch_xor(ptr, n) __sync_fetch_and_xor(ptr, n) 12 13 #define atomic_inc_fetch(ptr) __sync_add_and_fetch(ptr, 1) 14 #define atomic_dec_fetch(ptr) __sync_add_and_fetch(ptr, -1) 15 #define atomic_add_fetch(ptr, n) __sync_add_and_fetch(ptr, n) 16 #define atomic_sub_fetch(ptr, n) __sync_sub_and_fetch(ptr, n) 17 #define atomic_and_fetch(ptr, n) __sync_and_and_fetch(ptr, n) 18 #define atomic_or_fetch(ptr, n) __sync_or_and_fetch(ptr, n) 19 #define atomic_xor_fetch(ptr, n) __sync_xor_and_fetch(ptr, n) 20 21 #endif 22