aboutsummaryrefslogtreecommitdiff
path: root/include/asm-frv/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-frv/atomic.h')
-rw-r--r--include/asm-frv/atomic.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asm-frv/atomic.h b/include/asm-frv/atomic.h
index e7596846342..f6539ff569c 100644
--- a/include/asm-frv/atomic.h
+++ b/include/asm-frv/atomic.h
@@ -414,4 +414,16 @@ extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new);
#endif
+#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+
+#define atomic_add_unless(v, a, u) \
+({ \
+ int c, old; \
+ c = atomic_read(v); \
+ while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+ c = old; \
+ c != (u); \
+})
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
#endif /* _ASM_ATOMIC_H */