]> gcc.gnu.org Git - gcc.git/blob - libjava/include/dwarf2-signal.h
dwarf2-signal.h: New file.
[gcc.git] / libjava / include / dwarf2-signal.h
1 // dwarf2-signal.h - Catch runtime signals and turn them into exceptions.
2
3 /* Copyright (C) 2000, 2001 Free Software Foundation
4
5 This file is part of libgcj.
6
7 Use this file for every target for which the dwarf2 unwinder in
8 libgcc can unwind through signal handlers and no special actions
9 are needed.
10
11 This software is copyrighted work licensed under the terms of the
12 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
13 details. */
14
15 #ifndef JAVA_SIGNAL_H
16 #define JAVA_SIGNAL_H 1
17
18 #include <signal.h>
19 #include <sys/syscall.h>
20
21 #define HANDLE_SEGV 1
22 #undef HANDLE_FPE
23
24 #define SIGNAL_HANDLER(_name) \
25 static void _Jv_##_name (int)
26
27 class java::lang::Throwable;
28
29 // Unwind the stack to the point at which the signal was generated and
30 // then throw an exception. With the dwarf2 unwinder we don't need to
31 // do anything.
32
33 #define MAKE_THROW_FRAME(_exception) \
34 do \
35 { \
36 } \
37 while (0)
38
39
40 #define INIT_SEGV \
41 do \
42 { \
43 nullp = new java::lang::NullPointerException (); \
44 struct sigaction act; \
45 act.sa_handler = _Jv_catch_segv; \
46 sigemptyset (&act.sa_mask); \
47 act.sa_flags = 0; \
48 syscall (SYS_sigaction, SIGSEGV, &act, NULL); \
49 } \
50 while (0)
51
52 #define INIT_FPE \
53 do \
54 { \
55 arithexception = new java::lang::ArithmeticException \
56 (JvNewStringLatin1 ("/ by zero")); \
57 struct sigaction act; \
58 act.sa_handler = _Jv_catch_fpe; \
59 sigemptyset (&act.sa_mask); \
60 act.sa_flags = 0; \
61 syscall (SYS_sigaction, SIGFPE, &act, NULL); \
62 } \
63 while (0)
64
65 /* We use syscall(SYS_sigaction) in INIT_SEGV and INIT_FPE instead of
66 * sigaction() because on some systems the pthreads wrappers for
67 * signal handlers are not compiled with unwind information, so it's
68 * not possible to unwind through them. This is a problem that will
69 * go away once all systems have pthreads libraries that are
70 * compiled with full unwind info. */
71
72 #endif /* JAVA_SIGNAL_H */
This page took 0.038409 seconds and 5 git commands to generate.