--- /dev/null Sun Jun 21 11:00:58 2026 +++ /sys/src/libc/sparc/atom.c Sun Jun 21 00:00:00 2026 @@ -0,0 +1,110 @@ +#include +#include + +static int atomlock; + +static void +taslock(void) +{ + while(_tas(&atomlock)) + ; +} + +static void +tasunlock(void) +{ + atomlock = 0; +} + +long +ainc(long *p) +{ + long v; + + taslock(); + v = (*p += 1); + tasunlock(); + return v; +} + +long +adec(long *p) +{ + long v; + + taslock(); + v = (*p -= 1); + tasunlock(); + return v; +} + +void +_xinc(long *p) +{ + taslock(); + *p += 1; + tasunlock(); +} + +long +_xdec(long *p) +{ + long v; + + taslock(); + v = (*p -= 1); + tasunlock(); + return v; +} + +int +cas(int *p, int ov, int nv) +{ + int r; + + taslock(); + r = *p == ov; + if(r) + *p = nv; + tasunlock(); + return r; +} + +int +cas32(u32int *p, u32int ov, u32int nv) +{ + int r; + + taslock(); + r = *p == ov; + if(r) + *p = nv; + tasunlock(); + return r; +} + +int +casp(void **p, void *ov, void *nv) +{ + int r; + + taslock(); + r = *p == ov; + if(r) + *p = nv; + tasunlock(); + return r; +} + +int +casl(ulong *p, ulong ov, ulong nv) +{ + int r; + + taslock(); + r = *p == ov; + if(r) + *p = nv; + tasunlock(); + return r; +} --- /n/sources/plan9/sys/src/libc/sparc/mkfile Sun Nov 20 06:00:06 2005 +++ /sys/src/libc/sparc/mkfile Sun Jun 21 00:00:00 2026 @@ -22,6 +22,7 @@ vlop.s CFILES=\ + atom.c\ cycles.c\ notejmp.c\ sqrt.c\