Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add synchronization to xset.


Unfortunately, this is necessary to achieve sequential consistency.
---
 lib/thread/atomic-impl+plan9-x64.s | 8 ++++----
 lib/thread/atomic-impl+x64.s       | 6 +++---
 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 06224d27..b822bfda 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 3f282775..b19f4693 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
-- 
2.21.0


Follow-Ups:
Re: [PATCH] Add synchronization to xset.Ori Bernstein <ori@xxxxxxxxxxxxxx>