[PATCH] uml: move libc-dependent code from signal_user.c
[powerpc.git] / arch / um / kernel / trap_user.c
1 /* 
2  * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include <stdlib.h>
7 #include <errno.h>
8 #include <setjmp.h>
9 #include <signal.h>
10 #include <sys/time.h>
11 #include <sys/wait.h>
12 #include <asm/page.h>
13 #include <asm/unistd.h>
14 #include <asm/ptrace.h>
15 #include "init.h"
16 #include "sysdep/ptrace.h"
17 #include "sigcontext.h"
18 #include "sysdep/sigcontext.h"
19 #include "irq_user.h"
20 #include "time_user.h"
21 #include "task.h"
22 #include "mode.h"
23 #include "choose-mode.h"
24 #include "kern_util.h"
25 #include "user_util.h"
26 #include "os.h"
27
28 void kill_child_dead(int pid)
29 {
30         kill(pid, SIGKILL);
31         kill(pid, SIGCONT);
32         do {
33                 int n;
34                 CATCH_EINTR(n = waitpid(pid, NULL, 0));
35                 if (n > 0)
36                         kill(pid, SIGCONT);
37                 else
38                         break;
39         } while(1);
40 }
41
42 void segv_handler(int sig, union uml_pt_regs *regs)
43 {
44         struct faultinfo * fi = UPT_FAULTINFO(regs);
45
46         if(UPT_IS_USER(regs) && !SEGV_IS_FIXABLE(fi)){
47                 bad_segv(*fi, UPT_IP(regs));
48                 return;
49         }
50         segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
51 }
52
53 void usr2_handler(int sig, union uml_pt_regs *regs)
54 {
55         CHOOSE_MODE(syscall_handler_tt(sig, regs), (void) 0);
56 }
57
58 struct signal_info sig_info[] = {
59         [ SIGTRAP ] { .handler          = relay_signal,
60                       .is_irq           = 0 },
61         [ SIGFPE ] { .handler           = relay_signal,
62                      .is_irq            = 0 },
63         [ SIGILL ] { .handler           = relay_signal,
64                      .is_irq            = 0 },
65         [ SIGWINCH ] { .handler         = winch,
66                        .is_irq          = 1 },
67         [ SIGBUS ] { .handler           = bus_handler,
68                      .is_irq            = 0 },
69         [ SIGSEGV] { .handler           = segv_handler,
70                      .is_irq            = 0 },
71         [ SIGIO ] { .handler            = sigio_handler,
72                     .is_irq             = 1 },
73         [ SIGVTALRM ] { .handler        = timer_handler,
74                         .is_irq         = 1 },
75         [ SIGALRM ] { .handler          = timer_handler,
76                       .is_irq           = 1 },
77         [ SIGUSR2 ] { .handler          = usr2_handler,
78                       .is_irq           = 0 },
79 };
80
81 void do_longjmp(void *b, int val)
82 {
83         sigjmp_buf *buf = b;
84
85         siglongjmp(*buf, val);
86 }
87
88 /*
89  * Overrides for Emacs so that we follow Linus's tabbing style.
90  * Emacs will notice this stuff at the end of the file and automatically
91  * adjust the settings for this buffer only.  This must remain at the end
92  * of the file.
93  * ---------------------------------------------------------------------------
94  * Local variables:
95  * c-file-style: "linux"
96  * End:
97  */