linux/scripts/atomic/fallbacks/fetch_add_unless

15 lines
257 B
Plaintext
Executable File

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