aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/atomic.h
diff options
context:
space:
mode:
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)
548} 548}
549#endif 549#endif
550 550
551/**
552 * fetch_or - perform *ptr |= mask and return old value of *ptr
553 * @ptr: pointer to value
554 * @mask: mask to OR on the value
555 *
556 * cmpxchg based fetch_or, macro so it works for different integer types
557 */
558#ifndef fetch_or
559#define fetch_or(ptr, mask) \
560({ typeof(*(ptr)) __old, __val = *(ptr); \
561 for (;;) { \
562 __old = cmpxchg((ptr), __val, __val | (mask)); \
563 if (__old == __val) \
564 break; \
565 __val = __old; \
566 } \
567 __old; \
568})
569#endif
570
571
551#ifdef CONFIG_GENERIC_ATOMIC64 572#ifdef CONFIG_GENERIC_ATOMIC64
552#include <asm-generic/atomic64.h> 573#include <asm-generic/atomic64.h>
553#endif 574#endif