staging: brcm80211: change parameter in driver variable lookup
[zen-stable.git] / tools / perf / util / include / linux / bitmap.h
blobeda4416efa0a9819ad84a130132bd95d14f6b1a7
1 #ifndef _PERF_BITOPS_H
2 #define _PERF_BITOPS_H
4 #include <string.h>
5 #include <linux/bitops.h>
7 int __bitmap_weight(const unsigned long *bitmap, int bits);
9 #define BITMAP_LAST_WORD_MASK(nbits) \
10 ( \
11 ((nbits) % BITS_PER_LONG) ? \
12 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \
15 #define small_const_nbits(nbits) \
16 (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)
18 static inline void bitmap_zero(unsigned long *dst, int nbits)
20 if (small_const_nbits(nbits))
21 *dst = 0UL;
22 else {
23 int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
24 memset(dst, 0, len);
28 static inline int bitmap_weight(const unsigned long *src, int nbits)
30 if (small_const_nbits(nbits))
31 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
32 return __bitmap_weight(src, nbits);
35 #endif /* _PERF_BITOPS_H */