* target-def.h (TARGET_CXX_USE_AEABI_ATEXIT): Define.
[official-gcc.git] / libjava / include / mips-signal.h
blob732ba0b1f677003fe555c958314441bcfd3ff039
1 // mips-signal.h - Catch runtime signals and turn them into exceptions
2 // on an mips based Linux system.
4 /* Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004 Free Software Foundation
6 This file is part of libgcj.
8 This software is copyrighted work licensed under the terms of the
9 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10 details. */
12 /* Adapted from sparc-signal.h and powerpc-signal.h
13 by David Daney <ddaney@avtrex.com> */
15 #ifndef JAVA_SIGNAL_H
16 #define JAVA_SIGNAL_H 1
18 #include <signal.h>
19 #include <unistd.h>
20 #include <sys/syscall.h>
21 /* #include <asm/ucontext.h> structures we use are here but clash with
22 sys/ucontext.h included by java-signal.h from prims.cc */
24 #define HANDLE_SEGV 1
25 #define HANDLE_FPE 1
27 /* The third parameter to the signal handler points to something with
28 * this structure defined in asm/ucontext.h, but the name clashes with
29 * struct ucontext from sys/ucontext.h so this private copy is used. */
30 typedef struct _sig_ucontext {
31 unsigned long uc_flags;
32 struct _sig_ucontext *uc_link;
33 stack_t uc_stack;
34 struct sigcontext uc_mcontext;
35 sigset_t uc_sigmask;
36 } sig_ucontext_t;
38 /* We use kernel_sigaction here because we're calling the kernel
39 directly rather than via glibc. The sigaction structure that the
40 syscall uses is a different shape from the one in userland and not
41 visible to us in a header file so we define it here.
42 Additionally we want a proper prototype for the handler function
43 with the struct sigcontext pointer passed by the kernel as the 2nd
44 argument, which isn't there in userland headers. */
46 struct kernel_sigaction {
47 unsigned int k_sa_flags;
48 void (*k_sa_handler) (int, siginfo_t *, sig_ucontext_t *);
49 sigset_t k_sa_mask;
50 void (*k_sa_restorer)(void);
51 int k_sa_resv[1]; /* reserved */
56 #define SIGNAL_HANDLER(_name) \
57 static void _name (int _dummy __attribute__ ((__unused__)), \
58 siginfo_t *_info __attribute__ ((__unused__)), \
59 sig_ucontext_t *_arg __attribute__ ((__unused__)))
62 * MIPS leaves pc pointing at the faulting instruction, but the
63 * unwinder expects it to point to the following instruction
66 #define MAKE_THROW_FRAME(_exception) \
67 do \
68 { \
69 _arg->uc_mcontext.sc_pc += 4; \
70 (void)_dummy; \
71 (void)_info; \
72 } \
73 while (0)
75 /* For an explanation why we cannot simply use sigaction to
76 install the handlers, see i386-signal.h. */
78 #define INIT_SEGV \
79 do \
80 { \
81 struct kernel_sigaction kact; \
82 kact.k_sa_handler = catch_segv; \
83 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
84 sigemptyset (&kact.k_sa_mask); \
85 syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
86 } \
87 while (0)
89 #define INIT_FPE \
90 do \
91 { \
92 struct kernel_sigaction kact; \
93 kact.k_sa_handler = catch_fpe; \
94 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
95 sigemptyset (&kact.k_sa_mask); \
96 syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
97 } \
98 while (0)
100 #undef HANDLE_DIVIDE_OVERFLOW
102 #endif /* JAVA_SIGNAL_H */