atomic.h 972 B

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