raw_atomic_f..._and_release(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 raw_atomic_f..._and_release β€” the kernel API manual, bestie edition 🌸

okay so. unix manual page: raw_atomic_f..._and_release(9), straight out of the Kernel API Manual. that is the whole title and honestly she's a mouthful, so let's get into it πŸ’…


✨ NAME ✨

raw_atomic_fetch_and_release β€” an atomic bitwise AND, but make it release-ordered πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

int raw_atomic_fetch_and_release (int i , atomic_t *v );

πŸ’– ARGUMENTS πŸ’–

  • i β€” an int value. the thing you're AND-ing with. that's it, she's just a number πŸ’β€β™€οΈ
  • v β€” a pointer to atomic_t. your actual atomic variable, the main character of this whole operation πŸ‘‘

πŸ”₯ DESCRIPTION πŸ”₯

So the vibe is: this bad girl atomically updates v to (v & i), and she does it with release ordering. like, she's not just doing math at you, she's doing math with memory ordering and she's doing it in one indivisible little moment. iconic behavior, no notes ✨

And hear me out β€” it's safe to use in noinstr code. that's the whole reason the raw_ version exists, fr fr.

but bestie, listen: prefer atomic_fetch_and_release everywhere else. this one's for the special little noinstr situations 🫢

πŸ‘‘ RETURN πŸ‘‘

She gives you back the original value of v. so you get the before-picture, and v itself is the after-picture. very generous of her πŸ’œ


⭐ SEE ALSO ⭐

Kernel file: ./include/linux/atomic/atomic-arch-fallback.h

okay so this next part is the whole family reunion and EVERYONE showed up. i'm not leaving a single cousin out, i would never 😭

the raw_atomic_* girlies:

and now the 64-bit side of the family, same energy, twice the bits πŸ’€:


and that's the whole page, bestie, you ate it up πŸ“

πŸ’Œ cute little sign-off: this one lives in ./include/linux/atomic, and the source/version + date stamp on the original says October 2026 β€” so yeah, she's from the future and she's still release-ordered. periodt πŸ’…βœ¨
πŸ“¦ where this page comes from