___test_and_set_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ___test_and_set_bit β€” Kernel API Manual, bestie edition πŸŽ€

okay so welcome to the Kernel API Manual, the little corner of the docs where we talk about bit-fiddling ✨ and today's main character is ___test_and_set_bit. yes it has three leading underscores. no we don't ask why. iykyk πŸ’€


✨ NAME ✨

___test_and_set_bit β€” set a bit and return its old value 🫢

like, it flips the bit ON and hands you back what the bit used to be. that's the whole personality. iconic tbh πŸ‘‘


🌸 SYNOPSIS 🌸

bool ___test_and_set_bit (unsigned long nr , volatile unsigned long
*addr );

literally copy that exactly, spacing and all, don't @ me πŸ™ˆ


πŸ¦‹ ARGUMENTS πŸ¦‹

  • nr β€” the bit to set. which bit, bestie? this one. 🎯
  • addr β€” the address to count from. your starting point, your home base, your origin story πŸ’–

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea and you need to hear it 🍡

This operation is non-atomic and can be reordered. that's right, it's giving chaos gremlin energy 😭 it does not respect your locks, it does not respect your ordering, it simply vibes ✨

and because of that: if two examples of this operation race, one can appear to succeed but actually fail. πŸ’€ not the fake success!! so rude.

⚠️ so what do you do? You must protect multiple accesses with a lock. fr fr. no cap. if you're touching this from more than one place, lock it down like it's your group chat πŸ’…πŸ”’

🌈 SEE ALSO 🌈

(sibling energy, honestly. the whole bitops family ate πŸ”₯)


πŸ’œ okay that's the page!! this little masterpiece comes to you from ./tools/include/asm-generic/bi... (yes, truncated with dots, that's just how it's written, don't come for me 😭) and it's dated October 2026 β€” future icon behavior tbh ⭐ and it signs off as ___test_and_set_bit(9), three underscores and all, slay πŸ’…πŸŽ€

πŸ“¦ where this page comes from