1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_METAG_ATOMIC_H
3 #define __ASM_METAG_ATOMIC_H
5 #include <linux/compiler.h>
6 #include <linux/types.h>
7 #include <asm/cmpxchg.h>
8 #include <asm/barrier.h>
10 #if defined(CONFIG_METAG_ATOMICITY_IRQSOFF)
11 /* The simple UP case. */
12 #include <asm-generic/atomic.h>
15 #if defined(CONFIG_METAG_ATOMICITY_LOCK1)
16 #include <asm/atomic_lock1.h>
18 #include <asm/atomic_lnkget.h>
21 #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
23 #define atomic_dec_return(v) atomic_sub_return(1, (v))
24 #define atomic_inc_return(v) atomic_add_return(1, (v))
27 * atomic_inc_and_test - increment and test
28 * @v: pointer of type atomic_t
30 * Atomically increments @v by 1
31 * and returns true if the result is zero, or false for all
34 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
36 #define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0)
37 #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
39 #define atomic_inc(v) atomic_add(1, (v))
40 #define atomic_dec(v) atomic_sub(1, (v))
42 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
43 #define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v)
47 #include <asm-generic/atomic64.h>
49 #endif /* __ASM_METAG_ATOMIC_H */