5 #include <linux/bitops.h>
7 int __bitmap_weight(const unsigned long *bitmap, int bits);
8 void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
9 const unsigned long *bitmap2, int bits);
11 #define BITMAP_LAST_WORD_MASK(nbits) \
13 ((nbits) % BITS_PER_LONG) ? \
14 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
17 #define small_const_nbits(nbits) \
18 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
20 static inline void bitmap_zero(unsigned long *dst, int nbits)
22 if (small_const_nbits(nbits))
25 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
30 static inline int bitmap_weight(const unsigned long *src, int nbits)
32 if (small_const_nbits(nbits))
33 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
34 return __bitmap_weight(src, nbits);
37 static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
38 const unsigned long *src2, int nbits)
40 if (small_const_nbits(nbits))
43 __bitmap_or(dst, src1, src2, nbits);
46 #endif /* _PERF_BITOPS_H */