while ((old = cmpxchg(&v->counter, c, c c_op i)) != c) \ c = old; \ \ return c; \ } #else #include <linux/irqflags.h> @@ -88,6 +100,20 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ return ret; \ } #define ATOMIC_FETCH_OP(op, c_op...
fetch_orwith CBNZ to make a retry loop. Both make the same loop around ldxr / stxr (for mo_relaxed). It would be a slight improvement to be able to get arbitrary code into the body of that loop, instead of having todo{ stuff }while(!x.compare_exchange_weak(old, new, mo_relaxed)...