bitmap_pos_to_ord(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 in buf (and the rule is 0 <= pos < nbits, no cap)
  • nbits β€” the number of valid bit positions in buf. so basically how much of buf actually 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 πŸ’œ

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