Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Jul 2018 15:42:57 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336832 - head/sys/sparc64/include
Message-ID:  <201807281542.w6SFgvpo086240@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Sat Jul 28 15:42:57 2018
New Revision: 336832
URL: https://svnweb.freebsd.org/changeset/base/336832

Log:
  Implement atomic_swap_{32,64,int,long,ptr}(9).

Modified:
  head/sys/sparc64/include/atomic.h

Modified: head/sys/sparc64/include/atomic.h
==============================================================================
--- head/sys/sparc64/include/atomic.h	Sat Jul 28 12:53:10 2018	(r336831)
+++ head/sys/sparc64/include/atomic.h	Sat Jul 28 15:42:57 2018	(r336832)
@@ -154,14 +154,15 @@
 	e;								\
 })
 
-#define	atomic_st(p, v, sz) do {					\
+#define	atomic_st(p, v, sz) ({						\
 	itype(sz) e, r;							\
 	for (e = *(volatile itype(sz) *)(p);; e = r) {			\
 		r = atomic_cas((p), e, (v), sz);			\
 		if (r == e)						\
 			break;						\
 	}								\
-} while (0)
+	e;								\
+})
 
 #define	atomic_st_acq(p, v, sz) do {					\
 	atomic_st((p), (v), sz);					\
@@ -310,6 +311,12 @@ static __inline void							\
 atomic_store_rel_ ## name(volatile ptype p, vtype v)			\
 {									\
 	atomic_st_rel((p), (v), sz);					\
+}									\
+									\
+static __inline vtype							\
+atomic_swap_ ## name(volatile ptype p, vtype v)				\
+{									\
+	return ((vtype)atomic_st((p), (v), sz));			\
 }
 
 static __inline void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807281542.w6SFgvpo086240>