uml: eliminate SIGALRM
[safe/jmp/linux-2.6] / arch / um / os-Linux / skas / trap.c
1 /*
2  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5
6 #if 0
7 #include "kern_util.h"
8 #include "skas.h"
9 #include "ptrace_user.h"
10 #include "sysdep/ptrace_user.h"
11 #endif
12
13 #include <errno.h>
14 #include <signal.h>
15 #include "sysdep/ptrace.h"
16 #include "kern_constants.h"
17 #include "as-layout.h"
18 #include "os.h"
19 #include "sigcontext.h"
20 #include "task.h"
21
22 static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
23
24 void sig_handler_common_skas(int sig, void *sc_ptr)
25 {
26         struct sigcontext *sc = sc_ptr;
27         struct uml_pt_regs *r;
28         void (*handler)(int, struct uml_pt_regs *);
29         int save_user, save_errno = errno;
30
31         /*
32          * This is done because to allow SIGSEGV to be delivered inside a SEGV
33          * handler.  This can happen in copy_user, and if SEGV is disabled,
34          * the process will die.
35          * XXX Figure out why this is better than SA_NODEFER
36          */
37         if (sig == SIGSEGV) {
38                 change_sig(SIGSEGV, 1);
39                 /*
40                  * For segfaults, we want the data from the
41                  * sigcontext.  In this case, we don't want to mangle
42                  * the process registers, so use a static set of
43                  * registers.  For other signals, the process
44                  * registers are OK.
45                  */
46                 r = &ksig_regs[cpu()];
47                 copy_sc(r, sc_ptr);
48         }
49         else r = TASK_REGS(get_current());
50
51         save_user = r->is_user;
52         r->is_user = 0;
53         if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
54             (sig == SIGILL) || (sig == SIGTRAP))
55                 GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
56
57         change_sig(SIGUSR1, 1);
58
59         handler = sig_info[sig];
60
61         /* unblock SIGVTALRM, SIGIO if sig isn't IRQ signal */
62         if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
63                 unblock_signals();
64
65         handler(sig, r);
66
67         errno = save_errno;
68         r->is_user = save_user;
69 }