|
@@ -274,30 +274,6 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
|
|
|
#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
|
|
|
#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
|
|
|
|
|
|
-/**
|
|
|
- * atomic_fetch_add_unless - add unless the number is a given value
|
|
|
- * @v: pointer of type atomic_t
|
|
|
- * @a: the amount to add to v...
|
|
|
- * @u: ...unless v is equal to u.
|
|
|
- *
|
|
|
- * Atomically adds @a to @v, so long as it was not @u.
|
|
|
- * Returns the old value of @v.
|
|
|
- */
|
|
|
-static __inline__ int atomic_fetch_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;
|
|
|
-}
|
|
|
-
|
|
|
#define atomic_dec_return(v) atomic_sub_return(1, (v))
|
|
|
#define atomic_inc_return(v) atomic_add_return(1, (v))
|
|
|
|