bitmap_gather(9)
π 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 pointmaskβ the mask representing bits to extract from in the scattered bitmapnbitsβ 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 π¦
- Kernel file
./include/linux/bitmap.hβbitmap overview(9) bitmap bitops(9)declare bitmap(9)bitmap_find_next_zero_area(9)bitmap_or_equal(9)bitmap_weight_from(9)bitmap_scatter(9)bitmap_release_region(9)bitmap_allocate_region(9)bitmap_find_free_region(9)BITMAP_FROM_U64(9)bitmap_from_u64(9)bitmap_read(9)bitmap_write(9)
mwah π β source/version: ./include/linux, date: October 2026. Keep slaying those bitmaps, bestie π«Άπ
π¦ 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