summaryrefslogtreecommitdiffstats
path: root/sys/ia64
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-10-06 18:12:06 +0000
committerjhb <jhb@FreeBSD.org>2005-10-06 18:12:06 +0000
commit603cac3a997cf397b0d50eb99b78d6f60befbec8 (patch)
tree00d2920873d218802ad18578bc888fd12ecc9c9b /sys/ia64
parent94034fc30c1032f51422547af356e08811ffc3f7 (diff)
downloadFreeBSD-src-603cac3a997cf397b0d50eb99b78d6f60befbec8.zip
FreeBSD-src-603cac3a997cf397b0d50eb99b78d6f60befbec8.tar.gz
MFC: Add atomic_fetchadd(9) operation for types int and 32.
Other small updates to atomic(9) include: - Note that arm and ppc don't provide 64-bit atomic ops. - Update sample code. Approved by: re (scottl)
Diffstat (limited to 'sys/ia64')
-rw-r--r--sys/ia64/include/atomic.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/ia64/include/atomic.h b/sys/ia64/include/atomic.h
index 1119079..f660180 100644
--- a/sys/ia64/include/atomic.h
+++ b/sys/ia64/include/atomic.h
@@ -342,4 +342,23 @@ atomic_readandclear_64(volatile uint64_t* p)
#define atomic_readandclear_int atomic_readandclear_32
#define atomic_readandclear_long atomic_readandclear_64
+/*
+ * Atomically add the value of v to the integer pointed to by p and return
+ * the previous value of *p.
+ *
+ * XXX: Should we use the fetchadd instruction here?
+ */
+static __inline uint32_t
+atomic_fetchadd_32(volatile uint32_t *p, uint32_t v)
+{
+ uint32_t value;
+
+ do {
+ value = *p;
+ } while (!atomic_cmpset_32(p, value, value + v));
+ return (value);
+}
+
+#define atomic_fetchadd_int atomic_fetchadd_32
+
#endif /* ! _MACHINE_ATOMIC_H_ */
OpenPOWER on IntegriCloud