svn commit: r326517 - stable/9/sys/i386/include
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Dec 4 09:48:33 UTC 2017
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 */
More information about the svn-src-stable-9
mailing list