OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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_GOOS_GOARCH.h" | 6 #include "defs_GOOS_GOARCH.h" |
7 #include "os_GOOS.h" | 7 #include "os_GOOS.h" |
8 #include "signal_unix.h" | 8 #include "signal_unix.h" |
9 #include "stack.h" | 9 #include "stack.h" |
10 #include "../../cmd/ld/textflag.h" | 10 #include "../../cmd/ld/textflag.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 extern void runtime·sigtramp(void); | 234 extern void runtime·sigtramp(void); |
235 | 235 |
236 typedef struct sigaction { | 236 typedef struct sigaction { |
237 union { | 237 union { |
238 void (*__sa_handler)(int32); | 238 void (*__sa_handler)(int32); |
239 void (*__sa_sigaction)(int32, Siginfo*, void *); | 239 void (*__sa_sigaction)(int32, Siginfo*, void *); |
240 } __sigaction_u; /* signal handler */ | 240 } __sigaction_u; /* signal handler */ |
241 int32 sa_flags; /* see signal options below */ | 241 int32 sa_flags; /* see signal options below */ |
242 Sigset sa_mask; /* signal mask to apply */ | 242 Sigset sa_mask; /* signal mask to apply */ |
243 } Sigaction; | 243 } SigactionT; |
244 | 244 |
245 void | 245 void |
246 runtime·setsig(int32 i, GoSighandler *fn, bool restart) | 246 runtime·setsig(int32 i, GoSighandler *fn, bool restart) |
247 { | 247 { |
248 » Sigaction sa; | 248 » SigactionT sa; |
249 | 249 |
250 runtime·memclr((byte*)&sa, sizeof sa); | 250 runtime·memclr((byte*)&sa, sizeof sa); |
251 sa.sa_flags = SA_SIGINFO|SA_ONSTACK; | 251 sa.sa_flags = SA_SIGINFO|SA_ONSTACK; |
252 if(restart) | 252 if(restart) |
253 sa.sa_flags |= SA_RESTART; | 253 sa.sa_flags |= SA_RESTART; |
254 sa.sa_mask.__bits[0] = ~(uint32)0; | 254 sa.sa_mask.__bits[0] = ~(uint32)0; |
255 sa.sa_mask.__bits[1] = ~(uint32)0; | 255 sa.sa_mask.__bits[1] = ~(uint32)0; |
256 sa.sa_mask.__bits[2] = ~(uint32)0; | 256 sa.sa_mask.__bits[2] = ~(uint32)0; |
257 sa.sa_mask.__bits[3] = ~(uint32)0; | 257 sa.sa_mask.__bits[3] = ~(uint32)0; |
258 if(fn == runtime·sighandler) | 258 if(fn == runtime·sighandler) |
259 fn = (void*)runtime·sigtramp; | 259 fn = (void*)runtime·sigtramp; |
260 sa.__sigaction_u.__sa_sigaction = (void*)fn; | 260 sa.__sigaction_u.__sa_sigaction = (void*)fn; |
261 runtime·sigaction(i, &sa, nil); | 261 runtime·sigaction(i, &sa, nil); |
262 } | 262 } |
263 | 263 |
264 GoSighandler* | 264 GoSighandler* |
265 runtime·getsig(int32 i) | 265 runtime·getsig(int32 i) |
266 { | 266 { |
267 » Sigaction sa; | 267 » SigactionT sa; |
268 | 268 |
269 runtime·memclr((byte*)&sa, sizeof sa); | 269 runtime·memclr((byte*)&sa, sizeof sa); |
270 runtime·sigaction(i, nil, &sa); | 270 runtime·sigaction(i, nil, &sa); |
271 if((void*)sa.__sigaction_u.__sa_sigaction == runtime·sigtramp) | 271 if((void*)sa.__sigaction_u.__sa_sigaction == runtime·sigtramp) |
272 return runtime·sighandler; | 272 return runtime·sighandler; |
273 return (void*)sa.__sigaction_u.__sa_sigaction; | 273 return (void*)sa.__sigaction_u.__sa_sigaction; |
274 } | 274 } |
275 | 275 |
276 void | 276 void |
277 runtime·signalstack(byte *p, int32 n) | 277 runtime·signalstack(byte *p, int32 n) |
278 { | 278 { |
279 StackT st; | 279 StackT st; |
280 | 280 |
281 st.ss_sp = (void*)p; | 281 st.ss_sp = (void*)p; |
282 st.ss_size = n; | 282 st.ss_size = n; |
283 st.ss_flags = 0; | 283 st.ss_flags = 0; |
284 if(p == nil) | 284 if(p == nil) |
285 st.ss_flags = SS_DISABLE; | 285 st.ss_flags = SS_DISABLE; |
286 runtime·sigaltstack(&st, nil); | 286 runtime·sigaltstack(&st, nil); |
287 } | 287 } |
288 | 288 |
289 void | 289 void |
290 runtime·unblocksignals(void) | 290 runtime·unblocksignals(void) |
291 { | 291 { |
292 runtime·sigprocmask(&sigset_none, nil); | 292 runtime·sigprocmask(&sigset_none, nil); |
293 } | 293 } |
OLD | NEW |