1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:14:46 -07:00

sync/atomic: use cas64 to implement {Load,Store,Add}{Uint,Int}64 on Linux/ARM

Now with GOARM=5 our all.bash should pass on ARMv5 systems.
        Fixes #3331.

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/6210071
This commit is contained in:
Shenghou Ma 2012-05-23 02:02:01 +08:00
parent fb3a1b6821
commit 090f9fc3ef
2 changed files with 46 additions and 10 deletions

View File

@ -0,0 +1,36 @@
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package atomic
func loadUint64(addr *uint64) (val uint64) {
for {
val = *addr
if CompareAndSwapUint64(addr, val, val) {
break
}
}
return
}
func storeUint64(addr *uint64, val uint64) {
for {
old := *addr
if CompareAndSwapUint64(addr, old, val) {
break
}
}
return
}
func addUint64(val *uint64, delta uint64) (new uint64) {
for {
old := *val
new = old + delta
if CompareAndSwapUint64(val, old, new) {
break
}
}
return
}

View File

@ -121,20 +121,20 @@ TEXT setupAndCallCAS64<>(SB),7,$-4
MOVW R1, armCAS64(SB) MOVW R1, armCAS64(SB)
MOVW R1, PC MOVW R1, PC
TEXT ·CompareAndSwapInt64(SB),7,$-4 TEXT ·CompareAndSwapInt64(SB),7,$0
B ·CompareAndSwapUint64(SB)
TEXT ·CompareAndSwapUint64(SB),7,$-4
MOVW armCAS64(SB), R0 MOVW armCAS64(SB), R0
CMP $0, R0 CMP $0, R0
MOVW.NE R0, PC MOVW.NE R0, PC
B setupAndCallCAS64<>(SB) B setupAndCallCAS64<>(SB)
TEXT ·CompareAndSwapUint64(SB),7,$0
B ·CompareAndSwapInt64(SB)
TEXT ·AddInt64(SB),7,$0 TEXT ·AddInt64(SB),7,$0
B ·armAddUint64(SB) B ·addUint64(SB)
TEXT ·AddUint64(SB),7,$0 TEXT ·AddUint64(SB),7,$0
B ·armAddUint64(SB) B ·addUint64(SB)
TEXT ·LoadInt32(SB),7,$0 TEXT ·LoadInt32(SB),7,$0
B ·LoadUint32(SB) B ·LoadUint32(SB)
@ -150,10 +150,10 @@ loadloop1:
RET RET
TEXT ·LoadInt64(SB),7,$0 TEXT ·LoadInt64(SB),7,$0
B ·armLoadUint64(SB) B ·loadUint64(SB)
TEXT ·LoadUint64(SB),7,$0 TEXT ·LoadUint64(SB),7,$0
B ·armLoadUint64(SB) B ·loadUint64(SB)
TEXT ·LoadUintptr(SB),7,$0 TEXT ·LoadUintptr(SB),7,$0
B ·LoadUint32(SB) B ·LoadUint32(SB)
@ -174,10 +174,10 @@ storeloop1:
RET RET
TEXT ·StoreInt64(SB),7,$0 TEXT ·StoreInt64(SB),7,$0
B ·armStoreUint64(SB) B ·storeUint64(SB)
TEXT ·StoreUint64(SB),7,$0 TEXT ·StoreUint64(SB),7,$0
B ·armStoreUint64(SB) B ·storeUint64(SB)
TEXT ·StoreUintptr(SB),7,$0 TEXT ·StoreUintptr(SB),7,$0
B ·StoreUint32(SB) B ·StoreUint32(SB)