1
0
mirror of https://github.com/golang/go synced 2024-11-27 03:11:19 -07:00

runtime/internal/atomic: add memory barrier for mips Cas on failure

Add a memory barrier on the failure case of the
compare-and-swap for mips, this avoids potential
race conditions.

For #63506
This commit is contained in:
Mauri de Souza Meneguzzo 2023-10-17 19:43:21 -03:00
parent ab2e3ce77c
commit 2101b9fd44
2 changed files with 2 additions and 6 deletions

View File

@ -48,11 +48,6 @@ func unlock() {
spinUnlock(&lock.state)
}
//go:nosplit
func unlockNoFence() {
lock.state = 0
}
//go:nosplit
func Xadd64(addr *uint64, delta int64) (new uint64) {
lockAndCheck(addr)
@ -85,7 +80,7 @@ func Cas64(addr *uint64, old, new uint64) (swapped bool) {
return true
}
unlockNoFence()
unlock()
return false
}

View File

@ -28,6 +28,7 @@ try_cas:
MOVB R3, ret+12(FP)
RET
cas_fail:
SYNC
MOVB R0, ret+12(FP)
RET