arch___test_and_clear_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… arch___test_and_clear_bit(9) β€” Kernel API Manual ✨

okay so bestie, buckle up, we're reading a kernel API manual page together and honestly? it's lowkey iconic. this is arch___test_and_clear_bit, straight out of the kernel API manual, and it's giving "tiny function, big responsibilities." πŸŽ€


🌸 NAME 🌸

arch___test_and_clear_bit β€” clear a bit and return its old value 🫢


⭐ SYNOPSIS ⭐

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

πŸ¦‹ ARGUMENTS πŸ¦‹

  • nr β€” the bit you want to clear, bestie. that's the one. πŸ’…
  • addr β€” the address to count from. yes, "count from," that's literally what it says, don't come for me. 🌈

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea, and it's important tea: this operation is non-atomic and can be reordered. not me warning you about race conditions twice in one sentence, but here we are. 😭

if two examples of this operation race, one can appear to succeed but actually fail. like??? imagine winning and then finding out you didn't win. the audacity. πŸ’€

so no cap: you must protect multiple accesses with a lock. periodt. if you skip the lock, that's on you and the vibe check will not be kind. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

  • Kernel file ./arch/sh/include/asm/bitops-op32.h β€” the literal source of truth, iykyk πŸ“
  • arch___change_bit(9) β€” the cousin that changes bits ✨
  • arch___test_and_set_bit(9) β€” the cousin that sets bits 🌸

and that's the whole page, bestie! this one came from ./arch/sh/include/asm and it's dated October 2026, so like… remember it fondly. mwah πŸ’– πŸ§šβ€β™€οΈ πŸ“

πŸ“¦ where this page comes from