author: Mark Rutland <mark.rutland@arm.com> 2018-09-04 11:48:25 +0100
committer: Ingo Molnar <mingo@kernel.org> 2018-11-01 11:00:36 +0100
commit: ace9bad4df2684f31cbfe8c4ce7a0f5d92b27925
parent: 01a14bda11add9dcd4a59200f13834d634559935
Commit Summary:
Diffstat:
1 file changed, 13 insertions, 0 deletions
diff --git a/scripts/atomic/fallbacks/dec_if_positive b/scripts/atomic/fallbacks/dec_if_positive
new file mode 100644
index 000000000000..c52eacec43c8
--- /dev/null
+++ b/scripts/atomic/fallbacks/dec_if_positive
@@ -0,0 +1,15 @@
+cat <<EOF
+static inline ${ret}
+${atomic}_dec_if_positive(${atomic}_t *v)
+{
+ ${int} dec, c = ${atomic}_read(v);
+
+ do {
+ dec = c - 1;
+ if (unlikely(dec < 0))
+ break;
+ } while (!${atomic}_try_cmpxchg(v, &c, dec));
+
+ return dec;
+}
+EOF