OSDN Git Service

Back out controversial fix.
[pf3gnuchains/gcc-fork.git] / libjava / include / pa-signal.h
1 // pa-signal.h - Catch runtime signals and turn them into exceptions.
2
3 /* Copyright (C) 1998, 1999, 2000  Free Software Foundation
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 #ifndef JAVA_SIGNAL_H
12 #define JAVA_SIGNAL_H 1
13
14 #include <signal.h>
15 #include <ucontext.h>
16 #include <sys/syscall.h>
17
18 #define HANDLE_SEGV 1
19 #define HANDLE_FPE 1
20
21 #define SIGNAL_HANDLER(_name)                                   \
22 static void _Jv_##_name (int _dummy, siginfo_t *_info, void *arg)
23
24 #define MAKE_THROW_FRAME(_exception)                            \
25 do                                                              \
26 {                                                               \
27   struct ucontext *uc = (struct ucontext *)arg;                 \
28   struct sigcontext *sc = &uc->uc_mcontext;                     \
29   (void)_dummy;                                                 \
30   (void)_info;                                                  \
31   /* Advance the program counter so that it is after the start  \
32      of the instruction:  the exception handler expects         \
33      the PC to point to the instruction after a call. */        \
34   sc->sc_iaoq[0] = sc->sc_iaoq[1];                              \
35   sc->sc_iaoq[1] += 4;                                          \
36 }                                                               \
37 while (0)
38
39 #define INIT_SEGV                                               \
40 do                                                              \
41   {                                                             \
42     struct sigaction act;                                       \
43     act.sa_sigaction = _Jv_catch_segv;                          \
44     sigemptyset (&act.sa_mask);                                 \
45     act.sa_flags = SA_SIGINFO;                                  \
46     syscall (SYS_rt_sigaction, SIGSEGV, &act, NULL, _NSIG / 8); \
47   }                                                             \
48 while (0)  
49
50 #define INIT_FPE                                                \
51 do                                                              \
52   {                                                             \
53     struct sigaction act;                                       \
54     act.sa_sigaction = _Jv_catch_fpe;                           \
55     sigemptyset (&act.sa_mask);                                 \
56     act.sa_flags = SA_SIGINFO;                                  \
57     syscall (SYS_rt_sigaction, SIGFPE, &act, NULL, _NSIG / 8);  \
58   }                                                             \
59 while (0)  
60
61 #endif /* JAVA_SIGNAL_H */