- unsigned int count;
-
- assert(type->type_class == RCU_JA_BITMAP);
-
- bitmap = &node->data[0];
- /*
- * Check if n is hot in the bitmap. If yes, count the hweight
- * prior to n, including n, to get the pointer index.
- * The bitmap goes from least significant (0) to most
- * significant (255) as bytes increase.
- */
- byte_nr = n >> CHAR_BIT_SHIFT;
- if (bitmap[byte_nr] & (1U << (n & CHAR_BIT_MASK))) {
- uint8_t byte_iter;
- unsigned long v;
-
- count = 0;
- /* Count entire ulong prior to the one containing n */
- for (byte_iter = 0; byte_iter < JA_FLOOR(byte_nr, sizeof(unsigned long));
- byte_iter += sizeof(unsigned long)) {
- v = *((unsigned long *) &bitmap[byte_iter]);
- count += ja_hweight_ulong(v);
- }
- /*
- * Read only the bits prior to and including n within
- * the ulong containing n. ja_bitfield_read_le goes from
- * less significant to most significant as bytes
- * increase.
- */
- ja_bitfield_read_le(
- (unsigned long *) &bitmap[JA_FLOOR(byte_nr, sizeof(unsigned long))],
- unsigned long, 0, (n & ULONG_BIT_MASK) + 1,
- &v);
- count += ja_hweight_ulong(v);
- } else {
- return NULL;
- }