@atomicRmw
@atomicRmw
@atomicRmw(comptime T: type, ptr: *T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T
This builtin function atomically modifies memory and then returns the previous value.
T must be a pointer type, a bool, or an integer whose bit count meets these requirements:
- At least 8
- At most the same as usize
- Power of 2
TODO right now bool is not accepted. Also I think we could make non powers of 2 work fine, maybe we can remove this restriction
Supported operations:
.Xchg- stores the operand unmodified..Add- for integers, twos complement wraparound addition. Also supports Floats..Sub- for integers, twos complement wraparound subtraction. Also supports Floats..And- bitwise and.Nand- bitwise nand.Or- bitwise or.Xor- bitwise xor.Max- stores the operand if it is larger. Supports integers and floats..Min- stores the operand if it is smaller. Supports integers and floats.
