find_first_zero_bit(9)
π find_first_zero_bit(9)
okay so real talk, this is a page from the Kernel API Manual and it's genuinely one of the cutest tiny functions in the whole kernel header situation. no cap. it's giving "little helper that does one thing and does it flawlessly" energy, and honestly? we stan. π
β¨ NAME β¨
find_first_zero_bit β find the first cleared bit in a memory region π¦
like, you hand it a chunk of memory, it goes hunting for the first 0 bit hiding in there. that's the whole vibe. iconic behaviour, zero notes. π
πΈ SYNOPSIS πΈ
unsigned long find_first_zero_bit (const unsigned long *addr , unsigned long size );
literally the whole signature, character for character, bestie. don't come for me about the spacing, that's how it's written. π
π ARGUMENTS π
addrβ the address to start the search at. this is where you point the search party. πsizeβ the maximum number of bits to search. think of it as the search radius, except in bits instead of metres. if you're not sure, do the math, don't just yolo a random number. π’
π₯ DESCRIPTION π₯
so here's the tea: it returns the bit number of the first cleared bit β the first 0 it bumps into. that's the return value. a plain old bit index. no drama. β¨
and if there is no zero anywhere in the region you asked it to check? if every single bit is set and it comes up empty-handed? it just returns size. π«Ά
ok but like, that last bit is lowkey the important part βsizeis both your search limit and the "sorry bestie, nothing found" answer. so don't go treating asizereturn as a valid bit position unless you've already confirmed there's actually a zero somewhere in there. iykyk. π
π SEE ALSO π
if you enjoyed this function, may i direct your attention to the rest of the friend group in the kernel file ./tools/include/linux/find.h β they're all in the same header and they all slay in their own way:
go read them too, they deserve the engagement. π
and that's the whole page, bestie! no crumbs left behind π
cute little sign-off because you made it to the end π: this one lives in ./tools/include/linux, it's dated October 2026, and the page is, of course, find_first_zero_bit(9). mwah. ππ
π¦ 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