summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/atomic_386.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/atomic_386.c')
-rw-r--r--src/pkg/runtime/atomic_386.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/pkg/runtime/atomic_386.c b/src/pkg/runtime/atomic_386.c
index 79b7cbf96..1046eb81e 100644
--- a/src/pkg/runtime/atomic_386.c
+++ b/src/pkg/runtime/atomic_386.c
@@ -30,3 +30,16 @@ runtime·xadd64(uint64 volatile* addr, int64 v)
}
return old+v;
}
+
+#pragma textflag 7
+uint64
+runtime·xchg64(uint64 volatile* addr, uint64 v)
+{
+ uint64 old;
+
+ old = *addr;
+ while(!runtime·cas64(addr, &old, v)) {
+ // nothing
+ }
+ return old;
+}