* gcc.c-torture/execute/20020307-1.c: New test.
[official-gcc.git] / libjava / include / dwarf2-signal.h
blob3a662aec2d979bf6138ec6b5340aa8365aa016f8
1 // dwarf2-signal.h - Catch runtime signals and turn them into exceptions.
3 /* Copyright (C) 2000, 2001 Free Software Foundation
5 This file is part of libgcj.
7 Use this file for a target for which the dwarf2 unwinder in libgcc
8 can unwind through signal handlers.
10 This software is copyrighted work licensed under the terms of the
11 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 details. */
14 #ifndef JAVA_SIGNAL_H
15 #define JAVA_SIGNAL_H 1
17 #include <signal.h>
18 #include <sys/syscall.h>
20 #define HANDLE_SEGV 1
21 #undef HANDLE_FPE
23 #define SIGNAL_HANDLER(_name) \
24 static void _Jv_##_name (int, siginfo_t *, void *_p)
26 class java::lang::Throwable;
28 // Unwind the stack to the point at which the signal was generated and
29 // then throw an exception. With the dwarf2 unwinder we don't usually
30 // need to do anything, with some minor exceptions.
32 #ifdef __alpha__
33 #define MAKE_THROW_FRAME(_exception) \
34 do \
35 { \
36 /* Alpha either leaves PC pointing at a faulting instruction or the \
37 following instruction, depending on the signal. SEGV always does \
38 the former, so we adjust the saved PC to point to the following \
39 instruction; this is what the handler in libgcc expects. */ \
40 struct sigcontext *_sc = (struct sigcontext *)_p; \
41 _sc->sc_pc += 4; \
42 } \
43 while (0)
44 #else
45 #define MAKE_THROW_FRAME(_exception) \
46 do \
47 { \
48 (void)_p; \
49 } \
50 while (0)
51 #endif
53 #define INIT_SEGV \
54 do \
55 { \
56 nullp = new java::lang::NullPointerException (); \
57 struct sigaction act; \
58 act.sa_sigaction = _Jv_catch_segv; \
59 sigemptyset (&act.sa_mask); \
60 act.sa_flags = SA_SIGINFO; \
61 syscall (SYS_sigaction, SIGSEGV, &act, NULL); \
62 } \
63 while (0)
65 #define INIT_FPE \
66 do \
67 { \
68 arithexception = new java::lang::ArithmeticException \
69 (JvNewStringLatin1 ("/ by zero")); \
70 struct sigaction act; \
71 act.sa_sigaction = _Jv_catch_fpe; \
72 sigemptyset (&act.sa_mask); \
73 act.sa_flags = SA_SIGINFO; \
74 syscall (SYS_sigaction, SIGFPE, &act, NULL); \
75 } \
76 while (0)
78 /* We use syscall(SYS_sigaction) in INIT_SEGV and INIT_FPE instead of
79 * sigaction() because on some systems the pthreads wrappers for
80 * signal handlers are not compiled with unwind information, so it's
81 * not possible to unwind through them. This is a problem that will
82 * go away once all systems have pthreads libraries that are
83 * compiled with full unwind info. */
85 #endif /* JAVA_SIGNAL_H */