Author: br
Date: Wed Feb 17 14:32:03 2016
New Revision: 295701
URL: https://svnweb.freebsd.org/changeset/base/295701
Log:
Add the implementation of atomic_swap_32().
Modified:
head/sys/riscv/include/atomic.h
Modified: head/sys/riscv/include/atomic.h
==============================================================================
--- head/sys/riscv/include/atomic.h Wed Feb 17 14:24:25 2016
(r295700)
+++ head/sys/riscv/include/atomic.h Wed Feb 17 14:32:03 2016
(r295701)
@@ -310,6 +310,19 @@ atomic_readandclear_64(volatile uint64_t
return (ret);
}
+static __inline uint32_t
+atomic_swap_32(volatile uint32_t *p, uint32_t val)
+{
+ uint32_t old;
+
+ __asm __volatile("amoswap.w %0, %2, %1"
+ : "=&r"(old), "+A" (*p)
+ : "r" (val)
+ : "memory");
+
+ return (old);
+}
+
static __inline uint64_t
atomic_swap_64(volatile uint64_t *p, uint64_t val)
{
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"