find_next_and_bit(9)
π find_next_and_bit (kernel API manual, bestie)
okay so this page lives in the Kernel API Manual and it's about one very specific little function: find_next_and_bit. it's giving "two bitmaps walk into a bar and we find where they BOTH say yes" β¨
π NAME π
find_next_and_bit β find the next set bit in both memory regions π«Ά
like, both. not one. not either. both. that's the whole personality of this function and honestly? iconic.
β¨ SYNOPSIS β¨
unsigned long find_next_and_bit (const unsigned long *addr1 , const
unsigned long *addr2 , unsigned long size , unsigned long offset );
that's the whole vibe right there π four args, returns an unsigned long, no drama.
πΈ ARGUMENTS πΈ
addr1β the first address to base the search on π (bitmap number one, the main character)addr2β the second address to base the search on π¦ (bitmap number two, also main character, it's a dual-lead situation)sizeβ the bitmap size in bits π (how far the search is even allowed to look, no cap)offsetβ the bitnumber to start searching at β (where you're picking up the search, not from the very top)
π DESCRIPTION π
so here's the tea: it returns the bit number for the next set bit π₯
and if no bits are set? it returns size. that's it. that's the fallback. size is your "nope, nothing, we looked, bye" answer π
ngl this is the crucial part: if no bits are set, returnssize. don't go assuming it returns some negative thing or-1, because it does NOT. it returnssize, periodt.
π SEE ALSO π
- Kernel file
./tools/include/linux/find.h find_next_bit(9)find_next_zero_bit(9)find_first_bit(9)find_first_and_bit(9)find_first_zero_bit(9)
go read those too, they're the whole friend group π§ and they're all hanging out in the same header π
okay that's the page!! π this lil beauty comes from ./tools/include/linux and it's dated October 2026 β so yes, future-dated, we stay ahead of the timeline πβ¨π¦ see you in the next SEE ALSO, 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