History

tools lib: Adopt bitmap_intersects() operation from the kernel sources

Adopt bitmap_intersects() routine that tests whether bitmaps bitmap1 and bitmap2 intersects. This routine will be used during thread masks initialization.

Alexey Bayduraev committed 5 years ago

Commit f20510d1 parent 857286e2 files · +25 −0Browse files

Showing the changes to tools/include/linux (1 of 2 files). Show all

Unified · Split

tools/include/linux/bitmap.h+11−0
@@ -18,6 +18,8 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, · 17 unmodified lines
1818 int __bitmap_equal(const unsigned long *bitmap1,
1919 const unsigned long *bitmap2, unsigned int bits);
2020 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);
2123
2224 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
2325 #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
170172 return __bitmap_equal(src1, src2, nbits);
171173 }
172174
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+
173184 #endif /* _PERF_BITOPS_H */