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

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

Issue 4306043: code review 4306043: runtime: cpu profiling support (Closed)
Left Patch Set: diff -r 5155293bbd79 https://go.googlecode.com/hg/ Created 13 years, 12 months ago
Right Patch Set: diff -r 777b478bba31 https://go.googlecode.com/hg Created 13 years, 12 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/linux/amd64/signal.c ('k') | src/pkg/runtime/plan9/386/signal.c » ('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 #include "defs.h" 6 #include "defs.h"
7 #include "signals.h" 7 #include "signals.h"
8 #include "os.h" 8 #include "os.h"
9 9
10 void 10 void
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 runtime·signalstack(byte *p, int32 n) 117 runtime·signalstack(byte *p, int32 n)
118 { 118 {
119 Sigaltstack st; 119 Sigaltstack st;
120 120
121 st.ss_sp = p; 121 st.ss_sp = p;
122 st.ss_size = n; 122 st.ss_size = n;
123 st.ss_flags = 0; 123 st.ss_flags = 0;
124 runtime·sigaltstack(&st, nil); 124 runtime·sigaltstack(&st, nil);
125 } 125 }
126 126
127 static void
128 sigaction(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart)
129 {
130 Sigaction sa;
131
132 runtime·memclr((byte*)&sa, sizeof sa);
133 sa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESTORER;
134 if(restart)
135 sa.sa_flags |= SA_RESTART;
136 sa.sa_mask = ~0ULL;
137 sa.sa_restorer = (void*)runtime·sigreturn;
138 sa.k_sa_handler = fn;
139 runtime·rt_sigaction(i, &sa, nil, 8);
140 }
141
127 void 142 void
128 runtime·initsig(int32 queue) 143 runtime·initsig(int32 queue)
129 { 144 {
130 int32 i; 145 int32 i;
131 » Sigaction sa; 146 » void *fn;
132 147
133 runtime·siginit(); 148 runtime·siginit();
134 149
135 runtime·memclr((byte*)&sa, sizeof sa);
136 sa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESTORER;
137 sa.sa_mask.sig[0] = 0xFFFFFFFF;
138 sa.sa_mask.sig[1] = 0xFFFFFFFF;
139 sa.sa_restorer = (void*)runtime·sigreturn;
140 for(i = 0; i<NSIG; i++) { 150 for(i = 0; i<NSIG; i++) {
141 if(runtime·sigtab[i].flags) { 151 if(runtime·sigtab[i].flags) {
142 if((runtime·sigtab[i].flags & SigQueue) != queue) 152 if((runtime·sigtab[i].flags & SigQueue) != queue)
143 continue; 153 continue;
144 if(runtime·sigtab[i].flags & (SigCatch | SigQueue)) 154 if(runtime·sigtab[i].flags & (SigCatch | SigQueue))
145 » » » » sa.sa_handler = (void*)runtime·sigtramp; 155 » » » » fn = runtime·sighandler;
146 else 156 else
147 » » » » sa.sa_handler = (void*)runtime·sigignore; 157 » » » » fn = runtime·sigignore;
148 » » » if(runtime·sigtab[i].flags & SigRestart) 158 » » » sigaction(i, fn, (runtime·sigtab[i].flags & SigRestart) != 0);
149 » » » » sa.sa_flags |= SA_RESTART;
150 » » » else
151 » » » » sa.sa_flags &= ~SA_RESTART;
152 » » » runtime·rt_sigaction(i, &sa, nil, 8);
153 } 159 }
154 } 160 }
155 } 161 }
156 162
157 void 163 void
158 runtime·resetcpuprofiler(int32 hz) 164 runtime·resetcpuprofiler(int32 hz)
159 { 165 {
160 Sigaction sa; 166 Sigaction sa;
161 Itimerval it; 167 Itimerval it;
162 ········ 168 ········
169 runtime·memclr((byte*)&it, sizeof it);
163 if(hz == 0) { 170 if(hz == 0) {
164 runtime·memclr((byte*)&it, sizeof it);
165 runtime·setitimer(ITIMER_PROF, &it, nil); 171 runtime·setitimer(ITIMER_PROF, &it, nil);
166 » } 172 » » sigaction(SIGPROF, SIG_IGN, true);
167 »······· 173 » } else {
168 » runtime·memclr((byte*)&sa, sizeof sa); 174 » » sigaction(SIGPROF, runtime·sighandler, true);
169 » sa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_RESTORER | SA_RESTART;
170 » sa.sa_mask = ~0ULL;
171 » sa.sa_restorer = (void*)runtime·sigreturn;
172 » if(hz > 0)
173 » » sa.sa_handler = (void*)runtime·sigtramp;
174 » else
175 » » sa.sa_handler = SIG_IGN;
176 » runtime·rt_sigaction(SIGPROF, &sa, nil, 8);
177 »·······
178 » if(hz > 0) {
179 it.it_interval.tv_sec = 0; 175 it.it_interval.tv_sec = 0;
180 it.it_interval.tv_usec = 1000000 / hz; 176 it.it_interval.tv_usec = 1000000 / hz;
181 it.it_value = it.it_interval; 177 it.it_value = it.it_interval;
182 runtime·setitimer(ITIMER_PROF, &it, nil); 178 runtime·setitimer(ITIMER_PROF, &it, nil);
183 } 179 }
184 ········
185 m->profilehz = hz; 180 m->profilehz = hz;
186 } 181 }
LEFTRIGHT

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