--- /sys/src/libc/arm/atom.s Sun May 29 14:16:19 2016 +++ /sys/src/libc/arm/atom.s Tue Jan 11 17:24:19 2022 @@ -31,6 +31,7 @@ TEXT _xinc(SB), $0 /* void _xinc(long *); */ TEXT ainc(SB), $0 /* long ainc(long *); */ + DMB spinainc: LDREX(0,3) /* LDREX 0(R0),R3 */ ADD $1,R3 @@ -44,6 +45,7 @@ TEXT _xdec(SB), $0 /* long _xdec(long *); */ TEXT adec(SB), $0 /* long adec(long *); */ + DMB spinadec: LDREX(0,3) /* LDREX 0(R0),R3 */ SUB $1,R3 --- /sys/man/2/ainc Mon Jun 7 20:16:50 2021 +++ /sys/man/2/ainc Tue Jan 11 19:02:26 2022 @@ -41,6 +41,13 @@ increment and decrement (respectively) the integer pointed to by .IR p , and return the resulting value after the operation. +On architectures with a weak memory model, both operations +are implemented with a barrier to memory reordering. +In other words, all loads and stores +which precede the increment / decrement in program order +will be observed before it, +and the increment / decrement will be observed before any loads +and stores which follow it in program order. .PP .I Cas performs a compare and swap on the word pointed to by