atomic.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  4. */
  5. #ifndef _ASM_ARC_ATOMIC_H
  6. #define _ASM_ARC_ATOMIC_H
  7. #ifndef __ASSEMBLY__
  8. #include <linux/types.h>
  9. #include <linux/compiler.h>
  10. #include <asm/cmpxchg.h>
  11. #include <asm/barrier.h>
  12. #include <asm/smp.h>
  13. #define arch_atomic_read(v) READ_ONCE((v)->counter)
  14. #ifdef CONFIG_ARC_HAS_LLSC
  15. #include <asm/atomic-llsc.h>
  16. #else
  17. #include <asm/atomic-spinlock.h>
  18. #endif
  19. #define arch_atomic_cmpxchg(v, o, n) \
  20. ({ \
  21. arch_cmpxchg(&((v)->counter), (o), (n)); \
  22. })
  23. #ifdef arch_cmpxchg_relaxed
  24. #define arch_atomic_cmpxchg_relaxed(v, o, n) \
  25. ({ \
  26. arch_cmpxchg_relaxed(&((v)->counter), (o), (n)); \
  27. })
  28. #endif
  29. #define arch_atomic_xchg(v, n) \
  30. ({ \
  31. arch_xchg(&((v)->counter), (n)); \
  32. })
  33. #ifdef arch_xchg_relaxed
  34. #define arch_atomic_xchg_relaxed(v, n) \
  35. ({ \
  36. arch_xchg_relaxed(&((v)->counter), (n)); \
  37. })
  38. #endif
  39. /*
  40. * 64-bit atomics
  41. */
  42. #ifdef CONFIG_GENERIC_ATOMIC64
  43. #include <asm-generic/atomic64.h>
  44. #else
  45. #include <asm/atomic64-arcv2.h>
  46. #endif
  47. #endif /* !__ASSEMBLY__ */
  48. #endif