array_index_mask_nospec(9)
π
array_index_mask_nospec(9) π
okay so bestie, this is from the Kernel API Manual, and honestly? array_index_mask_nospec(9) is a whole vibe. No cap. π«Ά
π NAME π
array_index_mask_nospec β generate a ~0 mask when index < size, 0 otherwise. That's it, that's the function. Slay. β¨
πΈ SYNOPSIS πΈ
unsigned long array_index_mask_nospec (unsigned long index , unsigned long size );
π¦ ARGUMENTS π¦
indexβ the array element index, bestie. Like, which element you're looking at. πsizeβ the number of elements in the array. The whole roster, periodt. π
π₯ DESCRIPTION π₯
okay so lowkey the whole point is this: when index is out of bounds (index >= size), the sign bit will be set. Then you extend the sign bit to all bits and invert it β giving a result of zero for an out of bounds index, or ~0 if within bounds [0, size). That's the whole mask moment. Iconic. π
π SEE ALSO π
- Kernel file
./include/linux/nospec.hβ go read it, iykyk π§
xoxo, your girl from ./include/linux β October 2026 edition. Later, 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