atomic_fetch_and(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_fetch_and(9) β€” from the Kernel API Manual, bestie ✨

okay so first things first: this page is atomic_fetch_and(9) from the Kernel API Manual, and it's genuinely one of the cutest little atomic ops out there. Let's get into it πŸŽ€


🌸 NAME 🌸

atomic_fetch_and β€” atomic bitwise AND with full ordering. that's it. that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

int atomic_fetch_and (int i , atomic_t *v );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • i β€” an int value. your mask, your moment, your main character 🫢
  • v β€” pointer to an atomic_t. this is the thing getting updated, bestie.

πŸ’– DESCRIPTION πŸ’–

so what it does: it atomically updates v to (v & i) β€” and yes, with full ordering. literally the whole package πŸ”₯

⚠️ okay so important: it is unsafe to use in noinstr code 😭 use raw_atomic_fetch_and there instead. no cap, please don't skip this one πŸ™ˆ

πŸ‘‘ RETURN πŸ‘‘

it gives you back the original value of v β€” like, before the AND happened. the before picture, if you will ✨


🧚 SEE ALSO 🧚

Kernel file ./include/linux/atomic/atomic-instrumented.h, and like... a lot of friends πŸ’œ every single one of them, here we go:

the atomic_* girlies:

the atomic64_* icons:

the atomic_long_* legends:


and that's the whole page, bestie 🫢 this one lives in ./include/linux/atomic and it's dated October 2026 β€” go forth and AND atomically, you absolute icon πŸ’…βœ¨

πŸ“¦ where this page comes from