atomic_long_xchg_acquire(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

atomic_long_xchg_acquire β€” bestie, it's an atomic exchange, and it comes with acquire ordering πŸ’…

Okay so real quick, this is a page from the Kernel API Manual, and the star of the show is atomic_long_xchg_acquire. It swaps a long in atomically, and the ordering vibes are acquire. That's the whole personality. Slay.


✨ SYNOPSIS ✨

long atomic_long_xchg_acquire (atomic_long_t *v , long new );

Like yes, that's literally it. Two arguments, one long coming back at you 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” pointer to atomic_long_t. It's giving "where the value lives" energy.
  • new β€” the long value to assign. This is the new main character of *v.

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea: it atomically updates v to new, and it does it with acquire ordering. Atomic ✨ ordering ✨ both, no cap.

🚨 Real talk though: it's unsafe to use in noinstr code. If you're in there, use raw_atomic_long_xchg_acquire instead. Not a suggestion, it's the rule, iykyk πŸ’€

🌸 RETURN 🌸

It returns the original value of v β€” i.e. what was chilling in there before you swapped it. The way that it hands you the old value and the new one is already in place… iconic behavior honestly πŸ‘‘


πŸ’œ SEE ALSO πŸ’œ

Kernel file: ./include/linux/atomic/atomic-instrumented.h β€” that's where the lore lives πŸ“–

And now the friend group. Genuinely huge roster, but every single one of them is here because we don't do left-outs in this house 🫢

The atomic_* girlies:

The atomic64_* girlies:

The atomic_long_* girlies (our homegirl's family πŸ₯Ή):


That's the whole page bestie, no notes, go forth and exchange atomically πŸ’œ Source file is ./include/linux/atomic, and this cutie is dated October 2026 β€” catch you in the next atomic_long_xchg_acquire(9) era πŸ¦‹βœ¨

πŸ“¦ where this page comes from