1 #ifndef _LINUX_ATOMIC_H
2 #define _LINUX_ATOMIC_H
3 #include <asm/atomic.h>
6 * atomic_inc_not_zero_hint - increment if not null
7 * @v: pointer of type atomic_t
8 * @hint: probable value of the atomic before the increment
10 * This version of atomic_inc_not_zero() gives a hint of probable
11 * value of the atomic. This helps processor to not read the memory
12 * before doing the atomic read/modify/write cycle, lowering
13 * number of bus transactions on some arches.
15 * Returns: 0 if increment was not done, 1 otherwise.
17 #ifndef atomic_inc_not_zero_hint
18 static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
22 /* sanity test, should be removed by compiler if hint is a constant */
24 return atomic_inc_not_zero(v);
27 val = atomic_cmpxchg(v, c, c + 1);
37 #ifndef atomic_inc_unless_negative
38 static inline int atomic_inc_unless_negative(atomic_t *p)
41 for (v = 0; v >= 0; v = v1) {
42 v1 = atomic_cmpxchg(p, v, v + 1);
50 #ifndef atomic_dec_unless_positive
51 static inline int atomic_dec_unless_positive(atomic_t *p)
54 for (v = 0; v <= 0; v = v1) {
55 v1 = atomic_cmpxchg(p, v, v - 1);
63 #ifndef CONFIG_ARCH_HAS_ATOMIC_OR
64 static inline void atomic_or(int i, atomic_t *v)
72 } while (atomic_cmpxchg(v, old, new) != old);
74 #endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR */
76 #endif /* _LINUX_ATOMIC_H */