aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2018-08-06 08:40:02 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2018-08-06 08:40:02 +0000
commitdb119089beb7c616722f7e5265a55cecb9c84f12 (patch)
tree9e759d07999648f3e96081f0e73018edd4d03069 /sys/compat/linuxkpi/common/include
parentf698bc4d767c5840c2c21a0df68aadaa05c186ba (diff)
downloadsrc-db119089beb7c616722f7e5265a55cecb9c84f12.tar.gz
src-db119089beb7c616722f7e5265a55cecb9c84f12.zip
Implement atomic_long_cmpxchg() function in the LinuxKPI.
Submitted by: Johannes Lundberg <johalun0@gmail.com> MFC after: 1 week Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=337374
Diffstat (limited to 'sys/compat/linuxkpi/common/include')
-rw-r--r--sys/compat/linuxkpi/common/include/asm/atomic-long.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/asm/atomic-long.h b/sys/compat/linuxkpi/common/include/asm/atomic-long.h
index b0763f456b90..b6909e1342e5 100644
--- a/sys/compat/linuxkpi/common/include/asm/atomic-long.h
+++ b/sys/compat/linuxkpi/common/include/asm/atomic-long.h
@@ -81,6 +81,21 @@ atomic_long_xchg(atomic_long_t *v, long val)
return atomic_swap_long(&v->counter, val);
}
+static inline long
+atomic_long_cmpxchg(atomic_long_t *v, long old, long new)
+{
+ long ret = old;
+
+ for (;;) {
+ if (atomic_cmpset_long(&v->counter, old, new))
+ break;
+ ret = READ_ONCE(v->counter);
+ if (ret != old)
+ break;
+ }
+ return (ret);
+}
+
static inline int
atomic_long_add_unless(atomic_long_t *v, long a, long u)
{