Lines Matching refs:nbits
132 unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags);
133 unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
134 unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
135 unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
142 unsigned int nbits, gfp_t flags);
144 unsigned int nbits, gfp_t flags);
151 const unsigned long *bitmap2, unsigned int nbits);
155 unsigned int nbits);
157 unsigned int nbits);
159 unsigned int shift, unsigned int nbits);
161 unsigned int shift, unsigned int nbits);
163 unsigned int first, unsigned int cut, unsigned int nbits);
165 const unsigned long *bitmap2, unsigned int nbits);
167 const unsigned long *bitmap2, unsigned int nbits);
169 const unsigned long *bitmap2, unsigned int nbits);
171 const unsigned long *bitmap2, unsigned int nbits);
174 const unsigned long *mask, unsigned int nbits);
176 const unsigned long *bitmap2, unsigned int nbits);
178 const unsigned long *bitmap2, unsigned int nbits);
179 unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits);
181 const unsigned long *bitmap2, unsigned int nbits);
183 const unsigned long *bitmap2, unsigned int nbits);
218 const unsigned long *old, const unsigned long *new, unsigned int nbits);
224 unsigned int sz, unsigned int nbits);
227 #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) argument
229 #define bitmap_size(nbits) (ALIGN(nbits, BITS_PER_LONG) / BITS_PER_BYTE) argument
231 static __always_inline void bitmap_zero(unsigned long *dst, unsigned int nbits) in bitmap_zero() argument
233 unsigned int len = bitmap_size(nbits); in bitmap_zero()
235 if (small_const_nbits(nbits)) in bitmap_zero()
241 static __always_inline void bitmap_fill(unsigned long *dst, unsigned int nbits) in bitmap_fill() argument
243 unsigned int len = bitmap_size(nbits); in bitmap_fill()
245 if (small_const_nbits(nbits)) in bitmap_fill()
252 void bitmap_copy(unsigned long *dst, const unsigned long *src, unsigned int nbits) in bitmap_copy() argument
254 unsigned int len = bitmap_size(nbits); in bitmap_copy()
256 if (small_const_nbits(nbits)) in bitmap_copy()
266 void bitmap_copy_clear_tail(unsigned long *dst, const unsigned long *src, unsigned int nbits) in bitmap_copy_clear_tail() argument
268 bitmap_copy(dst, src, nbits); in bitmap_copy_clear_tail()
269 if (nbits % BITS_PER_LONG) in bitmap_copy_clear_tail()
270 dst[nbits / BITS_PER_LONG] &= BITMAP_LAST_WORD_MASK(nbits); in bitmap_copy_clear_tail()
295 unsigned int nbits);
297 unsigned int nbits);
299 #define bitmap_from_arr32(bitmap, buf, nbits) \ argument
301 (const unsigned long *) (buf), (nbits))
302 #define bitmap_to_arr32(buf, bitmap, nbits) \ argument
304 (const unsigned long *) (bitmap), (nbits))
312 void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits);
313 void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits);
315 #define bitmap_from_arr64(bitmap, buf, nbits) \ argument
316 bitmap_copy_clear_tail((unsigned long *)(bitmap), (const unsigned long *)(buf), (nbits))
317 #define bitmap_to_arr64(buf, bitmap, nbits) \ argument
318 bitmap_copy_clear_tail((unsigned long *)(buf), (const unsigned long *)(bitmap), (nbits))
323 const unsigned long *src2, unsigned int nbits) in bitmap_and() argument
325 if (small_const_nbits(nbits)) in bitmap_and()
326 return (*dst = *src1 & *src2 & BITMAP_LAST_WORD_MASK(nbits)) != 0; in bitmap_and()
327 return __bitmap_and(dst, src1, src2, nbits); in bitmap_and()
332 const unsigned long *src2, unsigned int nbits) in bitmap_or() argument
334 if (small_const_nbits(nbits)) in bitmap_or()
337 __bitmap_or(dst, src1, src2, nbits); in bitmap_or()
342 const unsigned long *src2, unsigned int nbits) in bitmap_xor() argument
344 if (small_const_nbits(nbits)) in bitmap_xor()
347 __bitmap_xor(dst, src1, src2, nbits); in bitmap_xor()
352 const unsigned long *src2, unsigned int nbits) in bitmap_andnot() argument
354 if (small_const_nbits(nbits)) in bitmap_andnot()
355 return (*dst = *src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; in bitmap_andnot()
356 return __bitmap_andnot(dst, src1, src2, nbits); in bitmap_andnot()
360 void bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int nbits) in bitmap_complement() argument
362 if (small_const_nbits(nbits)) in bitmap_complement()
365 __bitmap_complement(dst, src, nbits); in bitmap_complement()
376 bool bitmap_equal(const unsigned long *src1, const unsigned long *src2, unsigned int nbits) in bitmap_equal() argument
378 if (small_const_nbits(nbits)) in bitmap_equal()
379 return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_equal()
380 if (__builtin_constant_p(nbits & BITMAP_MEM_MASK) && in bitmap_equal()
381 IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT)) in bitmap_equal()
382 return !memcmp(src1, src2, nbits / 8); in bitmap_equal()
383 return __bitmap_equal(src1, src2, nbits); in bitmap_equal()
397 const unsigned long *src3, unsigned int nbits) in bitmap_or_equal() argument
399 if (!small_const_nbits(nbits)) in bitmap_or_equal()
400 return __bitmap_or_equal(src1, src2, src3, nbits); in bitmap_or_equal()
402 return !(((*src1 | *src2) ^ *src3) & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_or_equal()
406 bool bitmap_intersects(const unsigned long *src1, const unsigned long *src2, unsigned int nbits) in bitmap_intersects() argument
408 if (small_const_nbits(nbits)) in bitmap_intersects()
409 return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; in bitmap_intersects()
411 return __bitmap_intersects(src1, src2, nbits); in bitmap_intersects()
415 bool bitmap_subset(const unsigned long *src1, const unsigned long *src2, unsigned int nbits) in bitmap_subset() argument
417 if (small_const_nbits(nbits)) in bitmap_subset()
418 return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_subset()
420 return __bitmap_subset(src1, src2, nbits); in bitmap_subset()
424 bool bitmap_empty(const unsigned long *src, unsigned nbits) in bitmap_empty() argument
426 if (small_const_nbits(nbits)) in bitmap_empty()
427 return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_empty()
429 return find_first_bit(src, nbits) == nbits; in bitmap_empty()
433 bool bitmap_full(const unsigned long *src, unsigned int nbits) in bitmap_full() argument
435 if (small_const_nbits(nbits)) in bitmap_full()
436 return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_full()
438 return find_first_zero_bit(src, nbits) == nbits; in bitmap_full()
442 unsigned int bitmap_weight(const unsigned long *src, unsigned int nbits) in bitmap_weight() argument
444 if (small_const_nbits(nbits)) in bitmap_weight()
445 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_weight()
446 return __bitmap_weight(src, nbits); in bitmap_weight()
451 const unsigned long *src2, unsigned int nbits) in bitmap_weight_and() argument
453 if (small_const_nbits(nbits)) in bitmap_weight_and()
454 return hweight_long(*src1 & *src2 & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_weight_and()
455 return __bitmap_weight_and(src1, src2, nbits); in bitmap_weight_and()
460 const unsigned long *src2, unsigned int nbits) in bitmap_weight_andnot() argument
462 if (small_const_nbits(nbits)) in bitmap_weight_andnot()
463 return hweight_long(*src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits)); in bitmap_weight_andnot()
464 return __bitmap_weight_andnot(src1, src2, nbits); in bitmap_weight_andnot()
468 void bitmap_set(unsigned long *map, unsigned int start, unsigned int nbits) in bitmap_set() argument
470 if (__builtin_constant_p(nbits) && nbits == 1) in bitmap_set()
472 else if (small_const_nbits(start + nbits)) in bitmap_set()
473 *map |= GENMASK(start + nbits - 1, start); in bitmap_set()
476 __builtin_constant_p(nbits & BITMAP_MEM_MASK) && in bitmap_set()
477 IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT)) in bitmap_set()
478 memset((char *)map + start / 8, 0xff, nbits / 8); in bitmap_set()
480 __bitmap_set(map, start, nbits); in bitmap_set()
484 void bitmap_clear(unsigned long *map, unsigned int start, unsigned int nbits) in bitmap_clear() argument
486 if (__builtin_constant_p(nbits) && nbits == 1) in bitmap_clear()
488 else if (small_const_nbits(start + nbits)) in bitmap_clear()
489 *map &= ~GENMASK(start + nbits - 1, start); in bitmap_clear()
492 __builtin_constant_p(nbits & BITMAP_MEM_MASK) && in bitmap_clear()
493 IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT)) in bitmap_clear()
494 memset((char *)map + start / 8, 0, nbits / 8); in bitmap_clear()
496 __bitmap_clear(map, start, nbits); in bitmap_clear()
501 unsigned int shift, unsigned int nbits) in bitmap_shift_right() argument
503 if (small_const_nbits(nbits)) in bitmap_shift_right()
504 *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> shift; in bitmap_shift_right()
506 __bitmap_shift_right(dst, src, shift, nbits); in bitmap_shift_right()
511 unsigned int shift, unsigned int nbits) in bitmap_shift_left() argument
513 if (small_const_nbits(nbits)) in bitmap_shift_left()
514 *dst = (*src << shift) & BITMAP_LAST_WORD_MASK(nbits); in bitmap_shift_left()
516 __bitmap_shift_left(dst, src, shift, nbits); in bitmap_shift_left()
524 unsigned int nbits) in bitmap_replace() argument
526 if (small_const_nbits(nbits)) in bitmap_replace()
529 __bitmap_replace(dst, old, new, mask, nbits); in bitmap_replace()
569 const unsigned long *mask, unsigned int nbits) in bitmap_scatter() argument
574 bitmap_zero(dst, nbits); in bitmap_scatter()
576 for_each_set_bit(bit, mask, nbits) in bitmap_scatter()
624 const unsigned long *mask, unsigned int nbits) in bitmap_gather() argument
629 bitmap_zero(dst, nbits); in bitmap_gather()
631 for_each_set_bit(bit, mask, nbits) in bitmap_gather()
765 unsigned long bitmap_read(const unsigned long *map, unsigned long start, unsigned long nbits) in bitmap_read() argument
772 if (unlikely(!nbits || nbits > BITS_PER_LONG)) in bitmap_read()
775 if (space >= nbits) in bitmap_read()
776 return (map[index] >> offset) & BITMAP_LAST_WORD_MASK(nbits); in bitmap_read()
779 value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits); in bitmap_read()
800 unsigned long start, unsigned long nbits) in bitmap_write() argument
808 if (unlikely(!nbits || nbits > BITS_PER_LONG)) in bitmap_write()
811 mask = BITMAP_LAST_WORD_MASK(nbits); in bitmap_write()
815 fit = space >= nbits; in bitmap_write()
823 map[index + 1] &= BITMAP_FIRST_WORD_MASK(start + nbits); in bitmap_write()