arch___test_and_set_bit(9)
πΈ 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
- 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