raw_atomic64_xchg(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

raw_atomic64_xchg β€” atomic exchange with full ordering. Yes bestie, this is the raw_atomic64_xchg(9) page from the Kernel API Manual, and it's lowkey iconic.


✨ SYNOPSIS ✨

s64 raw_atomic64_xchg (atomic64_t *v , s64 new );

πŸ’… ARGUMENTS πŸ’…

  • v β€” pointer to atomic64_t. This is the thing getting swapped, no cap.
  • new β€” the s64 value to assign. This is the shiny new value going in.

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea: this function atomically updates v to new with full ordering. Like, the whole exchange happens atomically, and the ordering is fully there. It's giving "swap with main character energy."

It is safe to use in noinstr code. But if you're not in noinstr, prefer atomic64_xchg elsewhere. That's the rule, iykyk.

⚠️ for real though: noinstr gets the raw one; everywhere else, prefer atomic64_xchg. The manpage said it, I'm just relaying it with glitter πŸ’–

πŸ’– RETURN πŸ’–

The original value of v. Like, it hands you back what was there before the swap β€” the OG value. Obsessed. 🫢


🌈 SEE ALSO 🌈

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

🌱 raw_atomic crew

πŸ¦‹ raw_atomic64 crew

byeee 🫢 this page is from ./include/linux/atomic, stamped October 2026, and it's literally raw_atomic64_xchg(9) β€” mwah πŸ’‹

πŸ“¦ where this page comes from