bitmap_remap(9)
๐ฆ bitmap_remap(9) โ the Kernel API Manual, bestie edition ๐
okay so picture this: it's a bitmap_remap kind of day, the manual name is literally Kernel API Manual, and you're about to remap some bits like the icon you are. periodt. โจ
โจ NAME โจ
bitmap_remap โ apply a map defined by a pair of bitmaps to another bitmap ๐
๐ธ SYNOPSIS ๐ธ
void bitmap_remap (unsigned long *dst , const unsigned long *src , const
unsigned long *old , const unsigned long *new , unsigned int nbits );
๐ ARGUMENTS ๐
dstโ the remapped result goes here, bestie ๐ซถsrcโ the subset that's getting remappedoldโ this one defines the domain of the mapnewโ and this one defines the range of the mapnbitsโ how many bits live in each of these bitmaps (all of them, yes, same number)
๐ฅ DESCRIPTION ๐ฅ
So like, let old and new define a mapping of bit positions, right? The vibe is: whatever position is held by the n-th set bit in old gets mapped to the n-th set bit in new. iykyk ๐ซ
Now for the more general case โ because we're allowing for the possibility that the weight w of new is less than the weight of old โ 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. slay, math. ๐งฎโจ
If either of the old and new bitmaps are empty, or if src and dst point to the same location, then this routine just copies src to dst. no thoughts, head empty, copy. ๐
The positions of unset bits in old are mapped to themselves โ that's the identity map, main character energy, it stays exactly where it is. ๐
Then it applies the above specified mapping to src, placing the result in dst, clearing any bits previously set in dst. like, clean slate, no leftovers, we don't do baggage here. ๐
Example time!! ๐ Let's sayoldhas bits4through7set, andnewhas bits12through15set. That defines the mapping of bit position4to12,5to13,6to14and7to15โ and all other bit positions stay unchanged. So if saysrccomes into this routine with bits1,5and7set, thendstshould leave with bits1,13and15set. ate. ๐
๐ซถ 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_pos_to_ord(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) โ the whole squad, go read them too ๐๐
okay that's the whole page!! this one's from ./lib, dropping October 2026, and honestly? iconic. bitmap_remap bestie 4ever ๐โญ๐
๐ฆ 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