diff options
Diffstat (limited to 'include/linux/bitmap.h')
| -rw-r--r-- | include/linux/bitmap.h | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index dbfbf4990005..ea17cca9e685 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
| @@ -172,12 +172,8 @@ extern unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int | |||
| 172 | extern int bitmap_print_to_pagebuf(bool list, char *buf, | 172 | extern int bitmap_print_to_pagebuf(bool list, char *buf, |
| 173 | const unsigned long *maskp, int nmaskbits); | 173 | const unsigned long *maskp, int nmaskbits); |
| 174 | 174 | ||
| 175 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) | 175 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) |
| 176 | #define BITMAP_LAST_WORD_MASK(nbits) \ | 176 | #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) |
| 177 | ( \ | ||
| 178 | ((nbits) % BITS_PER_LONG) ? \ | ||
| 179 | (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ | ||
| 180 | ) | ||
| 181 | 177 | ||
| 182 | #define small_const_nbits(nbits) \ | 178 | #define small_const_nbits(nbits) \ |
| 183 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) | 179 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) |
| @@ -287,16 +283,16 @@ static inline int bitmap_empty(const unsigned long *src, unsigned nbits) | |||
| 287 | { | 283 | { |
| 288 | if (small_const_nbits(nbits)) | 284 | if (small_const_nbits(nbits)) |
| 289 | return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); | 285 | return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); |
| 290 | else | 286 | |
| 291 | return __bitmap_empty(src, nbits); | 287 | return find_first_bit(src, nbits) == nbits; |
| 292 | } | 288 | } |
| 293 | 289 | ||
| 294 | static inline int bitmap_full(const unsigned long *src, unsigned int nbits) | 290 | static inline int bitmap_full(const unsigned long *src, unsigned int nbits) |
| 295 | { | 291 | { |
| 296 | if (small_const_nbits(nbits)) | 292 | if (small_const_nbits(nbits)) |
| 297 | return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); | 293 | return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); |
| 298 | else | 294 | |
| 299 | return __bitmap_full(src, nbits); | 295 | return find_first_zero_bit(src, nbits) == nbits; |
| 300 | } | 296 | } |
| 301 | 297 | ||
| 302 | static inline int bitmap_weight(const unsigned long *src, unsigned int nbits) | 298 | static inline int bitmap_weight(const unsigned long *src, unsigned int nbits) |
