summaryrefslogtreecommitdiffstats
path: root/include/linux/atomic.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2015-08-11 18:03:23 +0200
committerFrederic Weisbecker <fweisbec@gmail.com>2016-02-13 15:34:28 +0100
commit5fd7a09cfb8c6852f596c1f8c891c6158395250e (patch)
treec136e50a60a4328e7779d01c3972d477883dc39f /include/linux/atomic.h
parent36f90b0a2ddd60823fe193a85e60ff1906c2a9b3 (diff)
downloadlinux-5fd7a09cfb8c6852f596c1f8c891c6158395250e.tar.gz
linux-5fd7a09cfb8c6852f596c1f8c891c6158395250e.tar.bz2
linux-5fd7a09cfb8c6852f596c1f8c891c6158395250e.zip
atomic: Export fetch_or()
Export fetch_or() that's implemented and used internally by the scheduler. We are going to use it for NO_HZ so make it generally available. Reviewed-by: Chris Metcalf <cmetcalf@ezchip.com> Cc: Christoph Lameter <cl@linux.com> Cc: Chris Metcalf <cmetcalf@ezchip.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'include/linux/atomic.h')
-rw-r--r--include/linux/atomic.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 301de78d65f7..6c502cb13c95 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -548,6 +548,27 @@ static inline int atomic_dec_if_positive(atomic_t *v)
}
#endif
+/**
+ * fetch_or - perform *ptr |= mask and return old value of *ptr
+ * @ptr: pointer to value
+ * @mask: mask to OR on the value
+ *
+ * cmpxchg based fetch_or, macro so it works for different integer types
+ */
+#ifndef fetch_or
+#define fetch_or(ptr, mask) \
+({ typeof(*(ptr)) __old, __val = *(ptr); \
+ for (;;) { \
+ __old = cmpxchg((ptr), __val, __val | (mask)); \
+ if (__old == __val) \
+ break; \
+ __val = __old; \
+ } \
+ __old; \
+})
+#endif
+
+
#ifdef CONFIG_GENERIC_ATOMIC64
#include <asm-generic/atomic64.h>
#endif