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