___test_and_change_bit(9)
π ___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'svolatile 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 π₯
- Kernel file
./include/asm-generic/bitops/instrumented-non-atomic.hβ yes the whole filename. she's long. she's iconic. π ___set_bit(9)___clear_bit(9)___change_bit(9)___test_and_set_bit(9)___test_and_clear_bit(9)_test_bit(9)_test_bit_acquire(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms