bitmap_gather(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

okay so bestie, this is bitmap_gather(9) from the Kernel API Manual β€” yes, we're in kernel land and it's giving big-brain hours πŸ’…

bitmap_gather β€” Gather a bitmap according to given mask. Periodt.


✨ SYNOPSIS ✨

void bitmap_gather (unsigned long *dst , const unsigned long *src ,
const unsigned long *mask , unsigned int nbits );

🧚 ARGUMENTS 🧚

  • dst β€” the gathered bitmap, aka the glow-up result πŸ’–
  • src β€” the scattered bitmap, aka the messy starting point
  • mask β€” the mask representing bits to extract from in the scattered bitmap
  • nbits β€” number of bits in each of these bitmaps

πŸ’– DESCRIPTION πŸ’–

It gathers a bitmap with sparse bits according to the given mask. Literally that's the whole vibe: mask says which bits to pull, and bitmap_gather pulls them into dst. No cap. ✨


🌸 EXAMPLE 🌸

If src bitmap = 0x0302, with mask = 0x1313, dst will be 0x001a. Slay.

Here's the exact binary layout from the page, iykyk:

Or in binary form src                 mask                   dst
0000001100000010     0001001100010011        0000000000011010

And yes: (Bits 0, 1, 4, 8, 9, 12 are copied to the bits 0, 1, 2, 3, 4, 5).

A more 'visual' description of the operation is giving diagram main character energy:

            mask: ...v..vv...v..vv
            src:  0000001100000010
                     ^  ^^   ^   0
                     |  ||   |  10
                     |  ||   > 010
                     |  |+--> 1010
                     |  +--> 11010
                     +----> 011010
            dst:  0000000000011010

A relationship exists between bitmap_gather and bitmap_scatter β€” see bitmap_scatter for the bitmap scatter detailed operations. TL;DR: bitmap_scatter can be seen as the 'reverse' bitmap_gather operation, bestie πŸ¦‹

Suppose scattered computed using bitmap_scatter(scattered, src, mask, n). The operation bitmap_gather(result, scattered, mask, n) leads to a result equal or equivalent to src.

The result can be 'equivalent' because bitmap_scatter and bitmap_gather are not bijective. The result and src values are equivalent in that sense that a call to bitmap_scatter(res, src, mask, n) and a call to bitmap_scatter(res, result, mask, n) will lead to the same res value. Fr fr.


πŸ¦‹ SEE ALSO πŸ¦‹


mwah πŸ’‹ β€” source/version: ./include/linux, date: October 2026. Keep slaying those bitmaps, bestie πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from