bitmap_pos_to_ord(9)
π bitmap_pos_to_ord(9) β the Kernel API Manual, bestie edition
okay so picture this: you're deep in ./lib/bitmap.c land, surrounded by bitmaps, and you just wanna know which set bit you're looking at. that's this function. she's the manual for bitmap_pos_to_ord in the Kernel API Manual, and she's here to help. π
β¨ NAME β¨
bitmap_pos_to_ord β find the ordinal of the set bit at a given position in a bitmap π
πΈ SYNOPSIS πΈ
int bitmap_pos_to_ord (const unsigned long *buf , unsigned int pos ,
unsigned int nbits );
like, that's the whole vibe. three args, one int back. slay.
π¦ ARGUMENTS π¦
bufβ pointer to a bitmap. yeah. that's the canvas, bestie. πΌοΈposβ a bit position inbuf(and the rule is0 <= pos < nbits, no cap)nbitsβ the number of valid bit positions inbuf. so basically how much ofbufactually counts. π₯
π DESCRIPTION π
so here's the tea β: this maps the bit sitting at position pos in buf (a bitmap of length nbits) to the ordinal β like, which set bit it is. and bestie, listen, if that bit is not set, or if pos isn't even a valid bit position? it maps to -1. that's the "nope, nothing here" answer. π
let's do the example, because the example ATE: say just bits 4 through 7 are set in buf. then pos values 4 through 7 get mapped to 0 through 3, respectively β and every other pos value gets mapped to -1. and when pos value 7 gets mapped to (aka returns) ord value 3 in this example, that literally means bit 7 is the 3rd (starting with the 0th π) set bit in buf. iykyk.
the bit positions 0 through bits are valid positions in buf. β¨
ngl, the counting starts at 0, so "3rd" means index 3. don't come for me, that's just how the 0th one works. π
π SEE ALSO π
- Kernel file
./lib/bitmap.c bitmap introduction(9)__bitmap_shift_right(9)__bitmap_shift_left(9)bitmap_cut(9)bitmap_find_next_zero_area_off(9)bitmap_remap(9)bitmap_bitremap(9)bitmap_onto(9)bitmap_fold(9)bitmap_from_arr32(9)bitmap_to_arr32(9)bitmap_from_arr64(9)bitmap_to_arr64(9)
like a whole friend group of bitmap functions. go say hi. π«Άπ
and that's the page, bestie β brought to you straight out of ./lib, dated October 2026, page name bitmap_pos_to_ord(9). periodt. π
β
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms