xref: /linux/scripts/atomic/fallbacks/fetch_add_unless (revision 9257959a6e5b4fca6fc8e985790bff62c2046f20)
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