bitmap_bitremap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« bitmap_bitremap πŸ’«

okay bestie, so this is a page from the Kernel API Manual β€” it's bitmap_bitremap(9), and honestly? it's giving "tiny function, huge brain" energy. it takes one single bit position and re-maps it through a pair of bitmaps. that's it. that's the whole gig. iconic, lowkey.


✨ SYNOPSIS ✨

int bitmap_bitremap (int oldbit , const unsigned long *old , const unsigned long *new , int bits );

πŸŽ€ ARGUMENTS πŸŽ€

  • oldbit β€” the bit position you're asking about, i.e. the one getting mapped. the main character, fr.
  • old β€” defines the domain of the map. the "from" side of the situationship.
  • new β€” defines the range of the map. the "to" side. slay.
  • bits β€” how many bits are in each of these bitmaps. yes, each. both of them. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe. let old and new define a mapping of bit positions, such that whatever position is held by the n-th set bit in old gets mapped to the n-th set bit in new. matching set bits to matching set bits, ngl it's cute.

but wait, there's a more general case 🫢 β€” allowing for the possibility that the weight 'w' of new is less than the weight of old. in that scenario, you map the position of the n-th set bit in old to the position of the m-th set bit in new, where m == n % w. yeah. modulo. the math is mathing.

and the positions of unset bits in old? they get mapped to themselves. it's the identity map. they said "no notes, we're staying exactly as we are" and honestly respect.

then you apply all of that to bit position oldbit, and it returns the new bit position. simple as that. ⭐

okay, example time because this is where it clicks:

say old has bits 4 through 7 set, and new has bits 12 through 15 set. this defines the mapping of bit position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other bit positions unchanged. so if say oldbit is 5, then this routine returns 13. boom. 🎯 literally that's it, you ate.


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! πŸ§šπŸ’œ this lil masterpiece lives in ./lib and the date on it is October 2026 β€” so yeah, she's from the future and she's still serving. mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from