1 2 3 4 5 6 7 8 9 10 11 12 13 14
cat << EOF static __always_inline ${int} raw_${atomic}_fetch_add_unless(${atomic}_t *v, ${int} a, ${int} u) { ${int} c = raw_${atomic}_read(v); do { if (unlikely(c == u)) break; } while (!raw_${atomic}_try_cmpxchg(v, &c, c + a)); return c; } EOF