__ffs(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

okay so this is __ffs β€” the kernel API manual page for it, bestie β€” and it does exactly one thing: find the first bit in a word. that's it. that's the whole vibe. ✨


✨ SYNOPSIS ✨

unsigned int __ffs (unsigned long word );

like literally that's the entire signature, copy it exactly please, no freestyling πŸ™ˆ


πŸŽ€ ARGUMENTS πŸŽ€

  • word β€” the word you wanna search. that's the one. the word. the thing you're hunting through for that first lil bit πŸ¦‹

πŸ¦‹ DESCRIPTION πŸ¦‹

so you hand it a word and it goes looking for the first bit. cute, simple, main character energy.

but β€” and this is the part where you gotta listen to me, fr fr β€” the behaviour is undefined if no bit exists. like, not "returns 0", not "returns -1", undefined. 😭 so your code should check against 0 first before you even think about calling this. do the vibe check on zero. periodt. πŸ’€

⚠️ no cap: no bit in the word = undefined behaviour. check against 0 first, always, i'm begging 🫢

🌸 SEE ALSO 🌸

  • Kernel file ./tools/include/asm-generic/bitops/__ffs.h β€” go read the source, iykyk πŸ‘‘

okay that's the whole page, you ate it, i'm obsessed πŸ’– and just so we're cute and complete: this came from the source file ./tools/include/asm-generic/bi... and the date on it is October 2026 β€” so yeah, __ffs(9), fresh off the kernel API manual, slay πŸŒˆπŸ‘‘πŸŽ€

πŸ“¦ where this page comes from