atomic_fetch_and_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ atomic_fetch_and_relaxed(9) ✨

okay so bestie, welcome to the atomic_fetch_and_relaxed(9) page from the Kernel API Manual πŸ’… this one's a lil atomic bitwise AND and honestly it's giving main-character energy in the concurrency department πŸ”₯

πŸŽ€ NAME πŸŽ€

atomic_fetch_and_relaxed β€” atomic bitwise AND, but make it relaxed ordering πŸ¦‹

🌸 SYNOPSIS 🌸

int atomic_fetch_and_relaxed (int i , atomic_t *v );

πŸ’– ARGUMENTS πŸ’–

  • i β€” an int value. that's the bitmask you're AND-ing in, bestie ✨
  • v β€” pointer to atomic_t. this is the atomic thing you're AND-ing 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

so what it does: it atomically updates v to (v & i) with relaxed ordering. the whole update happens as one uninterrupted unit, no cap πŸ’―

⚠️ lowkey important: this one is unsafe to use in noinstr code. if you're in there, you gotta use raw_atomic_fetch_and_relaxed instead. no exceptions, bestie 😭

🌈 RETURN 🌈

it gives you back the original value of v β€” like, the value from before the AND landed ✨ so you can peek at what was there, iconic behavior πŸŽ€

πŸ’€ SEE ALSO πŸ’€

everything lives in the kernel file ./include/linux/atomic/atomic-instrumented.h β€” and here's the whole friend group, fr fr πŸ’œ

the base atomic_* squad πŸ¦‹

the bitwise babes (the ones right next to this one) πŸ’…

the swap + compare crew πŸ”₯

the testy ones πŸ’€

the "unless" girlies 🧚


the atomic64_* extended universe ⭐


the atomic_long_* finale πŸŽ€


and that's the whole page, bestie 🫢 go forth and AND your bits atomically πŸ’…βœ¨

source: ./include/linux/atomic Β· version drop: October 2026 Β· atomic_fetch_and_relaxed(9) β€” mwah, see u in the group chat πŸŽ€πŸ’œ

πŸ“¦ where this page comes from