]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/asm-m68knommu/atomic.h
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[karo-tx-linux.git] / include / asm-m68knommu / atomic.h
index a83631ed8c8f7a487b446893562b80e12172b346..3c1cc153c4154c233fc05dc6f0f0b8f7f3b8e9f9 100644 (file)
@@ -128,6 +128,18 @@ static inline int atomic_sub_return(int i, atomic_t * v)
        return temp;
 }
 
+#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
+
+#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)
+
 #define atomic_dec_return(v) atomic_sub_return(1,(v))
 #define atomic_inc_return(v) atomic_add_return(1,(v))