summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/atomic.h
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2008-03-16 21:20:50 +0000
committerpjd <pjd@FreeBSD.org>2008-03-16 21:20:50 +0000
commitea49d310bf69a1de4effcf20fc368f40b3541ef0 (patch)
treeef1e5ab50a7584e0e028a94391bd41725fc82f82 /sys/amd64/include/atomic.h
parentbc8c8477a02fa7911713785305f7fe01ee91f393 (diff)
downloadFreeBSD-src-ea49d310bf69a1de4effcf20fc368f40b3541ef0.zip
FreeBSD-src-ea49d310bf69a1de4effcf20fc368f40b3541ef0.tar.gz
Implement atomic_fetchadd_long() for all architectures and document it.
Reviewed by: attilio, jhb, jeff, kris (as a part of the uidinfo_waitfree.patch)
Diffstat (limited to 'sys/amd64/include/atomic.h')
-rw-r--r--sys/amd64/include/atomic.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h
index dc12d4d..0edbfff 100644
--- a/sys/amd64/include/atomic.h
+++ b/sys/amd64/include/atomic.h
@@ -74,6 +74,7 @@ void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)
int atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src);
int atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src);
u_int atomic_fetchadd_int(volatile u_int *p, u_int v);
+u_long atomic_fetchadd_long(volatile u_long *p, u_long v);
#define ATOMIC_STORE_LOAD(TYPE, LOP, SOP) \
u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p); \
@@ -174,6 +175,25 @@ atomic_fetchadd_int(volatile u_int *p, u_int v)
return (v);
}
+/*
+ * Atomically add the value of v to the long integer pointed to by p and return
+ * the previous value of *p.
+ */
+static __inline u_long
+atomic_fetchadd_long(volatile u_long *p, u_long v)
+{
+
+ __asm __volatile(
+ " " MPLOCKED " "
+ " xaddq %0, %1 ; "
+ "# atomic_fetchadd_long"
+ : "+r" (v), /* 0 (result) */
+ "=m" (*p) /* 1 */
+ : "m" (*p)); /* 2 */
+
+ return (v);
+}
+
#if defined(_KERNEL) && !defined(SMP)
/*
OpenPOWER on IntegriCloud