summaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2023-04-05 16:17:08 +0200
committerIngo Molnar <mingo@kernel.org>2023-04-29 09:09:16 +0200
commitd994f2c8e2410ebcb928df67baa6f04e29bc9d3e (patch)
treed410609c74e79e17a758aec1be8e043603be8e61 /arch/powerpc
parent8fc4fddaf9a184eea7da21290236a1764e608a01 (diff)
downloadlinux-d994f2c8e2410ebcb928df67baa6f04e29bc9d3e.tar.gz
linux-d994f2c8e2410ebcb928df67baa6f04e29bc9d3e.tar.bz2
linux-d994f2c8e2410ebcb928df67baa6f04e29bc9d3e.zip
locking/arch: Wire up local_try_cmpxchg()
Implement target specific support for local_try_cmpxchg() and local_cmpxchg() using typed C wrappers that call their _local counterpart and provide additional checking of their input arguments. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20230405141710.3551-4-ubizjak@gmail.com Cc: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/local.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
index bc4bd19b7fc2..45492fb5bf22 100644
--- a/arch/powerpc/include/asm/local.h
+++ b/arch/powerpc/include/asm/local.h
@@ -90,6 +90,17 @@ static __inline__ long local_cmpxchg(local_t *l, long o, long n)
return t;
}
+static __inline__ bool local_try_cmpxchg(local_t *l, long *po, long n)
+{
+ long o = *po, r;
+
+ r = local_cmpxchg(l, o, n);
+ if (unlikely(r != o))
+ *po = r;
+
+ return likely(r == o);
+}
+
static __inline__ long local_xchg(local_t *l, long n)
{
long t;