Date: Mon, 4 Dec 2017 09:48:31 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r326517 - stable/9/sys/i386/include Message-ID: <201712040948.vB49mVAO090510@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Mon Dec 4 09:48:31 2017 New Revision: 326517 URL: https://svnweb.freebsd.org/changeset/base/326517 Log: MFC r326161: Implement atomic_fetchadd_64() for i386. This function is needed by the atomic64 header file in the LinuxKPI for i386. Reviewed by: kib Sponsored by: Mellanox Technologies Modified: stable/9/sys/i386/include/atomic.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/i386/include/atomic.h ============================================================================== --- stable/9/sys/i386/include/atomic.h Mon Dec 4 09:47:42 2017 (r326516) +++ stable/9/sys/i386/include/atomic.h Mon Dec 4 09:48:31 2017 (r326517) @@ -94,6 +94,7 @@ void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_ int atomic_cmpset_64(volatile uint64_t *, uint64_t, uint64_t); uint64_t atomic_swap_64(volatile uint64_t *, uint64_t); +uint64_t atomic_fetchadd_64(volatile uint64_t *, uint64_t); #else /* !KLD_MODULE && __GNUCLIKE_ASM */ @@ -478,6 +479,17 @@ atomic_swap_64(volatile uint64_t *p, uint64_t v) return (atomic_swap_64_i386(p, v)); else return (atomic_swap_64_i586(p, v)); +} + +static __inline uint64_t +atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) +{ + + for (;;) { + uint64_t t = *p; + if (atomic_cmpset_64(p, t, t + v)) + return (t); + } } #endif /* _KERNEL */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712040948.vB49mVAO090510>