diff options
author | marcel <marcel@FreeBSD.org> | 2014-02-16 23:08:21 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2014-02-16 23:08:21 +0000 |
commit | 4bb58e4f5d8dbf6ff38d1652c421414f9dae8cf4 (patch) | |
tree | 0f8deefd6a2d8bb653b8d16449307c9cdfe80863 /sys/ia64 | |
parent | 2aad389c5a78fcbe02bee5cc0544786b677c94bd (diff) | |
download | FreeBSD-src-4bb58e4f5d8dbf6ff38d1652c421414f9dae8cf4.zip FreeBSD-src-4bb58e4f5d8dbf6ff38d1652c421414f9dae8cf4.tar.gz |
MFC r260175:
Implement atomic_swap_<type>.
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/include/atomic.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/ia64/include/atomic.h b/sys/ia64/include/atomic.h index d2f8874..e8ac7a7 100644 --- a/sys/ia64/include/atomic.h +++ b/sys/ia64/include/atomic.h @@ -386,4 +386,32 @@ atomic_fetchadd_long(volatile u_long *p, u_long v) return (value); } +/* + * <type> atomic_swap_<type>(volatile <type> *p, <type> v); + */ + +static __inline uint32_t +atomic_swap_32(volatile uint32_t *p, uint32_t v) +{ + uint32_t r; + + __asm __volatile ("xchg4 %0 = %3, %2;;" : "=r"(r), "=m"(*p) : + "r"(v), "m"(*p) : "memory"); + return (r); +} + +static __inline uint64_t +atomic_swap_64(volatile uint64_t *p, uint64_t v) +{ + uint64_t r; + + __asm __volatile ("xchg8 %0 = %3, %2;;" : "=r"(r), "=m"(*p) : + "r"(v), "m"(*p) : "memory"); + return (r); +} + +#define atomic_swap_int atomic_swap_32 +#define atomic_swap_long atomic_swap_64 +#define atomic_swap_ptr atomic_swap_64 + #endif /* ! _MACHINE_ATOMIC_H_ */ |