From cc57fc042ce65cb7fe2b13fcc74992eb95b52958 Mon Sep 17 00:00:00 2001 From: Dean Prichard Date: Thu, 18 Feb 2010 15:37:16 -0800 Subject: 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 http://codereview.appspot.com/214049 Committer: Kai Backman --- src/pkg/sync/Makefile | 16 +++++++++++++++- src/pkg/sync/asm_arm.s | 30 ------------------------------ src/pkg/sync/asm_arm5.s | 40 ++++++++++++++++++++++++++++++++++++++++ src/pkg/sync/asm_arm6.s | 30 ++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 31 deletions(-) delete mode 100644 src/pkg/sync/asm_arm.s create mode 100644 src/pkg/sync/asm_arm5.s create mode 100644 src/pkg/sync/asm_arm6.s (limited to 'src') diff --git a/src/pkg/sync/Makefile b/src/pkg/sync/Makefile index 25d11d03d..4b9a05816 100644 --- a/src/pkg/sync/Makefile +++ b/src/pkg/sync/Makefile @@ -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 diff --git a/src/pkg/sync/asm_arm.s b/src/pkg/sync/asm_arm.s deleted file mode 100644 index d1e0851d0..000000000 --- a/src/pkg/sync/asm_arm.s +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -// 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), R1 // *val - MOVW 4(FP), R2 // old - MOVW 8(FP), R3 // new -l: - LDREX (R1), R0 - CMP R0, R2 - BNE fail - STREX R3, (R1), R0 - CMP $0, R0 - BNE l - MOVW $1, R0 - MOVW R0, 16(SP) - RET -fail: - MOVW $0, R0 - MOVW R0, 16(SP) - RET diff --git a/src/pkg/sync/asm_arm5.s b/src/pkg/sync/asm_arm5.s new file mode 100644 index 000000000..3cdca0b87 --- /dev/null +++ b/src/pkg/sync/asm_arm5.s @@ -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 + diff --git a/src/pkg/sync/asm_arm6.s b/src/pkg/sync/asm_arm6.s new file mode 100644 index 000000000..d1e0851d0 --- /dev/null +++ b/src/pkg/sync/asm_arm6.s @@ -0,0 +1,30 @@ +// 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. + +// 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), R1 // *val + MOVW 4(FP), R2 // old + MOVW 8(FP), R3 // new +l: + LDREX (R1), R0 + CMP R0, R2 + BNE fail + STREX R3, (R1), R0 + CMP $0, R0 + BNE l + MOVW $1, R0 + MOVW R0, 16(SP) + RET +fail: + MOVW $0, R0 + MOVW R0, 16(SP) + RET -- cgit v1.2.3