test_and_clear_bit(9)
π test_and_clear_bit(9) π
okay so bestie, welcome to the Kernel API Manual β this one's a little kernel function called test_and_clear_bit, and honestly? she's iconic. β¨
πΈ NAME πΈ
test_and_clear_bit β clear a bit and return its old value. that's it. that's the whole vibe. π
π¦ SYNOPSIS π¦
bool test_and_clear_bit (long nr , volatile unsigned long *addr );
like, she takes two things and gives you back a bool. main character energy. π
π ARGUMENTS π
nrβ the bit you wanna clear. yes, this one. this is the bit. π«Άaddrβ the address to count from. that's where the counting happens. no cap. π«
π₯ DESCRIPTION π₯
so here's the tea: this is an atomic, fully-ordered operation β meaning it comes with an implied full memory barrier. like, she's not just clearing a bit, she's doing it atomically AND respecting the full ordering. the way that she's both ππ₯
bestie pls remember: atomic + fully ordered = no sneaky reordering shenanigans. the memory barrier is implied, so you don't gotta ask for it, she just comes with it. periodt. π
π§ SEE ALSO π§
- Kernel file
./include/asm-generic/bitops/instrumented-atomic.h set_bit(9)clear_bit(9)change_bit(9)test_and_set_bit(9)test_and_change_bit(9)
the whole bitops friend group!! go say hi to all of them, they're all slay in their own way ππ
okay that's the whole page!! π this lil beauty lives in ./include/asm-generic/bitops and it's dated October 2026 β so like, future vibes only. mwah πβ¨ go clear some bits, bestie, you got this π«Άπ
π¦ 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