atomic.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2004-2011 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef __ARCH_BLACKFIN_ATOMIC__
  7. #define __ARCH_BLACKFIN_ATOMIC__
  8. #include <asm/cmpxchg.h>
  9. #ifdef CONFIG_SMP
  10. #include <asm/barrier.h>
  11. #include <linux/linkage.h>
  12. #include <linux/types.h>
  13. asmlinkage int __raw_uncached_fetch_asm(const volatile int *ptr);
  14. asmlinkage int __raw_atomic_add_asm(volatile int *ptr, int value);
  15. asmlinkage int __raw_atomic_xadd_asm(volatile int *ptr, int value);
  16. asmlinkage int __raw_atomic_and_asm(volatile int *ptr, int value);
  17. asmlinkage int __raw_atomic_or_asm(volatile int *ptr, int value);
  18. asmlinkage int __raw_atomic_xor_asm(volatile int *ptr, int value);
  19. asmlinkage int __raw_atomic_test_asm(const volatile int *ptr, int value);
  20. #define atomic_read(v) __raw_uncached_fetch_asm(&(v)->counter)
  21. #define atomic_add_return(i, v) __raw_atomic_add_asm(&(v)->counter, i)
  22. #define atomic_sub_return(i, v) __raw_atomic_add_asm(&(v)->counter, -(i))
  23. #define atomic_fetch_add(i, v) __raw_atomic_xadd_asm(&(v)->counter, i)
  24. #define atomic_fetch_sub(i, v) __raw_atomic_xadd_asm(&(v)->counter, -(i))
  25. #define atomic_or(i, v) (void)__raw_atomic_or_asm(&(v)->counter, i)
  26. #define atomic_and(i, v) (void)__raw_atomic_and_asm(&(v)->counter, i)
  27. #define atomic_xor(i, v) (void)__raw_atomic_xor_asm(&(v)->counter, i)
  28. #define atomic_fetch_or(i, v) __raw_atomic_or_asm(&(v)->counter, i)
  29. #define atomic_fetch_and(i, v) __raw_atomic_and_asm(&(v)->counter, i)
  30. #define atomic_fetch_xor(i, v) __raw_atomic_xor_asm(&(v)->counter, i)
  31. #endif
  32. #include <asm-generic/atomic.h>
  33. #endif