From 7b15ed9ef455b6b66c6b376898a88aef5d6a9970 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Tue, 26 Apr 2011 09:55:32 +0200 Subject: Imported Upstream version 2011.04.13 --- src/pkg/runtime/darwin/386/signal.c | 57 ++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 13 deletions(-) (limited to 'src/pkg/runtime/darwin/386/signal.c') diff --git a/src/pkg/runtime/darwin/386/signal.c b/src/pkg/runtime/darwin/386/signal.c index aeef5de3f..35bbb178b 100644 --- a/src/pkg/runtime/darwin/386/signal.c +++ b/src/pkg/runtime/darwin/386/signal.c @@ -46,6 +46,11 @@ runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp) mc = uc->uc_mcontext; r = &mc->ss; + if(sig == SIGPROF) { + runtime·sigprof((uint8*)r->eip, (uint8*)r->esp, nil, gp); + return; + } + if(gp != nil && (runtime·sigtab[sig].flags & SigPanic)) { // Work around Leopard bug that doesn't set FPE_INTDIV. // Look at instruction to see if it is a divide. @@ -126,31 +131,57 @@ runtime·signalstack(byte *p, int32 n) runtime·sigaltstack(&st, nil); } +static void +sigaction(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart) +{ + Sigaction sa; + + runtime·memclr((byte*)&sa, sizeof sa); + sa.sa_flags = SA_SIGINFO|SA_ONSTACK; + if(restart) + sa.sa_flags |= SA_RESTART; + sa.sa_mask = ~0U; + sa.sa_tramp = (uintptr)runtime·sigtramp; // runtime·sigtramp's job is to call into real handler + sa.__sigaction_u.__sa_sigaction = (uintptr)fn; + runtime·sigaction(i, &sa, nil); +} + void runtime·initsig(int32 queue) { int32 i; - static Sigaction sa; + void *fn; runtime·siginit(); - sa.sa_flags |= SA_SIGINFO|SA_ONSTACK; - sa.sa_mask = 0xFFFFFFFFU; - sa.sa_tramp = runtime·sigtramp; // runtime·sigtramp's job is to call into real handler for(i = 0; iprofilehz = hz; +} -- cgit v1.2.3