mirror of
https://github.com/golang/go
synced 2024-11-25 04:57:56 -07:00
sync: allow to work on armv5
asm_arm.s was using ldrex which does not work on armv5. Tested on Sheevaplug. R=rsc, kaib CC=golang-dev https://golang.org/cl/214049
This commit is contained in:
parent
713e3e1541
commit
86b0ea6447
@ -9,7 +9,21 @@ GOFILES=\
|
||||
mutex.go\
|
||||
rwmutex.go\
|
||||
|
||||
# 386-specific object files
|
||||
OFILES_386=\
|
||||
asm_386.$O\
|
||||
|
||||
# amd64-specific object files
|
||||
OFILES_amd64=\
|
||||
asm_amd64.$O\
|
||||
|
||||
GOARM?=6
|
||||
|
||||
# arm-specific object files
|
||||
OFILES_arm=\
|
||||
asm_arm$(GOARM).$O\
|
||||
|
||||
OFILES=\
|
||||
asm_$(GOARCH).$O\
|
||||
$(OFILES_$(GOARCH))\
|
||||
|
||||
include ../../Make.pkg
|
||||
|
40
src/pkg/sync/asm_arm5.s
Normal file
40
src/pkg/sync/asm_arm5.s
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2009 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.
|
||||
|
||||
// This version works on pre v6 architectures
|
||||
// func cas(val *int32, old, new int32) bool
|
||||
// Atomically:
|
||||
// if *val == old {
|
||||
// *val = new;
|
||||
// return true;
|
||||
// }else
|
||||
// return false;
|
||||
|
||||
TEXT ·cas(SB),7,$0
|
||||
MOVW 0(FP), R0 // *val
|
||||
MOVW 4(FP), R1 // old
|
||||
MOVW 8(FP), R2 // new
|
||||
MOVW $1, R3
|
||||
MOVW $cas_mutex(SB), R4
|
||||
l:
|
||||
SWPW (R4), R3 // acquire mutex
|
||||
CMP $0, R3
|
||||
BNE fail0
|
||||
|
||||
MOVW (R0), R5
|
||||
CMP R1, R5
|
||||
BNE fail1
|
||||
|
||||
MOVW R2, (R0)
|
||||
MOVW R3, (R4) // release mutex
|
||||
MOVW $1, R0
|
||||
MOVW R0, 16(SP)
|
||||
RET
|
||||
fail1:
|
||||
MOVW R3, (R4) // release mutex
|
||||
fail0:
|
||||
MOVW $0, R0
|
||||
MOVW R0, 16(SP)
|
||||
RET
|
||||
|
Loading…
Reference in New Issue
Block a user