Date: Sun, 16 Feb 2014 23:08:21 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r262004 - stable/10/sys/ia64/include Message-ID: <201402162308.s1GN8LqU098064@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcel Date: Sun Feb 16 23:08:21 2014 New Revision: 262004 URL: http://svnweb.freebsd.org/changeset/base/262004 Log: MFC r260175: Implement atomic_swap_<type>. Modified: stable/10/sys/ia64/include/atomic.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ia64/include/atomic.h ============================================================================== --- stable/10/sys/ia64/include/atomic.h Sun Feb 16 22:48:36 2014 (r262003) +++ stable/10/sys/ia64/include/atomic.h Sun Feb 16 23:08:21 2014 (r262004) @@ -386,4 +386,32 @@ atomic_fetchadd_long(volatile u_long *p, 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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402162308.s1GN8LqU098064>