Atomic Fetch and Add

Atomically add to a memory location and return its previous value.

Atomics

Semantics

atomically: old = *addr; *addr = old + v; return old.

Architecture Instructions Expressed as How this architecture does it
x86 one instruction LOCK XADD returns the previous value in the source register, which is what makes it a fetch-and-add rather than a plain atomic add.
ARM one instruction FEAT_LSE atomic instruction; it can execute near memory rather than pulling the line exclusively to the core, which scales better under contention.
RISC-V one instruction A extension AMO. The acquire and release bits are encoded in the instruction itself rather than requiring separate fences.
PowerISA an idiom Built from the same reservation loop as compare-and-swap: there is no dedicated fetch-and-add instruction.