Adopt bitmap_intersects() routine that tests whether bitmaps bitmap1 and bitmap2 intersects. This routine will be used during thread masks initialization.
Showing the changes to tools/include/linux (1 of 2 files). Show all
Unified · Split
| @@ -18,6 +18,8 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, · 17 unmodified lines | |||
| 18 | int __bitmap_equal(const unsigned long *bitmap1, | 18 | int __bitmap_equal(const unsigned long *bitmap1, |
| 19 | const unsigned long *bitmap2, unsigned int bits); | 19 | const unsigned long *bitmap2, unsigned int bits); |
| 20 | void bitmap_clear(unsigned long *map, unsigned int start, int len); | 20 | void bitmap_clear(unsigned long *map, unsigned int start, int len); |
| 21 | int __bitmap_intersects(const unsigned long *bitmap1, | ||
| 22 | const unsigned long *bitmap2, unsigned int bits); | ||
| 21 | 23 | ||
| 22 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) | 24 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) |
| 23 | #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) | 25 | #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) |
| @@ -170,4 +172,13 @@ static inline int bitmap_equal(const unsigned long *src1, · 146 unmodified lines | |||
| 170 | return __bitmap_equal(src1, src2, nbits); | 172 | return __bitmap_equal(src1, src2, nbits); |
| 171 | } | 173 | } |
| 172 | 174 | ||
| 175 | static inline int bitmap_intersects(const unsigned long *src1, | ||
| 176 | const unsigned long *src2, unsigned int nbits) | ||
| 177 | { | ||
| 178 | if (small_const_nbits(nbits)) | ||
| 179 | return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; | ||
| 180 | else | ||
| 181 | return __bitmap_intersects(src1, src2, nbits); | ||
| 182 | } | ||
| 183 | |||
| 173 | #endif /* _PERF_BITOPS_H */ | 184 | #endif /* _PERF_BITOPS_H */ |