aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2008-03-16 21:20:50 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2008-03-16 21:20:50 +0000
commit6eb4157ffce8f31f8401801c09545ac1cde2a43e (patch)
treeef1e5ab50a7584e0e028a94391bd41725fc82f82 /sys/amd64
parent3de180085004e968e1084c6301e86d96a6050fc1 (diff)
Notes
Diffstat (limited to 'sys/amd64')
-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 dc12d4da063f..0edbfff52ff7 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)
/*