Lines Matching +full:bit +full:- +full:mask

1 /* SPDX-License-Identifier: BSD-3-Clause */
50 /* Determine which chunk a bit belongs in */
53 #define BITS_TO_CHUNKS(sz) (((sz) + BITS_PER_CHUNK - 1) / BITS_PER_CHUNK)
54 /* Which bit inside a chunk this bit corresponds to */
57 #define LAST_CHUNK_BITS(nr) ((((nr) - 1) % BITS_PER_CHUNK) + 1)
60 (BITS_PER_CHUNK - LAST_CHUNK_BITS(nr)))
67 return !!(*bitmap & BIT(nr)); in ice_is_bit_set_internal()
80 * and define macro ICE_ATOMIC_BITOPS to overwrite the default non-atomic
85 *bitmap &= ~BIT(nr); in ice_clear_bit_internal()
90 *bitmap |= BIT(nr); in ice_set_bit_internal()
113 * ice_is_bit_set - Check state of a bit in a bitmap
115 * @nr: the bit to check
117 * Returns true if bit nr of bitmap is set. False otherwise. Assumes that nr
127 * ice_clear_bit - Clear a bit in a bitmap
129 * @nr: the bit to change
131 * Clears the bit nr in bitmap. Assumes that nr is less than the size of the
140 * ice_set_bit - Set a bit in a bitmap
142 * @nr: the bit to change
144 * Sets the bit nr in bitmap. Assumes that nr is less than the size of the
153 * ice_test_and_clear_bit - Atomically clear a bit and return the old bit value
154 * @nr: the bit to change
157 * Check and clear the bit nr in bitmap. Assumes that nr is less than the size
168 * ice_test_and_set_bit - Atomically set a bit and return the old bit value
169 * @nr: the bit to change
172 * Check and set the bit nr in bitmap. Assumes that nr is less than the size of
182 /* ice_zero_bitmap - set bits of bitmap to zero.
188 * will zero every bit in the last chunk, even if those bits are beyond the
198 * ice_and_bitmap - bitwise AND 2 bitmaps and store result in dst bitmap
207 * a non-zero value if at least one bit location from both "source" bitmaps is
208 * non-zero.
214 ice_bitmap_t res = 0, mask; in ice_and_bitmap() local
218 for (i = 0; i < BITS_TO_CHUNKS(size) - 1; i++) { in ice_and_bitmap()
229 mask = LAST_CHUNK_MASK(size); in ice_and_bitmap()
230 dst[i] = (dst[i] & ~mask) | ((bmp1[i] & bmp2[i]) & mask); in ice_and_bitmap()
231 res |= dst[i] & mask; in ice_and_bitmap()
237 * ice_or_bitmap - bitwise OR 2 bitmaps and store result in dst bitmap
251 ice_bitmap_t mask; in ice_or_bitmap() local
255 for (i = 0; i < BITS_TO_CHUNKS(size) - 1; i++) in ice_or_bitmap()
263 mask = LAST_CHUNK_MASK(size); in ice_or_bitmap()
264 dst[i] = (dst[i] & ~mask) | ((bmp1[i] | bmp2[i]) & mask); in ice_or_bitmap()
268 * ice_xor_bitmap - bitwise XOR 2 bitmaps and store result in dst bitmap
282 ice_bitmap_t mask; in ice_xor_bitmap() local
286 for (i = 0; i < BITS_TO_CHUNKS(size) - 1; i++) in ice_xor_bitmap()
294 mask = LAST_CHUNK_MASK(size); in ice_xor_bitmap()
295 dst[i] = (dst[i] & ~mask) | ((bmp1[i] ^ bmp2[i]) & mask); in ice_xor_bitmap()
299 * ice_andnot_bitmap - bitwise ANDNOT 2 bitmaps and result in dst bitmap
313 ice_bitmap_t mask; in ice_andnot_bitmap() local
317 for (i = 0; i < BITS_TO_CHUNKS(size) - 1; i++) in ice_andnot_bitmap()
325 mask = LAST_CHUNK_MASK(size); in ice_andnot_bitmap()
326 dst[i] = (dst[i] & ~mask) | ((bmp1[i] & ~bmp2[i]) & mask); in ice_andnot_bitmap()
330 * ice_find_next_bit - Find the index of the next set bit of a bitmap
335 * Scans the bitmap and returns the index of the first set bit which is equal
374 * ice_find_first_bit - Find the index of the first set bit of a bitmap
378 * Scans the bitmap and returns the index of the first set bit. Will return
392 * ice_is_any_bit_set - Return true of any bit in the bitmap is set
405 * ice_cp_bitmap - copy bitmaps
421 * ice_bitmap_set - set a number of bits in bitmap from a starting position
423 * @pos: first bit position to set
426 * This function sets bits in a bitmap from pos to (pos + num_bits) - 1.
440 * ice_bitmap_hweight - hamming weight of bitmap
452 u16 bit = 0; in ice_bitmap_hweight() local
454 while (size > (bit = ice_find_next_bit(bm, size, bit))) { in ice_bitmap_hweight()
456 bit++; in ice_bitmap_hweight()
463 * ice_cmp_bitmap - compares two bitmaps
473 ice_bitmap_t mask; in ice_cmp_bitmap() local
477 for (i = 0; i < BITS_TO_CHUNKS(size) - 1; i++) in ice_cmp_bitmap()
482 mask = LAST_CHUNK_MASK(size); in ice_cmp_bitmap()
483 if ((bmp1[i] & mask) != (bmp2[i] & mask)) in ice_cmp_bitmap()
490 * ice_bitmap_from_array32 - copies u32 array source into bitmap destination
513 if (entry & BIT(j)) in ice_bitmap_from_array32()
528 if (entry & BIT(j)) in ice_bitmap_from_array32()