svn commit: r337896 - stable/11/sys/compat/linuxkpi/common/include/asm

Hans Petter Selasky hselasky at FreeBSD.org
Thu Aug 16 08:10:12 UTC 2018


Author: hselasky
Date: Thu Aug 16 08:10:11 2018
New Revision: 337896
URL: https://svnweb.freebsd.org/changeset/base/337896

Log:
  MFC r337374:
  Implement atomic_long_cmpxchg() function in the LinuxKPI.
  
  Submitted by:	Johannes Lundberg <johalun0 at gmail.com>
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h	Thu Aug 16 08:09:26 2018	(r337895)
+++ stable/11/sys/compat/linuxkpi/common/include/asm/atomic-long.h	Thu Aug 16 08:10:11 2018	(r337896)
@@ -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)
 {


More information about the svn-src-stable-11 mailing list