bitmap_ord_to_pos(9)

bitmap_ord_to_pos9

Find position of n-th set bit in bitmap

Usage

unsigned int bitmap_ord_to_pos(const unsigned long * buf, unsigned int ord, unsigned int nbits);

Arguments

buf

pointer to bitmap

ord

ordinal bit position (n-th set bit, n >= 0)

nbits

number of valid bit positions in buf

Overview

Map the ordinal offset of bit ord in buf to its position in buf. Value of ord should be in range 0 <= ord < weight(buf). If ord >= weight(buf), returns nbits.

If for example, just bits 4 through 7 are set in buf, then ord values 0 through 3 will get mapped to 4 through 7, respectively, and all other ord values returns nbits. When ord value 3 gets mapped to (returns) pos value 7 in this example, that means that the 3rd set bit (starting with 0th) is at position 7 in buf.

The bit positions 0 through nbits-1 are valid positions in buf.

Releases

6 releases since Debian 4.0 (Etch); the text changed 5 times.

  1. 4.0
  2. 5.0
  3. 6.0
  4. 7
  5. 8
  6. 9

From linux-manual-4.9 4.9.228-1 in Debian 9 (Stretch). Parsed by carta from the page's man source.