linux-zen-desktop/scripts/atomic/fallbacks/dec_if_positive

12 lines
176 B
Plaintext
Raw Normal View History

2023-08-30 17:31:07 +02:00
cat <<EOF
2023-10-24 12:59:35 +02:00
${int} dec, c = raw_${atomic}_read(v);
2023-08-30 17:31:07 +02:00
do {
dec = c - 1;
if (unlikely(dec < 0))
break;
2023-10-24 12:59:35 +02:00
} while (!raw_${atomic}_try_cmpxchg(v, &c, dec));
2023-08-30 17:31:07 +02:00
return dec;
EOF