1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
6 #ifndef _ASM_ARC_ATOMIC_H
7 #define _ASM_ARC_ATOMIC_H
11 #include <linux/types.h>
12 #include <linux/compiler.h>
13 #include <asm/cmpxchg.h>
14 #include <asm/barrier.h>
17 #define arch_atomic_read(v) READ_ONCE((v)->counter)
19 #ifdef CONFIG_ARC_HAS_LLSC
20 #include <asm/atomic-llsc.h>
22 #include <asm/atomic-spinlock.h>
25 #define arch_atomic_cmpxchg(v, o, n) \
27 arch_cmpxchg(&((v)->counter), (o), (n)); \
30 #ifdef arch_cmpxchg_relaxed
31 #define arch_atomic_cmpxchg_relaxed(v, o, n) \
33 arch_cmpxchg_relaxed(&((v)->counter), (o), (n)); \
37 #define arch_atomic_xchg(v, n) \
39 arch_xchg(&((v)->counter), (n)); \
42 #ifdef arch_xchg_relaxed
43 #define arch_atomic_xchg_relaxed(v, n) \
45 arch_xchg_relaxed(&((v)->counter), (n)); \
52 #ifdef CONFIG_GENERIC_ATOMIC64
53 #include <asm-generic/atomic64.h>
55 #include <asm/atomic64-arcv2.h>
58 #endif /* !__ASSEMBLY__ */