diff options
Diffstat (limited to 'tools/perf/util/include/linux/bitmap.h')
-rw-r--r-- | tools/perf/util/include/linux/bitmap.h | 17 |
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 01ffd12dc791..40bd21488032 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, | |||
46 | __bitmap_or(dst, src1, src2, nbits); | 46 | __bitmap_or(dst, src1, src2, nbits); |
47 | } | 47 | } |
48 | 48 | ||
49 | /** | ||
50 | * test_and_set_bit - Set a bit and return its old value | ||
51 | * @nr: Bit to set | ||
52 | * @addr: Address to count from | ||
53 | */ | ||
54 | static inline int test_and_set_bit(int nr, unsigned long *addr) | ||
55 | { | ||
56 | unsigned long mask = BIT_MASK(nr); | ||
57 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); | ||
58 | unsigned long old; | ||
59 | |||
60 | old = *p; | ||
61 | *p = old | mask; | ||
62 | |||
63 | return (old & mask) != 0; | ||
64 | } | ||
65 | |||
49 | #endif /* _PERF_BITOPS_H */ | 66 | #endif /* _PERF_BITOPS_H */ |