find_next_and_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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, returns size. don't go assuming it returns some negative thing or -1, because it does NOT. it returns size, periodt.

πŸ‘‘ SEE ALSO πŸ‘‘

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