arch___test_and_set_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 arch___test_and_set_bit(9) 🌸

okay bestie, welcome to the Kernel API Manual β€” yes that's the manual name, we're being official today πŸ’…. This page is all about arch___test_and_set_bit, and no cap, it's a lil gremlin of a function, so listen up 🫢


✨ NAME ✨

arch___test_and_set_bit β€” Set a bit and return its old value

Like, it sets the bit ✨ and then hands you back what the bit used to be. Iconic behaviour honestly.


πŸ¦‹ SYNOPSIS πŸ¦‹

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

That's the whole vibe. It returns a bool, it takes two args, and it's coming for your bit πŸŽ€


πŸ“ ARGUMENTS πŸ“

  • nr β€” Bit to set. The actual bit, the main character, the one getting flipped 🌟
  • addr β€” Address to count from. This is where we're counting from, bestie, keep up 😭

πŸ’€ DESCRIPTION πŸ’€

Okay so this is the part where I have to be real with you: this operation is non-atomic and it can be reordered. Not me warning you twice, but like, I am warning you twice πŸ™ˆ

If two examples of this operation race, one can appear to succeed but actually fail. The audacity, fr fr. So it's giving "fake success" energy and you cannot trust it.

You must protect multiple accesses with a lock. Periodt. No lock, no bit, no peace πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./arch/sh/include/asm/bitops-op32.h, plus these two icons:


and that's the whole page, bestie! πŸ’–βœ¨ This little gem lives in ./arch/sh/include/asm and the October 2026 version is what you're reading right now. Go forth, set those bits, and please use a lock πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from