fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libjava / include / powerpc-signal.h
blob0d5a6627fe7624d51db5514ea18abf2c18398d60
1 // powerpc-signal.h - Catch runtime signals and turn them into exceptions
2 // on a powerpc based Linux system.
4 /* Copyright (C) 2003 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. */
13 #ifndef JAVA_SIGNAL_H
14 #define JAVA_SIGNAL_H 1
16 #include <signal.h>
17 #include <sys/syscall.h>
19 #define HANDLE_SEGV 1
20 #undef HANDLE_FPE
22 #define SIGNAL_HANDLER(_name) \
23 static void _name (int /* _signal */, struct sigcontext *_sc)
25 /* PPC either leaves PC pointing at a faulting instruction or the
26 following instruction, depending on the signal. SEGV always does
27 the former, so we adjust the saved PC to point to the following
28 instruction. This is what the handler in libgcc expects. */
30 #define MAKE_THROW_FRAME(_exception) \
31 do \
32 { \
33 _sc->regs->nip += 4; \
34 } \
35 while (0)
37 /* For an explanation why we cannot simply use sigaction to
38 install the handlers, see i386-signal.h. */
40 /* We use kernel_old_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 Additionally we want a proper prototype for the handler function
45 with the struct sigcontext pointer passed by the kernel as the 2nd
46 argument, which isn't there in userland headers.
48 Note that we explicitly avoid the SA_SIGINFO flag in INIT_SEGV and
49 INIT_FPE below. Using the ucontext pointer passed as 3rd argument
50 of a SA_SIGINFO type handler would need complicated backwards
51 compatibility hacks in MAKE_THROW_FRAME, as the ucontext layout
52 on PPC changed during the 2.5 kernel series. */
54 #ifndef __powerpc64__
55 struct kernel_old_sigaction {
56 void (*k_sa_handler) (int, struct sigcontext *);
57 unsigned long k_sa_mask;
58 unsigned long k_sa_flags;
59 void (*k_sa_restorer) (void);
62 #define INIT_SEGV \
63 do \
64 { \
65 struct kernel_old_sigaction kact; \
66 kact.k_sa_handler = catch_segv; \
67 kact.k_sa_mask = 0; \
68 kact.k_sa_flags = 0; \
69 if (syscall (SYS_sigaction, SIGSEGV, &kact, NULL) != 0) \
70 __asm__ __volatile__ (".long 0"); \
71 } \
72 while (0)
74 #define INIT_FPE \
75 do \
76 { \
77 struct kernel_old_sigaction kact; \
78 kact.k_sa_handler = catch_fpe; \
79 kact.k_sa_mask = 0; \
80 kact.k_sa_flags = 0; \
81 if (syscall (SYS_sigaction, SIGFPE, &kact, NULL) != 0) \
82 __asm__ __volatile__ (".long 0"); \
83 } \
84 while (0)
86 #else /* powerpc64 */
88 struct kernel_sigaction
90 void (*k_sa_handler) (int, struct sigcontext *);
91 unsigned long k_sa_flags;
92 void (*k_sa_restorer)(void);
93 unsigned long k_sa_mask;
96 #define INIT_SEGV \
97 do \
98 { \
99 struct kernel_sigaction kact; \
100 memset (&kact, 0, sizeof (kact)); \
101 kact.k_sa_handler = catch_segv; \
102 if (syscall (SYS_rt_sigaction, SIGSEGV, &kact, NULL, 8) != 0) \
103 __asm__ __volatile__ (".long 0"); \
105 while (0)
107 #define INIT_FPE \
108 do \
110 struct kernel_sigaction kact; \
111 memset (&kact, 0, sizeof (kact)); \
112 kact.k_sa_handler = catch_fpe; \
113 if (syscall (SYS_rt_sigaction, SIGFPE, &kact, NULL, 8) != 0) \
114 __asm__ __volatile__ (".long 0"); \
116 while (0)
117 #endif
119 #endif /* JAVA_SIGNAL_H */