bitmap_remap(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿฆ‹ 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 remapped
  • old โ€” this one defines the domain of the map
  • new โ€” and this one defines the range of the map
  • nbits โ€” 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 say old has bits 4 through 7 set, and new has bits 12 through 15 set. That defines the mapping of bit position 4 to 12, 5 to 13, 6 to 14 and 7 to 15 โ€” and all other bit positions stay unchanged. So if say src comes into this routine with bits 1, 5 and 7 set, then dst should leave with bits 1, 13 and 15 set. 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