1 | // s390-signal.h - Catch runtime signals and turn them into exceptions
|
---|
2 | // on an s390 based Linux system.
|
---|
3 |
|
---|
4 | /* Copyright (C) 2002 Free Software Foundation
|
---|
5 |
|
---|
6 | This file is part of libgcj.
|
---|
7 |
|
---|
8 | This software is copyrighted work licensed under the terms of the
|
---|
9 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
---|
10 | details. */
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef JAVA_SIGNAL_H
|
---|
14 | #define JAVA_SIGNAL_H 1
|
---|
15 |
|
---|
16 | #include <signal.h>
|
---|
17 | #include <sys/syscall.h>
|
---|
18 |
|
---|
19 | #define HANDLE_SEGV 1
|
---|
20 | #undef HANDLE_FPE
|
---|
21 |
|
---|
22 | #define SIGNAL_HANDLER(_name) \
|
---|
23 | static void _name (int /* _signal */, struct sigcontext _sc)
|
---|
24 |
|
---|
25 | #define MAKE_THROW_FRAME(_exception) \
|
---|
26 | do \
|
---|
27 | { \
|
---|
28 | /* Advance the program counter so that it is after the start of the \
|
---|
29 | instruction: the s390 exception handler expects the PSW to point \
|
---|
30 | to the instruction after a call. */ \
|
---|
31 | _sc.sregs->regs.psw.addr += 2; \
|
---|
32 | \
|
---|
33 | } \
|
---|
34 | while (0)
|
---|
35 |
|
---|
36 |
|
---|
37 | /* For an explanation why we cannot simply use sigaction to
|
---|
38 | install the handlers, see i386-signal.h. */
|
---|
39 |
|
---|
40 | /* We use old_kernel_sigaction here because we're calling the kernel
|
---|
41 | directly rather than via glibc. The sigaction structure that the
|
---|
42 | syscall uses is a different shape from the one in userland and not
|
---|
43 | visible to us in a header file so we define it here. */
|
---|
44 |
|
---|
45 | struct old_s390_kernel_sigaction {
|
---|
46 | void (*k_sa_handler) (int, struct sigcontext);
|
---|
47 | unsigned long k_sa_mask;
|
---|
48 | unsigned long k_sa_flags;
|
---|
49 | void (*sa_restorer) (void);
|
---|
50 | };
|
---|
51 |
|
---|
52 | #define INIT_SEGV \
|
---|
53 | do \
|
---|
54 | { \
|
---|
55 | nullp = new java::lang::NullPointerException (); \
|
---|
56 | struct old_s390_kernel_sigaction kact; \
|
---|
57 | kact.k_sa_handler = catch_segv; \
|
---|
58 | kact.k_sa_mask = 0; \
|
---|
59 | kact.k_sa_flags = 0; \
|
---|
60 | syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
|
---|
61 | } \
|
---|
62 | while (0)
|
---|
63 |
|
---|
64 | #define INIT_FPE \
|
---|
65 | do \
|
---|
66 | { \
|
---|
67 | arithexception = new java::lang::ArithmeticException \
|
---|
68 | (JvNewStringLatin1 ("/ by zero")); \
|
---|
69 | struct old_s390_kernel_sigaction kact; \
|
---|
70 | kact.k_sa_handler = catch_fpe; \
|
---|
71 | kact.k_sa_mask = 0; \
|
---|
72 | kact.k_sa_flags = 0; \
|
---|
73 | syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
|
---|
74 | } \
|
---|
75 | while (0)
|
---|
76 |
|
---|
77 | #endif /* JAVA_SIGNAL_H */
|
---|
78 |
|
---|