]> err.no Git - linux-2.6/blobdiff - include/asm-x86_64/atomic.h
Pull button into release branch
[linux-2.6] / include / asm-x86_64 / atomic.h
index 6b540237a2f805c7b94fbe2f002828ba50d21058..cecbf7baa6aa346297efa3bb14480bddd5e4236a 100644 (file)
@@ -2,6 +2,7 @@
 #define __ARCH_X86_64_ATOMIC__
 
 #include <linux/config.h>
+#include <asm/types.h>
 
 /* atomic_t should be 32 bit signed type */
 
@@ -404,8 +405,14 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
 ({                                                             \
        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)