summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoririri <iri@konnichiwastevenspielbergde.su>2019-03-16 20:05:12 -0700
committerOri Bernstein <ori@eigenstate.org>2019-03-16 20:12:01 -0700
commit5197866beb5ead9160183b6ada7a76244686f9f8 (patch)
tree02af6fc537b78b63370b929bc2f835cfe297887f /lib
parenta4fdef8a867263627510ea20e9b4a758549f7c98 (diff)
downloadmc-5197866beb5ead9160183b6ada7a76244686f9f8.tar.gz
Add synchronization to xset.
Unfortunately, this is necessary to achieve sequential consistency.
Diffstat (limited to 'lib')
-rw-r--r--lib/thread/atomic-impl+plan9-x64.s8
-rw-r--r--lib/thread/atomic-impl+x64.s6
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/thread/atomic-impl+plan9-x64.s b/lib/thread/atomic-impl+plan9-x64.s
index 06224d2..b822bfd 100644
--- a/lib/thread/atomic-impl+plan9-x64.s
+++ b/lib/thread/atomic-impl+plan9-x64.s
@@ -14,16 +14,16 @@ TEXT thread$xgetp+0(SB),1,$0
// set variants
TEXT thread$xset8+0(SB),1,$0
- MOVB SI, (DI)
+ LOCK; XCHGB (DI), SI
RET
TEXT thread$xset32+0(SB),1,$0
- MOVL SI, (DI)
+ LOCK; XCHGL (DI), SI
RET
TEXT thread$xset64+0(SB),1,$0
- MOVQ SI, (DI)
+ LOCK; XCHGQ (DI), SI
RET
TEXT thread$xsetp+0(SB),1,$0
- MOVQ SI, (DI)
+ LOCK; XCHGQ (DI), SI
RET
// add variants
diff --git a/lib/thread/atomic-impl+x64.s b/lib/thread/atomic-impl+x64.s
index 3f28277..b19f469 100644
--- a/lib/thread/atomic-impl+x64.s
+++ b/lib/thread/atomic-impl+x64.s
@@ -27,13 +27,13 @@ _thread$xgetp:
.globl _thread$xset8
thread$xset8:
_thread$xset8:
- movl %esi, (%rdi)
+ lock xchgb (%rdi), %sil
ret
.globl thread$xset32
.globl _thread$xset32
thread$xset32:
_thread$xset32:
- movl %esi, (%rdi)
+ lock xchgl (%rdi), %esi
ret
.globl thread$xset64
.globl thread$xsetp
@@ -43,7 +43,7 @@ thread$xset64:
thread$xsetp:
_thread$xset64:
_thread$xsetp:
- movq %rsi, (%rdi)
+ lock xchgq (%rdi), %rsi
ret
# add variants