___test_and_change_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ___test_and_change_bit(9) πŸ’…

okay so welcome to the Kernel API Manual, bestie β€” this is the page for ___test_and_change_bit, and yes, those are three underscores up front. she's extra like that. πŸŽ€


✨ NAME ✨

___test_and_change_bit β€” change a bit and return its old value πŸ‘‘

like, she flips the bit and tells you what it used to be. a little gossipy. we love her for it. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

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

that's it. that's the whole vibe check. two args, one bool coming back at you. ✨


🌸 ARGUMENTS 🌸

  • nr β€” the bit you're changing, babes. that's the one. 🎯
  • addr β€” the address to count from. yes it's volatile unsigned long *, no you may not fight me about it. πŸ™ˆ

πŸ’€ DESCRIPTION πŸ’€

okay this is the important part so like. pay attention. πŸ‘€

this operation is non-atomic.

as in β€” if two instances of this operation race, one can appear to succeed but actually fail. 😭 not "fail loudly." not "throw an error." appear to succeed. fake success. the worst kind. it's giving gaslighting, gatekeeping, girlbossing. 🚩

so if you've got threads doing this on the same bit at the same time, no cap, you have a bug, and it will not be obvious, and you will be sad. atomic variants exist for a reason, bestie. use them. πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

the whole bit-twiddling friend group fr fr. scroll the list, find your girl. 🫢


🌈 SIGN-OFF 🌈

this page came from the kernel file tree at ./include/asm-generic/bitops, dated October 2026 β€” so like, future energy, main character energy, ___test_and_change_bit(9) energy. ⭐

stay atomic out there. don't let the race conditions win. bye bestie!! πŸ’œπŸ§šπŸ“

πŸ“¦ where this page comes from