Path: blob/master/tools/perf/util/include/linux/bitmap.h
10825 views
#ifndef _PERF_BITOPS_H1#define _PERF_BITOPS_H23#include <string.h>4#include <linux/bitops.h>56int __bitmap_weight(const unsigned long *bitmap, int bits);78#define BITMAP_LAST_WORD_MASK(nbits) \9( \10((nbits) % BITS_PER_LONG) ? \11(1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \12)1314#define small_const_nbits(nbits) \15(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)1617static inline void bitmap_zero(unsigned long *dst, int nbits)18{19if (small_const_nbits(nbits))20*dst = 0UL;21else {22int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);23memset(dst, 0, len);24}25}2627static inline int bitmap_weight(const unsigned long *src, int nbits)28{29if (small_const_nbits(nbits))30return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));31return __bitmap_weight(src, nbits);32}3334#endif /* _PERF_BITOPS_H */353637