summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/include/linux/bitmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/include/linux/bitmap.h')
-rw-r--r--tools/perf/util/include/linux/bitmap.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/perf/util/include/linux/bitmap.h b/tools/perf/util/include/linux/bitmap.h
index 01ffd12dc79..40bd2148803 100644
--- a/tools/perf/util/include/linux/bitmap.h
+++ b/tools/perf/util/include/linux/bitmap.h
@@ -46,4 +46,21 @@ static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
__bitmap_or(dst, src1, src2, nbits);
}
+/**
+ * test_and_set_bit - Set a bit and return its old value
+ * @nr: Bit to set
+ * @addr: Address to count from
+ */
+static inline int test_and_set_bit(int nr, unsigned long *addr)
+{
+ unsigned long mask = BIT_MASK(nr);
+ unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
+ unsigned long old;
+
+ old = *p;
+ *p = old | mask;
+
+ return (old & mask) != 0;
+}
+
#endif /* _PERF_BITOPS_H */