diff options
author | br <br@FreeBSD.org> | 2016-02-17 14:32:03 +0000 |
---|---|---|
committer | br <br@FreeBSD.org> | 2016-02-17 14:32:03 +0000 |
commit | ab7fae640a43d539a2c4e04f6003048c2aa11386 (patch) | |
tree | e2153f2a33b7b1514f0c50a6cc3d24112b996d71 /sys/riscv | |
parent | 633cf96bb13055f85afd9b2dff463d794edca38e (diff) | |
download | FreeBSD-src-ab7fae640a43d539a2c4e04f6003048c2aa11386.zip FreeBSD-src-ab7fae640a43d539a2c4e04f6003048c2aa11386.tar.gz |
Add the implementation of atomic_swap_32().
Diffstat (limited to 'sys/riscv')
-rw-r--r-- | sys/riscv/include/atomic.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/riscv/include/atomic.h b/sys/riscv/include/atomic.h index f86570a..2d7d819 100644 --- a/sys/riscv/include/atomic.h +++ b/sys/riscv/include/atomic.h @@ -310,6 +310,19 @@ atomic_readandclear_64(volatile uint64_t *p) 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) { |