X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=include%2Fasm-xtensa%2Fatomic.h;h=b3b23540f14d2c5087e4b8d09d519378e73e726a;hb=59c51591a0ac7568824f541f57de967e88adaa07;hp=fe105a123924207ea5769829250d4ab15faaab7b;hpb=ea9b395fe20ac74be788f415af2622ac8f0c35c7;p=powerpc.git diff --git a/include/asm-xtensa/atomic.h b/include/asm-xtensa/atomic.h index fe105a1239..b3b23540f1 100644 --- a/include/asm-xtensa/atomic.h +++ b/include/asm-xtensa/atomic.h @@ -13,7 +13,6 @@ #ifndef _XTENSA_ATOMIC_H #define _XTENSA_ATOMIC_H -#include #include typedef struct { volatile int counter; } atomic_t; @@ -235,14 +234,21 @@ static inline int atomic_sub_return(int i, atomic_t * v) * Atomically adds @a to @v, so long as it was not @u. * Returns non-zero if @v was not @u, and zero otherwise. */ -#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); \ -}) +static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) +{ + int c, old; + c = atomic_read(v); + for (;;) { + if (unlikely(c == (u))) + break; + old = atomic_cmpxchg((v), c, c + (a)); + if (likely(old == c)) + break; + c = old; + } + return c != (u); +} + #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)