summaryrefslogtreecommitdiff
path: root/scripts/atomic/fallbacks/fetch_add_unless
blob: c18b940153dfda9ec8c2e47fff85766e8ca3fd82 (plain)
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