svn commit: r264376 - stable/9/sys/powerpc/include
Andreas Tobler
andreast at FreeBSD.org
Sat Apr 12 19:58:31 UTC 2014
Author: andreast
Date: Sat Apr 12 19:58:31 2014
New Revision: 264376
URL: http://svnweb.freebsd.org/changeset/base/264376
Log:
MFC r260610:
Described in the man page but not implemented. Here it comes,
atomic_swap_32/64. The latter only for powerpc64.
Modified:
stable/9/sys/powerpc/include/atomic.h
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/powerpc/include/atomic.h
==============================================================================
--- stable/9/sys/powerpc/include/atomic.h Sat Apr 12 19:57:15 2014 (r264375)
+++ stable/9/sys/powerpc/include/atomic.h Sat Apr 12 19:58:31 2014 (r264376)
@@ -666,10 +666,47 @@ atomic_fetchadd_long(volatile u_long *p,
return (value);
}
+static __inline u_int
+atomic_swap_32(volatile u_int *p, u_int v)
+{
+ u_int prev;
+
+ __asm __volatile(
+ "1: lwarx %0,0,%2\n"
+ " stwcx. %3,0,%2\n"
+ " bne- 1b\n"
+ : "=&r" (prev), "+m" (*(volatile u_int *)p)
+ : "r" (p), "r" (v)
+ : "cc", "memory");
+
+ return (prev);
+}
+
+#ifdef __powerpc64__
+static __inline u_long
+atomic_swap_64(volatile u_long *p, u_long v)
+{
+ u_long prev;
+
+ __asm __volatile(
+ "1: ldarx %0,0,%2\n"
+ " stdcx. %3,0,%2\n"
+ " bne- 1b\n"
+ : "=&r" (prev), "+m" (*(volatile u_long *)p)
+ : "r" (p), "r" (v)
+ : "cc", "memory");
+
+ return (prev);
+}
+#endif
+
#define atomic_fetchadd_32 atomic_fetchadd_int
+#define atomic_swap_int atomic_swap_32
#ifdef __powerpc64__
#define atomic_fetchadd_64 atomic_fetchadd_long
+#define atomic_swap_long atomic_swap_64
+#define atomic_swap_ptr atomic_swap_64
#endif
#endif /* ! _MACHINE_ATOMIC_H_ */
More information about the svn-src-stable-9
mailing list