Add the implementation of atomic_swap_32().
This commit is contained in:
parent
f936aa4a3a
commit
5fe191b01e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=295701
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user