find_first_zero_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” size is both your search limit and the "sorry bestie, nothing found" answer. so don't go treating a size return 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