bitmap_fold(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« bitmap_fold(9) πŸ’«

okay so bestie, welcome to bitmap_fold β€” the kernel API manual page that's here to teach you how to fold a bigger bitmap into a smaller one, modulo a size you specify. yes, we're doing math. yes, it's iconic. ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

void bitmap_fold (unsigned long *dst , const unsigned long *orig ,
       unsigned int sz , unsigned int nbits );

like, that's the whole signature. four things go in, nothing comes out. it's giving "void because I don't need to explain myself" energy πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • dst β€” the resulting smaller bitmap. this is the glow-up destination, the itty-bitty baby bitmap where everything ends up. πŸ“
  • orig β€” the original larger bitmap. the big one. the main character, honestly, but it's not the one getting written to. 😭
  • sz β€” the specified size. this is the modulus, the magic number, the ~vibe check~ that decides where each bit lands. πŸ”₯
  • nbits β€” number of bits in each of these bitmaps. both of them. they're matching, okay? 🫢

🌸 DESCRIPTION 🌸

okay so here's the tea, and I mean the whole tea β˜•

for each bit oldbit in orig, you set bit oldbit mod sz in dst. that's it. that's the fold. the way that a bit at position oldbit literally just slides down into oldbit mod sz β€” chef's kiss. 🧚

and then? clear all other bits in dst. all of them. not some, not most β€” all the other bits. no cap. πŸ’€

for the why and the how of using this, the original says to see further the comment and Example [2] for bitmap_onto. go read that, bestie, it's all connected, iykyk. πŸ“–


πŸ‘‘ SEE ALSO πŸ‘‘

so like, the whole friend group. the kernel file ./lib/bitmap.c, plus:

go read them all, they're literally all bangers, periodt. ⭐


and that's the page, bestie!! πŸŽ€ this little number lives in ./lib and it's dated October 2026, so like β€” screenshot it, cite it, love it. mwah πŸ’œβœ¨

πŸ“¦ where this page comes from