diff options
| author | Ruslan Bukin <br@FreeBSD.org> | 2016-02-17 14:32:03 +0000 |
|---|---|---|
| committer | Ruslan Bukin <br@FreeBSD.org> | 2016-02-17 14:32:03 +0000 |
| commit | 5fe191b01e37f024b36af565157838c8d5c687d4 (patch) | |
| tree | e2153f2a33b7b1514f0c50a6cc3d24112b996d71 /sys/riscv/include | |
| parent | f936aa4a3aaa46c9e818bf90c7a3a364e098576b (diff) | |
Notes
Diffstat (limited to 'sys/riscv/include')
| -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 f86570a6f6225..2d7d8192aea01 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) { |
