diff options
| author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-06 13:13:54 -0400 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-06 13:13:54 -0400 |
| commit | 11e4afb49b7fa1fc8e1ffd850c1806dd86a08204 (patch) | |
| tree | 9e57efcb106ae912f7bec718feb3f8ec607559bb /tools/perf/util/include/linux/bitmap.h | |
| parent | 162500b3a3ff39d941d29db49b41a16667ae44f0 (diff) | |
| parent | 9b2a606d3898fcb2eedb6faded3bb37549590ac4 (diff) | |
Merge branches 'gemini' and 'misc' into devel
Diffstat (limited to 'tools/perf/util/include/linux/bitmap.h')
| -rw-r--r-- | tools/perf/util/include/linux/bitmap.h | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/tools/perf/util/include/linux/bitmap.h b/tools/perf/util/include/linux/bitmap.h index 94507639a8c4..eda4416efa0a 100644 --- a/tools/perf/util/include/linux/bitmap.h +++ b/tools/perf/util/include/linux/bitmap.h | |||
| @@ -1,3 +1,35 @@ | |||
| 1 | #include "../../../../include/linux/bitmap.h" | 1 | #ifndef _PERF_BITOPS_H |
| 2 | #include "../../../../include/asm-generic/bitops/find.h" | 2 | #define _PERF_BITOPS_H |
| 3 | #include <linux/errno.h> | 3 | |
| 4 | #include <string.h> | ||
| 5 | #include <linux/bitops.h> | ||
| 6 | |||
| 7 | int __bitmap_weight(const unsigned long *bitmap, int bits); | ||
| 8 | |||
| 9 | #define BITMAP_LAST_WORD_MASK(nbits) \ | ||
| 10 | ( \ | ||
| 11 | ((nbits) % BITS_PER_LONG) ? \ | ||
| 12 | (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ | ||
| 13 | ) | ||
| 14 | |||
| 15 | #define small_const_nbits(nbits) \ | ||
| 16 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) | ||
| 17 | |||
| 18 | static inline void bitmap_zero(unsigned long *dst, int nbits) | ||
| 19 | { | ||
| 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); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | static inline int bitmap_weight(const unsigned long *src, int nbits) | ||
| 29 | { | ||
| 30 | if (small_const_nbits(nbits)) | ||
| 31 | return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); | ||
| 32 | return __bitmap_weight(src, nbits); | ||
| 33 | } | ||
| 34 | |||
| 35 | #endif /* _PERF_BITOPS_H */ | ||
