]> Cypherpunks repositories - gostls13.git/commitdiff
sync/atomic: fix new swap on arm linux
authorRuss Cox <rsc@golang.org>
Wed, 14 Aug 2013 04:50:47 +0000 (00:50 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 14 Aug 2013 04:50:47 +0000 (00:50 -0400)
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12920043

src/pkg/sync/atomic/64bit_arm.go
src/pkg/sync/atomic/asm_linux_arm.s

index 7d280ffd22e869895e247fc0cd15185d5ba51201..c08f214c7ef7b03507115264d29be757dd794fb2 100644 (file)
@@ -37,7 +37,7 @@ func addUint64(val *uint64, delta uint64) (new uint64) {
 
 func swapUint64(addr *uint64, new uint64) (old uint64) {
        for {
-               old := *addr
+               old = *addr
                if CompareAndSwapUint64(addr, old, new) {
                        break
                }
index 3d1edfe0bf3fb3614beaecfcde3991ab0c49e574..8a65ed9c940323d5466b822cce1ded24bc289b63 100644 (file)
@@ -88,9 +88,10 @@ TEXT ·SwapUint32(SB),NOSPLIT,$0-12
        MOVW    new+4(FP), R1
 swaploop1:
        MOVW    0(R2), R0
+       MOVW    R0, R4 // cas smashes R0
        BL      cas<>(SB)
        BCC     swaploop1
-       MOVW    R0, old+8(FP)
+       MOVW    R4, old+8(FP)
        RET
 
 TEXT ·SwapUintptr(SB),NOSPLIT,$0