diff options
author | dim <dim@FreeBSD.org> | 2016-02-21 13:49:26 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-02-21 13:49:26 +0000 |
commit | 2e1a0cbbd8f5a5ca7ec73c85311451ed1ac4242c (patch) | |
tree | bb5f550a5fd2ee1357495987f5076839273e5998 /sys/riscv/include/atomic.h | |
parent | f393760a8a7c87242739a64002290b7bda94cb27 (diff) | |
parent | 579b7ad49fdbcb4dd1e016603c5d0774b32c12d1 (diff) | |
download | FreeBSD-src-2e1a0cbbd8f5a5ca7ec73c85311451ed1ac4242c.zip FreeBSD-src-2e1a0cbbd8f5a5ca7ec73c85311451ed1ac4242c.tar.gz |
Merge ^/head r295601 through r295844.
Diffstat (limited to 'sys/riscv/include/atomic.h')
-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) { |