Date: Wed, 17 Feb 2016 14:32:03 +0000 (UTC) From: Ruslan Bukin <br@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295701 - head/sys/riscv/include Message-ID: <201602171432.u1HEW33j049662@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602171432.u1HEW33j049662>