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
14 #define JAVA_SIGNAL_H 1
17 #include <sys/syscall.h>
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) \
33 _sc->regs->nip += 4; \
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. */
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);
65 struct kernel_old_sigaction kact; \
66 kact.k_sa_handler = catch_segv; \
68 kact.k_sa_flags = 0; \
69 if (syscall (SYS_sigaction, SIGSEGV, &kact, NULL) != 0) \
70 __asm__ __volatile__ (".long 0"); \
77 struct kernel_old_sigaction kact; \
78 kact.k_sa_handler = catch_fpe; \
80 kact.k_sa_flags = 0; \
81 if (syscall (SYS_sigaction, SIGFPE, &kact, NULL) != 0) \
82 __asm__ __volatile__ (".long 0"); \
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
;
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"); \
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"); \
119 #endif /* JAVA_SIGNAL_H */