test_and_set_bit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… test_and_set_bit(9) β€” like, the Kernel API Manual page you actually wanna read

okay bestie, welcome to the Kernel API Manual, section 9, and today's main character is test_and_set_bit πŸ’–


✨ NAME ✨

test_and_set_bit β€” set a bit and return its old value. that's it, that's the whole vibe πŸŽ€


🌸 SYNOPSIS 🌸

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

literally just hand it a bit number and an address and it does the thing, no cap ✨


πŸ¦‹ ARGUMENTS πŸ¦‹

  • nr β€” the bit you wanna set. which one? that one. the *nr*th one 🎯
  • addr β€” the address to count from. start counting here, bestie 🫢

πŸ”₯ DESCRIPTION πŸ”₯

so this is an atomic fully-ordered operation β€” the docs literally say it comes with an implied full memory barrier. it's giving main character energy, it's giving "i don't need anyone to hold my hand" πŸ˜­πŸ‘‘

⚠️ okay but fr fr, "fully-ordered" is not a cute little detail, it's the whole point. don't go assuming you can reorder stuff around it.

πŸ‘‘ SEE ALSO πŸ‘‘

the whole bit-twiddling friend group, honestly 🌈


and that's the page!! πŸ’œ this one's from ./include/asm-generic/bitops, dated October 2026, and it's test_and_set_bit(9) forever and always β€” slay, go set some bits, mwah πŸ§šπŸ’…

πŸ“¦ where this page comes from