Commit | Line | Data |
---|---|---|
6006c0d8 JH |
1 | #ifndef __ASM_METAG_ATOMIC_H |
2 | #define __ASM_METAG_ATOMIC_H | |
3 | ||
4 | #include <linux/compiler.h> | |
5 | #include <linux/types.h> | |
6 | #include <asm/cmpxchg.h> | |
40074dec | 7 | #include <asm/barrier.h> |
6006c0d8 JH |
8 | |
9 | #if defined(CONFIG_METAG_ATOMICITY_IRQSOFF) | |
10 | /* The simple UP case. */ | |
11 | #include <asm-generic/atomic.h> | |
12 | #else | |
13 | ||
14 | #if defined(CONFIG_METAG_ATOMICITY_LOCK1) | |
15 | #include <asm/atomic_lock1.h> | |
16 | #else | |
17 | #include <asm/atomic_lnkget.h> | |
18 | #endif | |
19 | ||
20 | #define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) | |
21 | ||
22 | #define atomic_dec_return(v) atomic_sub_return(1, (v)) | |
23 | #define atomic_inc_return(v) atomic_add_return(1, (v)) | |
24 | ||
25 | /* | |
26 | * atomic_inc_and_test - increment and test | |
27 | * @v: pointer of type atomic_t | |
28 | * | |
29 | * Atomically increments @v by 1 | |
30 | * and returns true if the result is zero, or false for all | |
31 | * other cases. | |
32 | */ | |
33 | #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0) | |
34 | ||
35 | #define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0) | |
36 | #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) | |
37 | ||
38 | #define atomic_inc(v) atomic_add(1, (v)) | |
39 | #define atomic_dec(v) atomic_sub(1, (v)) | |
40 | ||
41 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | |
42 | ||
6006c0d8 JH |
43 | #endif |
44 | ||
45 | #define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v) | |
46 | ||
47 | #include <asm-generic/atomic64.h> | |
48 | ||
49 | #endif /* __ASM_METAG_ATOMIC_H */ |