summaryrefslogtreecommitdiffstats
path: root/sys/ia64
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-01-01 22:51:19 +0000
committermarcel <marcel@FreeBSD.org>2014-01-01 22:51:19 +0000
commitcce5252fb9da86b3d2caf38c306fb8f51654df4c (patch)
tree346be411ab8cf038f179d65dfaa0b14518bf7b4f /sys/ia64
parentb3be56b601dd12171147f03accd96ee1cee71f85 (diff)
downloadFreeBSD-src-cce5252fb9da86b3d2caf38c306fb8f51654df4c.zip
FreeBSD-src-cce5252fb9da86b3d2caf38c306fb8f51654df4c.tar.gz
Implement atomic_swap_<type>.
The operation was documented and implemented partially (both from a type and architecture perspective) on 2013-08-21 and got used in ZFS with revision 260150 (zfeature.c) and since ZFS is supported on ia64, the lack of having atomic_swap became problem.
Diffstat (limited to 'sys/ia64')
-rw-r--r--sys/ia64/include/atomic.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/ia64/include/atomic.h b/sys/ia64/include/atomic.h
index d2f8874..e8ac7a7 100644
--- a/sys/ia64/include/atomic.h
+++ b/sys/ia64/include/atomic.h
@@ -386,4 +386,32 @@ atomic_fetchadd_long(volatile u_long *p, u_long v)
return (value);
}
+/*
+ * <type> atomic_swap_<type>(volatile <type> *p, <type> v);
+ */
+
+static __inline uint32_t
+atomic_swap_32(volatile uint32_t *p, uint32_t v)
+{
+ uint32_t r;
+
+ __asm __volatile ("xchg4 %0 = %3, %2;;" : "=r"(r), "=m"(*p) :
+ "r"(v), "m"(*p) : "memory");
+ return (r);
+}
+
+static __inline uint64_t
+atomic_swap_64(volatile uint64_t *p, uint64_t v)
+{
+ uint64_t r;
+
+ __asm __volatile ("xchg8 %0 = %3, %2;;" : "=r"(r), "=m"(*p) :
+ "r"(v), "m"(*p) : "memory");
+ return (r);
+}
+
+#define atomic_swap_int atomic_swap_32
+#define atomic_swap_long atomic_swap_64
+#define atomic_swap_ptr atomic_swap_64
+
#endif /* ! _MACHINE_ATOMIC_H_ */
OpenPOWER on IntegriCloud