bitmap_fold(9)
π« 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:
bitmap introduction(9)__bitmap_shift_right(9)__bitmap_shift_left(9)bitmap_cut(9)bitmap_find_next_zero_area_off(9)bitmap_pos_to_ord(9)bitmap_remap(9)bitmap_bitremap(9)bitmap_onto(9)bitmap_from_arr32(9)bitmap_to_arr32(9)bitmap_from_arr64(9)bitmap_to_arr64(9)
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
- 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