]> Cypherpunks repositories - gostls13.git/commitdiff
add support for pre arm v6 cas. set GOARM=5 to enable.
authorKai Backman <kaib@golang.org>
Thu, 12 Nov 2009 23:23:23 +0000 (15:23 -0800)
committerKai Backman <kaib@golang.org>
Thu, 12 Nov 2009 23:23:23 +0000 (15:23 -0800)
R=rsc
https://golang.org/cl/154101

src/pkg/runtime/Makefile
src/pkg/runtime/arm/cas5.s [new file with mode: 0644]
src/pkg/runtime/arm/cas6.s [moved from src/pkg/runtime/arm/cas.s with 100% similarity]

index f66d4c2a58a3aa4cd1a8c2c2dabb6482f10c13f6..e31073cf2714473346d2d4cc6e2d225733c28e35 100644 (file)
@@ -28,9 +28,11 @@ OFILES_386=\
        vlop.$O\
        vlrt.$O\
 
+GOARM ?= 6
+
 # arm-specific object files
 OFILES_arm=\
-       cas.$O\
+       cas$(GOARM).$O\
        memset.$O\
        vlop.$O\
        vlrt.$O\
diff --git a/src/pkg/runtime/arm/cas5.s b/src/pkg/runtime/arm/cas5.s
new file mode 100644 (file)
index 0000000..8a4c8be
--- /dev/null
@@ -0,0 +1,43 @@
+// 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.
+
+#include "arm/asm.h"
+
+// This version works on pre v6 architectures
+
+// bool cas(int32 *val, int32 old, int32 new)
+// Atomically:
+//     if(*val == old){
+//             *val = new;
+//             return 1;
+//     }else
+//             return 0;
+
+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
+       RET
+fail1: 
+       MOVW    R3, (R4)        // release mutex
+fail0:
+       MOVW    $0, R0
+       RET
+DATA cas_mutex(SB)/4, $0
+GLOBL cas_mutex(SB), $4