xref: /linux/scripts/atomic/fallbacks/dec_if_positive (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1cat <<EOF
2	${int} dec, c = raw_${atomic}_read(v);
3
4	do {
5		dec = c - 1;
6		if (unlikely(dec < 0))
7			break;
8	} while (!raw_${atomic}_try_cmpxchg(v, &c, dec));
9
10	return dec;
11EOF
12