Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(399)

Delta Between Two Patch Sets: src/pkg/runtime/arm/cas5.s

Issue 4245043: code review 4245043: runtime: use kernel-supplied cas on linux/arm (Closed)
Left Patch Set: Created 14 years ago
Right Patch Set: diff -r 51e1539c025c https://go.googlecode.com/hg Created 14 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/arm/asm.s ('k') | src/pkg/runtime/arm/cas6.s » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 #include "arm/asm.h"
6
7 // This version works on pre v6 architectures
8
9 // bool cas(int32 *val, int32 old, int32 new)
10 // Atomically:
11 // if(*val == old){
12 // *val = new;
13 // return 1;
14 // }else
15 // return 0;
16
17 TEXT runtime·cas(SB),7,$0
18 MOVW 0(FP), R0 // *val
19 MOVW 4(FP), R1 // old
20 MOVW 8(FP), R2 // new
21 MOVW $1, R3
22 MOVW $runtime·cas_mutex(SB), R4
23 SWPW (R4), R3 // acquire mutex
24 CMP $0, R3
25 BNE fail0
26 ········
27 MOVW (R0), R5
28 CMP R1, R5
29 BNE fail1
30 ········
31 MOVW R2, (R0)········
32 MOVW R3, (R4) // release mutex
33 MOVW $1, R0
34 RET
35 fail1:··
36 MOVW R3, (R4) // release mutex
37 fail0:
38 MOVW $0, R0
39 RET
40
41 // bool casp(void **p, void *old, void *new)
42 // Atomically:
43 // if(*p == old){
44 // *p = new;
45 // return 1;
46 // }else
47 // return 0;
48
49 TEXT runtime·casp(SB),7,$0
50 MOVW 0(FP), R0 // *p
51 MOVW 4(FP), R1 // old
52 MOVW 8(FP), R2 // new
53 MOVW $1, R3
54 MOVW $runtime·cas_mutex(SB), R4
55 SWPW (R4), R3 // acquire mutex
56 CMP $0, R3
57 BNE failp0
58 ········
59 MOVW (R0), R5
60 CMP R1, R5
61 BNE failp1
62 ········
63 MOVW R2, (R0)········
64 MOVW R3, (R4) // release mutex
65 MOVW $1, R0
66 RET
67 failp1:·
68 MOVW R3, (R4) // release mutex
69 failp0:
70 MOVW $0, R0
71 RET
72
73 DATA runtime·cas_mutex(SB)/4, $0
74 GLOBL runtime·cas_mutex(SB), $4
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b