for_each_clear_bitrange(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ for_each_clear_bitrange ✨

okay so real talk bestie, welcome to the Kernel API Manual β€” section 9 for all my fellow kernel girlies out there πŸ’… this one's about for_each_clear_bitrange, and it's honestly such a vibe once you get it.


🌸 NAME 🌸

for_each_clear_bitrange β€” iterate over all unset bit ranges [b; e) πŸŽ€

like, all of them. every single little stretch of zeroes. no bit left behind, fr fr.


πŸ¦‹ SYNOPSIS πŸ¦‹

for_each_clear_bitrange (b , e , addr , size );

that's the whole thing. four args, one macro, infinite potential ✨


πŸ’– ARGUMENTS πŸ’–

  • b β€” bit offset of start of current bitrange (first unset bit). so like, where the clear zone begins πŸ‘‘
  • e β€” bit offset of end of current bitrange (first set bit). where it ends, and yes, the [b; e) half-open thing means e is not included, periodt πŸ’…
  • addr β€” bitmap address to base the search on. your actual bitmap, the main character of this whole operation 🌟
  • size β€” bitmap size in number of bits. how far the search is allowed to wander, ngl don't let it roam past this πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯

bestie there are SO many siblings in this family, it's giving huge family reunion energy 😭 all chillin' in the Kernel file ./include/linux/find.h:

find_next_bit(9), find_next_and_bit(9), find_next_andnot_bit(9), find_next_or_bit(9), find_next_zero_bit(9), find_first_bit(9), find_nth_bit(9), find_nth_and_bit(9), find_nth_and_andnot_bit(9), find_first_and_bit(9), find_first_andnot_bit(9), find_first_and_and_bit(9), find_first_zero_bit(9), find_last_bit(9), find_next_and_bit_wrap(9), find_next_bit_wrap(9), find_next_clump8(9), for_each_set_bitrange(9), for_each_set_bitrange_from(9), for_each_clear_bitrange_from(9), for_each_set_bit_wrap(9), for_each_set_clump8(9)

go read them all, iykyk πŸ§šβ€β™€οΈ honestly iconic of them to all live together like that.

lowkey a reminder: if you ever need the set bits instead of the clear ones, that's a whole different macro (for_each_set_bitrange), so don't mix them up bestie πŸ’€

okay that's the page!! mwah 🫢 this dropped in ./include/linux, in the October 2026 era, and yes β€” this page is literally called for_each_clear_bitrange(9). slay, bye πŸ’œπŸ“

πŸ“¦ where this page comes from