diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-02 16:38:43 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-03-02 16:38:43 +0000 |
commit | cbb6491d76c7aa81cdf5d3b3a81386129c5e2fce (patch) | |
tree | efa0c55763b34cbc633bc494c2743d1b5d9aaff3 /libgo/runtime/go-signal.c | |
parent | ff2f581b00ac6759f6366c16ef902c935163aa13 (diff) | |
download | gcc-cbb6491d76c7aa81cdf5d3b3a81386129c5e2fce.zip gcc-cbb6491d76c7aa81cdf5d3b3a81386129c5e2fce.tar.gz gcc-cbb6491d76c7aa81cdf5d3b3a81386129c5e2fce.tar.bz2 |
libgo: Update to weekly.2012-02-14 release.
From-SVN: r184798
Diffstat (limited to 'libgo/runtime/go-signal.c')
-rw-r--r-- | libgo/runtime/go-signal.c | 216 |
1 files changed, 78 insertions, 138 deletions
diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c index fd48f4b..b698ae2 100644 --- a/libgo/runtime/go-signal.c +++ b/libgo/runtime/go-signal.c @@ -25,11 +25,11 @@ extern void __splitstack_setcontext(void *context[10]); #endif -#define C SigCatch -#define I SigIgnore -#define R SigRestart -#define Q SigQueue +#define N SigNotify +#define K SigKill +#define T SigThrow #define P SigPanic +#define D SigDefault /* Signal actions. This collects the sigtab tables for several different targets from the master library. SIGKILL, SIGCONT, and @@ -38,105 +38,105 @@ extern void __splitstack_setcontext(void *context[10]); SigTab runtime_sigtab[] = { #ifdef SIGHUP - { SIGHUP, Q + R }, + { SIGHUP, N + K }, #endif #ifdef SIGINT - { SIGINT, Q + R }, + { SIGINT, N + K }, #endif #ifdef SIGQUIT - { SIGQUIT, C }, + { SIGQUIT, N + T }, #endif #ifdef SIGILL - { SIGILL, C }, + { SIGILL, T }, #endif #ifdef SIGTRAP - { SIGTRAP, C }, + { SIGTRAP, T }, #endif #ifdef SIGABRT - { SIGABRT, C }, + { SIGABRT, N + T }, #endif #ifdef SIGBUS - { SIGBUS, C + P }, + { SIGBUS, P }, #endif #ifdef SIGFPE - { SIGFPE, C + P }, + { SIGFPE, P }, #endif #ifdef SIGUSR1 - { SIGUSR1, Q + I + R }, + { SIGUSR1, N }, #endif #ifdef SIGSEGV - { SIGSEGV, C + P }, + { SIGSEGV, P }, #endif #ifdef SIGUSR2 - { SIGUSR2, Q + I + R }, + { SIGUSR2, N }, #endif #ifdef SIGPIPE - { SIGPIPE, I }, + { SIGPIPE, N }, #endif #ifdef SIGALRM - { SIGALRM, Q + I + R }, + { SIGALRM, N }, #endif #ifdef SIGTERM - { SIGTERM, Q + R }, + { SIGTERM, N + K }, #endif #ifdef SIGSTKFLT - { SIGSTKFLT, C }, + { SIGSTKFLT, T }, #endif #ifdef SIGCHLD - { SIGCHLD, Q + I + R }, + { SIGCHLD, N }, #endif #ifdef SIGTSTP - { SIGTSTP, Q + I + R }, + { SIGTSTP, N + D }, #endif #ifdef SIGTTIN - { SIGTTIN, Q + I + R }, + { SIGTTIN, N + D }, #endif #ifdef SIGTTOU - { SIGTTOU, Q + I + R }, + { SIGTTOU, N + D }, #endif #ifdef SIGURG - { SIGURG, Q + I + R }, + { SIGURG, N }, #endif #ifdef SIGXCPU - { SIGXCPU, Q + I + R }, + { SIGXCPU, N }, #endif #ifdef SIGXFSZ - { SIGXFSZ, Q + I + R }, + { SIGXFSZ, N }, #endif #ifdef SIGVTALRM - { SIGVTALRM, Q + I + R }, + { SIGVTALRM, N }, #endif #ifdef SIGPROF - { SIGPROF, Q + I + R }, + { SIGPROF, N }, #endif #ifdef SIGWINCH - { SIGWINCH, Q + I + R }, + { SIGWINCH, N }, #endif #ifdef SIGIO - { SIGIO, Q + I + R }, + { SIGIO, N }, #endif #ifdef SIGPWR - { SIGPWR, Q + I + R }, + { SIGPWR, N }, #endif #ifdef SIGSYS - { SIGSYS, C }, + { SIGSYS, N }, #endif #ifdef SIGEMT - { SIGEMT, C }, + { SIGEMT, T }, #endif #ifdef SIGINFO - { SIGINFO, Q + I + R }, + { SIGINFO, N }, #endif #ifdef SIGTHR - { SIGTHR, Q + I + R }, + { SIGTHR, N }, #endif { -1, 0 } }; -#undef C -#undef I -#undef R -#undef Q +#undef N +#undef K +#undef T #undef P +#undef D /* Handle a signal, for cases where we don't panic. We can split the stack here. */ @@ -158,21 +158,24 @@ sig_handler (int sig) for (i = 0; runtime_sigtab[i].sig != -1; ++i) { struct sigaction sa; + SigTab *t; - if (runtime_sigtab[i].sig != sig) + t = &runtime_sigtab[i]; + + if (t->sig != sig) continue; - if ((runtime_sigtab[i].flags & SigQueue) != 0) + if ((t->flags & SigNotify) != 0) { - if (__go_sigsend (sig) - || (runtime_sigtab[sig].flags & SigIgnore) != 0) + if (__go_sigsend (sig)) return; - runtime_exit (2); // SIGINT, SIGTERM, etc } - - if (runtime_panicking) + if ((t->flags & SigKill) != 0) runtime_exit (2); - runtime_panicking = 1; + if ((t->flags & SigThrow) == 0) + return; + + runtime_startpanic (); /* We should do a stack backtrace here. Until we can do that, we reraise the signal in order to get a slightly better @@ -227,7 +230,7 @@ static void sig_panic_info_handler (int sig, siginfo_t *info, void *context __attribute__ ((unused))) { - if (runtime_g () == NULL) + if (runtime_g () == NULL || info->si_code == SI_USER) { sig_handler (sig); return; @@ -316,16 +319,6 @@ sig_panic_handler (int sig) #endif /* !defined (SA_SIGINFO) */ -/* Ignore a signal. This is called on the alternate signal stack so - it may not split the stack. */ - -static void sig_ignore (int) __attribute__ ((no_split_stack)); - -static void -sig_ignore (int sig __attribute__ ((unused))) -{ -} - /* A signal handler used for signals which are not going to panic. This is called on the alternate signal stack so it may not split the stack. */ @@ -376,100 +369,41 @@ sig_tramp (int sig) } } -/* Initialize signal handling for Go. This is called when the program - starts. */ - void -runtime_initsig (int32 queue) +runtime_setsig (int32 i, bool def __attribute__ ((unused)), bool restart) { struct sigaction sa; - int i; - - siginit (); + int r; + SigTab *t; memset (&sa, 0, sizeof sa); - i = sigfillset (&sa.sa_mask); - __go_assert (i == 0); - - for (i = 0; runtime_sigtab[i].sig != -1; ++i) - { - if (runtime_sigtab[i].flags == 0) - continue; - if ((runtime_sigtab[i].flags & SigQueue) != queue) - continue; - - if ((runtime_sigtab[i].flags & (SigCatch | SigQueue)) != 0) - { - if ((runtime_sigtab[i].flags & SigPanic) == 0) - { - sa.sa_flags = SA_ONSTACK; - sa.sa_handler = sig_tramp; - } - else - { -#ifdef SA_SIGINFO - sa.sa_flags = SA_SIGINFO; - sa.sa_sigaction = sig_panic_info_handler; -#else - sa.sa_flags = 0; - sa.sa_handler = sig_panic_handler; -#endif - } - } - else - { - sa.sa_flags = SA_ONSTACK; - sa.sa_handler = sig_ignore; - } + r = sigfillset (&sa.sa_mask); + __go_assert (r == 0); - if ((runtime_sigtab[i].flags & SigRestart) != 0) - sa.sa_flags |= SA_RESTART; + t = &runtime_sigtab[i]; - if (sigaction (runtime_sigtab[i].sig, &sa, NULL) != 0) - __go_assert (0); - } -} - -void -runtime_resetcpuprofiler(int32 hz) -{ -#ifdef SIGPROF - struct itimerval it; - struct sigaction sa; - int i; - - memset (&it, 0, sizeof it); - - memset (&sa, 0, sizeof sa); - i = sigfillset (&sa.sa_mask); - __go_assert (i == 0); - - if (hz == 0) + if ((t->flags & SigPanic) == 0) { - i = setitimer (ITIMER_PROF, &it, NULL); - __go_assert (i == 0); - - sa.sa_handler = SIG_IGN; - i = sigaction (SIGPROF, &sa, NULL); - __go_assert (i == 0); + sa.sa_flags = SA_ONSTACK; + sa.sa_handler = sig_tramp; } else { - sa.sa_handler = sig_handler; - sa.sa_flags = SA_RESTART; - i = sigaction (SIGPROF, &sa, NULL); - __go_assert (i == 0); - - it.it_interval.tv_sec = 0; - it.it_interval.tv_usec = 1000000 / hz; - it.it_value = it.it_interval; - i = setitimer (ITIMER_PROF, &it, NULL); - __go_assert (i == 0); - } +#ifdef SA_SIGINFO + sa.sa_flags = SA_SIGINFO; + sa.sa_sigaction = sig_panic_info_handler; +#else + sa.sa_flags = 0; + sa.sa_handler = sig_panic_handler; #endif + } + + if (restart) + sa.sa_flags |= SA_RESTART; - runtime_m()->profilehz = hz; + if (sigaction (t->sig, &sa, NULL) != 0) + __go_assert (0); } /* Used by the os package to raise SIGPIPE. */ @@ -494,3 +428,9 @@ os_sigpipe (void) raise (SIGPIPE); } + +void +runtime_setprof(bool on) +{ + USED(on); +} |