Lines Matching refs:nbits

38  * The generated code is more efficient when nbits is known at
43 * bitmap_zero(dst, nbits) *dst = 0UL
44 * bitmap_fill(dst, nbits) *dst = ~0UL
45 * bitmap_copy(dst, src, nbits) *dst = *src
46 * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2
47 * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2
48 * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2
49 * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2)
50 * bitmap_complement(dst, src, nbits) *dst = ~(*src)
51 * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal?
52 * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap?
53 * bitmap_subset(src1, src2, nbits) Is *src1 a subset of *src2?
54 * bitmap_empty(src, nbits) Are all bits zero in *src?
55 * bitmap_full(src, nbits) Are all bits set in *src?
56 * bitmap_weight(src, nbits) Hamming Weight: number set bits
57 * bitmap_weight_and(src1, src2, nbits) Hamming Weight of and'ed bitmap
58 * bitmap_weight_andnot(src1, src2, nbits) Hamming Weight of andnot'ed bitmap
59 * bitmap_set(dst, pos, nbits) Set specified bit area
60 * bitmap_clear(dst, pos, nbits) Clear specified bit area
63 * bitmap_shift_right(dst, src, n, nbits) *dst = *src >> n
64 * bitmap_shift_left(dst, src, n, nbits) *dst = *src << n
65 * bitmap_cut(dst, src, first, n, nbits) Cut n bits from first, copy rest
66 * bitmap_replace(dst, old, new, mask, nbits) *dst = (*old & ~(*mask)) | (*new & *mask)
67 * bitmap_scatter(dst, src, mask, nbits) *dst = map(dense, sparse)(src)
68 * bitmap_gather(dst, src, mask, nbits) *dst = map(sparse, dense)(src)
69 * bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
70 * bitmap_bitremap(oldbit, old, new, nbits) newbit = map(old, new)(oldbit)
71 * bitmap_onto(dst, orig, relmap, nbits) *dst = orig relative to relmap
72 * bitmap_fold(dst, orig, sz, nbits) dst bits = orig bits mod sz
73 * bitmap_parse(buf, buflen, dst, nbits) Parse bitmap dst from kernel buf
74 * bitmap_parse_user(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
75 * bitmap_parselist(buf, dst, nbits) Parse bitmap dst from kernel buf
76 * bitmap_parselist_user(buf, dst, nbits) Parse bitmap dst from user buf
80 * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst
81 * bitmap_from_arr64(dst, buf, nbits) Copy nbits from u64[] buf to dst
82 * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst
83 * bitmap_to_arr64(buf, src, nbits) Copy nbits from buf to u64[] dst
106 * find_first_zero_bit(addr, nbits) Position first zero bit in *addr
107 * find_first_bit(addr, nbits) Position first set bit in *addr
108 * find_next_zero_bit(addr, nbits, bit)
110 * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit
111 * find_next_and_bit(addr1, addr2, nbits, bit)
128 unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags);
129 unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
130 unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
131 unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
138 unsigned int nbits, gfp_t flags);
140 unsigned int nbits, gfp_t flags);
147 const unsigned long *bitmap2, unsigned int nbits);
151 unsigned int nbits);
153 unsigned int nbits);
155 unsigned int shift, unsigned int nbits);
157 unsigned int shift, unsigned int nbits);
159 unsigned int first, unsigned int cut, unsigned int nbits);
161 const unsigned long *bitmap2, unsigned int nbits);
163 const unsigned long *bitmap2, unsigned int nbits);
165 const unsigned long *bitmap2, unsigned int nbits);
167 const unsigned long *bitmap2, unsigned int nbits);
170 const unsigned long *mask, unsigned int nbits);
172 const unsigned long *bitmap2, unsigned int nbits);
174 const unsigned long *bitmap2, unsigned int nbits);
175 unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits);
177 const unsigned long *bitmap2, unsigned int nbits);
179 const unsigned long *bitmap2, unsigned int nbits);
214 const unsigned long *old, const unsigned long *new, unsigned int nbits);
220 unsigned int sz, unsigned int nbits);
223 #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
225 static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
227 unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
229 if (small_const_nbits(nbits))
235 static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
237 unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
239 if (small_const_nbits(nbits))
246 unsigned int nbits)
248 unsigned int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
250 if (small_const_nbits(nbits))
260 const unsigned long *src, unsigned int nbits)
262 bitmap_copy(dst, src, nbits);
263 if (nbits % BITS_PER_LONG)
264 dst[nbits / BITS_PER_LONG] &= BITMAP_LAST_WORD_MASK(nbits);
277 unsigned int nbits);
279 unsigned int nbits);
281 #define bitmap_from_arr32(bitmap, buf, nbits) \
283 (const unsigned long *) (buf), (nbits))
284 #define bitmap_to_arr32(buf, bitmap, nbits) \
286 (const unsigned long *) (bitmap), (nbits))
294 void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits);
295 void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits);
297 #define bitmap_from_arr64(bitmap, buf, nbits) \
298 bitmap_copy_clear_tail((unsigned long *)(bitmap), (const unsigned long *)(buf), (nbits))
299 #define bitmap_to_arr64(buf, bitmap, nbits) \
300 bitmap_copy_clear_tail((unsigned long *)(buf), (const unsigned long *)(bitmap), (nbits))
304 const unsigned long *src2, unsigned int nbits)
306 if (small_const_nbits(nbits))
307 return (*dst = *src1 & *src2 & BITMAP_LAST_WORD_MASK(nbits)) != 0;
308 return __bitmap_and(dst, src1, src2, nbits);
312 const unsigned long *src2, unsigned int nbits)
314 if (small_const_nbits(nbits))
317 __bitmap_or(dst, src1, src2, nbits);
321 const unsigned long *src2, unsigned int nbits)
323 if (small_const_nbits(nbits))
326 __bitmap_xor(dst, src1, src2, nbits);
330 const unsigned long *src2, unsigned int nbits)
332 if (small_const_nbits(nbits))
333 return (*dst = *src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
334 return __bitmap_andnot(dst, src1, src2, nbits);
338 unsigned int nbits)
340 if (small_const_nbits(nbits))
343 __bitmap_complement(dst, src, nbits);
354 const unsigned long *src2, unsigned int nbits)
356 if (small_const_nbits(nbits))
357 return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
358 if (__builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
359 IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
360 return !memcmp(src1, src2, nbits / 8);
361 return __bitmap_equal(src1, src2, nbits);
369 * @nbits: number of bits in each of these bitmaps
376 unsigned int nbits)
378 if (!small_const_nbits(nbits))
379 return __bitmap_or_equal(src1, src2, src3, nbits);
381 return !(((*src1 | *src2) ^ *src3) & BITMAP_LAST_WORD_MASK(nbits));
386 unsigned int nbits)
388 if (small_const_nbits(nbits))
389 return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
391 return __bitmap_intersects(src1, src2, nbits);
395 const unsigned long *src2, unsigned int nbits)
397 if (small_const_nbits(nbits))
398 return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits));
400 return __bitmap_subset(src1, src2, nbits);
403 static inline bool bitmap_empty(const unsigned long *src, unsigned nbits)
405 if (small_const_nbits(nbits))
406 return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
408 return find_first_bit(src, nbits) == nbits;
411 static inline bool bitmap_full(const unsigned long *src, unsigned int nbits)
413 if (small_const_nbits(nbits))
414 return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits));
416 return find_first_zero_bit(src, nbits) == nbits;
420 unsigned int bitmap_weight(const unsigned long *src, unsigned int nbits)
422 if (small_const_nbits(nbits))
423 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
424 return __bitmap_weight(src, nbits);
429 const unsigned long *src2, unsigned int nbits)
431 if (small_const_nbits(nbits))
432 return hweight_long(*src1 & *src2 & BITMAP_LAST_WORD_MASK(nbits));
433 return __bitmap_weight_and(src1, src2, nbits);
438 const unsigned long *src2, unsigned int nbits)
440 if (small_const_nbits(nbits))
441 return hweight_long(*src1 & ~(*src2) & BITMAP_LAST_WORD_MASK(nbits));
442 return __bitmap_weight_andnot(src1, src2, nbits);
446 unsigned int nbits)
448 if (__builtin_constant_p(nbits) && nbits == 1)
450 else if (small_const_nbits(start + nbits))
451 *map |= GENMASK(start + nbits - 1, start);
454 __builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
455 IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
456 memset((char *)map + start / 8, 0xff, nbits / 8);
458 __bitmap_set(map, start, nbits);
462 unsigned int nbits)
464 if (__builtin_constant_p(nbits) && nbits == 1)
466 else if (small_const_nbits(start + nbits))
467 *map &= ~GENMASK(start + nbits - 1, start);
470 __builtin_constant_p(nbits & BITMAP_MEM_MASK) &&
471 IS_ALIGNED(nbits, BITMAP_MEM_ALIGNMENT))
472 memset((char *)map + start / 8, 0, nbits / 8);
474 __bitmap_clear(map, start, nbits);
478 unsigned int shift, unsigned int nbits)
480 if (small_const_nbits(nbits))
481 *dst = (*src & BITMAP_LAST_WORD_MASK(nbits)) >> shift;
483 __bitmap_shift_right(dst, src, shift, nbits);
487 unsigned int shift, unsigned int nbits)
489 if (small_const_nbits(nbits))
490 *dst = (*src << shift) & BITMAP_LAST_WORD_MASK(nbits);
492 __bitmap_shift_left(dst, src, shift, nbits);
499 unsigned int nbits)
501 if (small_const_nbits(nbits))
504 __bitmap_replace(dst, old, new, mask, nbits);
512 * @nbits: number of bits in each of these bitmaps
543 const unsigned long *mask, unsigned int nbits)
548 bitmap_zero(dst, nbits);
550 for_each_set_bit(bit, mask, nbits)
559 * @nbits: number of bits in each of these bitmaps
597 const unsigned long *mask, unsigned int nbits)
602 bitmap_zero(dst, nbits);
604 for_each_set_bit(bit, mask, nbits)