mirror of
https://github.com/golang/go
synced 2024-11-20 00:04:43 -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:
parent
fb3a1b6821
commit
090f9fc3ef
36
src/pkg/sync/atomic/64bit_linux_arm.go
Normal file
36
src/pkg/sync/atomic/64bit_linux_arm.go
Normal 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
|
||||
}
|
@ -121,20 +121,20 @@ TEXT setupAndCallCAS64<>(SB),7,$-4
|
||||
MOVW R1, armCAS64(SB)
|
||||
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
|
||||
CMP $0, R0
|
||||
MOVW.NE R0, PC
|
||||
B setupAndCallCAS64<>(SB)
|
||||
|
||||
TEXT ·CompareAndSwapUint64(SB),7,$0
|
||||
B ·CompareAndSwapInt64(SB)
|
||||
|
||||
TEXT ·AddInt64(SB),7,$0
|
||||
B ·armAddUint64(SB)
|
||||
B ·addUint64(SB)
|
||||
|
||||
TEXT ·AddUint64(SB),7,$0
|
||||
B ·armAddUint64(SB)
|
||||
B ·addUint64(SB)
|
||||
|
||||
TEXT ·LoadInt32(SB),7,$0
|
||||
B ·LoadUint32(SB)
|
||||
@ -150,10 +150,10 @@ loadloop1:
|
||||
RET
|
||||
|
||||
TEXT ·LoadInt64(SB),7,$0
|
||||
B ·armLoadUint64(SB)
|
||||
B ·loadUint64(SB)
|
||||
|
||||
TEXT ·LoadUint64(SB),7,$0
|
||||
B ·armLoadUint64(SB)
|
||||
B ·loadUint64(SB)
|
||||
|
||||
TEXT ·LoadUintptr(SB),7,$0
|
||||
B ·LoadUint32(SB)
|
||||
@ -174,10 +174,10 @@ storeloop1:
|
||||
RET
|
||||
|
||||
TEXT ·StoreInt64(SB),7,$0
|
||||
B ·armStoreUint64(SB)
|
||||
B ·storeUint64(SB)
|
||||
|
||||
TEXT ·StoreUint64(SB),7,$0
|
||||
B ·armStoreUint64(SB)
|
||||
B ·storeUint64(SB)
|
||||
|
||||
TEXT ·StoreUintptr(SB),7,$0
|
||||
B ·StoreUint32(SB)
|
||||
|
Loading…
Reference in New Issue
Block a user