]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/asm-ia64/atomic.h
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/pci-2.6
[linux-2.6-omap-h63xx.git] / include / asm-ia64 / atomic.h
index 15cf7984c48e92849058e5f8c5a006aa1ff312c3..569ec7574baf24b01ce450c4f6a5cdc32d805a60 100644 (file)
@@ -89,13 +89,20 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
 }
 
 #define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
+#define atomic_xchg(v, new) (xchg(&((v)->counter), 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) \
+       for (;;) {                                              \
+               if (unlikely(c == (u)))                         \
+                       break;                                  \
+               old = atomic_cmpxchg((v), c, c + (a));          \
+               if (likely(old == c))                           \
+                       break;                                  \
                c = old;                                        \
+       }                                                       \
        c != (u);                                               \
 })
 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)