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

Delta Between Two Patch Sets: src/pkg/runtime/arm/atomic.c

Issue 4817058: code review 4817058: runtime: fix data race in findfunc() (Closed)
Left Patch Set: diff -r c0e0030f5308 https://go.googlecode.com/hg/ Created 13 years, 7 months ago
Right Patch Set: diff -r 9c32561a8704 https://go.googlecode.com/hg/ Created 13 years, 7 months 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/amd64/asm.s ('k') | src/pkg/runtime/runtime.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "runtime.h" 5 #include "runtime.h"
6 6
7 // Atomic add and return new value. 7 // Atomic add and return new value.
8 #pragma textflag 7 8 #pragma textflag 7
9 uint32 9 uint32
10 runtime·xadd(uint32 volatile *val, int32 delta) 10 runtime·xadd(uint32 volatile *val, int32 delta)
11 { 11 {
12 uint32 oval, nval; 12 uint32 oval, nval;
13 13
14 for(;;){ 14 for(;;){
15 oval = *val; 15 oval = *val;
16 nval = oval + delta; 16 nval = oval + delta;
17 if(runtime·cas(val, oval, nval)) 17 if(runtime·cas(val, oval, nval))
18 return nval; 18 return nval;
19 }
20 }
21
22 #pragma textflag 7
23 uint32
24 runtime·xchg(uint32 volatile* addr, uint32 v)
25 {
26 uint32 old;
27
28 for(;;) {
29 old = *addr;
30 if(runtime·cas(addr, old, v))
31 return old;
32 }
33 }
34
35 #pragma textflag 7
36 void
37 runtime·procyield(uint32 cnt)
38 {
39 uint32 volatile i;
40
41 for(i = 0; i < cnt; i++) {
19 } 42 }
20 } 43 }
21 44
22 #pragma textflag 7 45 #pragma textflag 7
23 uint32 46 uint32
24 runtime·atomicload(uint32 volatile* addr) 47 runtime·atomicload(uint32 volatile* addr)
25 { 48 {
26 return runtime·xadd(addr, 0); 49 return runtime·xadd(addr, 0);
27 } 50 }
28 51
(...skipping 22 matching lines...) Expand all
51 runtime·atomicstore(uint32 volatile* addr, uint32 v) 74 runtime·atomicstore(uint32 volatile* addr, uint32 v)
52 { 75 {
53 uint32 old; 76 uint32 old;
54 ········ 77 ········
55 for(;;) { 78 for(;;) {
56 old = *addr; 79 old = *addr;
57 if(runtime·cas(addr, old, v)) 80 if(runtime·cas(addr, old, v))
58 return; 81 return;
59 } 82 }
60 } 83 }
LEFTRIGHT

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