diff options
Diffstat (limited to 'tools/include/linux')
| -rw-r--r-- | tools/include/linux/bitmap.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h index 43c1c5021e4b..eef41d500e9e 100644 --- a/tools/include/linux/bitmap.h +++ b/tools/include/linux/bitmap.h | |||
| @@ -35,6 +35,32 @@ static inline void bitmap_zero(unsigned long *dst, int nbits) | |||
| 35 | } | 35 | } |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) | ||
| 39 | { | ||
| 40 | unsigned int nlongs = BITS_TO_LONGS(nbits); | ||
| 41 | if (!small_const_nbits(nbits)) { | ||
| 42 | unsigned int len = (nlongs - 1) * sizeof(unsigned long); | ||
| 43 | memset(dst, 0xff, len); | ||
| 44 | } | ||
| 45 | dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); | ||
| 46 | } | ||
| 47 | |||
| 48 | static inline int bitmap_empty(const unsigned long *src, unsigned nbits) | ||
| 49 | { | ||
| 50 | if (small_const_nbits(nbits)) | ||
| 51 | return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); | ||
| 52 | |||
| 53 | return find_first_bit(src, nbits) == nbits; | ||
| 54 | } | ||
| 55 | |||
| 56 | static inline int bitmap_full(const unsigned long *src, unsigned int nbits) | ||
| 57 | { | ||
| 58 | if (small_const_nbits(nbits)) | ||
| 59 | return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); | ||
| 60 | |||
| 61 | return find_first_zero_bit(src, nbits) == nbits; | ||
| 62 | } | ||
| 63 | |||
| 38 | static inline int bitmap_weight(const unsigned long *src, int nbits) | 64 | static inline int bitmap_weight(const unsigned long *src, int nbits) |
| 39 | { | 65 | { |
| 40 | if (small_const_nbits(nbits)) | 66 | if (small_const_nbits(nbits)) |
