Implement atomic_fetchadd_64() for i386. This function is needed by the

atomic64 header file in the LinuxKPI for i386.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
hselasky 2017-11-24 12:10:42 +00:00
parent 993cc07930
commit cd19f399a1

View File

@ -129,6 +129,7 @@ int atomic_cmpset_64(volatile uint64_t *, uint64_t, uint64_t);
uint64_t atomic_load_acq_64(volatile uint64_t *);
void atomic_store_rel_64(volatile 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 */
@ -565,6 +566,17 @@ atomic_swap_64(volatile uint64_t *p, uint64_t v)
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 */
#endif /* KLD_MODULE || !__GNUCLIKE_ASM */