__fls(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ __fls ✨

okay so this is a page from the Kernel API Manual (yes, the kernel has lore and we're reading it πŸ’…) and it's about __fls, bestie. let's get into it.


🌸 NAME 🌸

__fls β€” find the last (most-significant) set bit in a long word πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

unsigned int __fls (unsigned long word );

like, that's the whole signature. that's her. no cap. ✨


πŸ’– ARGUMENTS πŸ’–

  • word β€” the word you're searching πŸ” that's it, that's the argument, she's serving one single parameter and she doesn't need more πŸ‘‘

🌈 DESCRIPTION 🌈

okay so listen closely because this part actually matters 🫢 β€” if there's no set bit in the word at all, the result is undefined. literally undefined. not "zero", not "whatever", undefined 😭 so the docs are like: your code should check against 0 first.

πŸ’€ bestie do NOT skip the zero check. this is the "look both ways before crossing" of bitops. undefined behaviour is not a vibe, it's a jumpscare πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯

  • Kernel file ./include/asm-generic/bitops/builtin-__fls.h β€” go read the source, iykyk πŸ“–βœ¨

and that's the whole page, gorgeous 🌸 this one came from ./include/asm-generic/bitops and it's dated October 2026 β€” so yeah, the kernel docs said "see you in the future, babe" and honestly? iconic. signed, sealed, __fls(9) πŸ’œπŸŽ€

πŸ“¦ where this page comes from