1 // powerpc-signal.h - Catch runtime signals and turn them into exceptions
2 // on a powerpc based Linux system.
4 /* Copyright (C) 2003, 2006 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 /* MD_FALLBACK_FRAME_STATE_FOR takes care of special casing PC
26 before the faulting instruction, so we don't need to do anything
29 #define MAKE_THROW_FRAME(_exception)
31 /* For an explanation why we cannot simply use sigaction to
32 install the handlers, see i386-signal.h. */
34 /* We use kernel_old_sigaction here because we're calling the kernel
35 directly rather than via glibc. The sigaction structure that the
36 syscall uses is a different shape from the one in userland and not
37 visible to us in a header file so we define it here.
38 Additionally we want a proper prototype for the handler function
39 with the struct sigcontext pointer passed by the kernel as the 2nd
40 argument, which isn't there in userland headers.
42 Note that we explicitly avoid the SA_SIGINFO flag in INIT_SEGV and
43 INIT_FPE below. Using the ucontext pointer passed as 3rd argument
44 of a SA_SIGINFO type handler would need complicated backwards
45 compatibility hacks in MAKE_THROW_FRAME, as the ucontext layout
46 on PPC changed during the 2.5 kernel series. */
49 struct kernel_old_sigaction
{
50 void (*k_sa_handler
) (int, struct sigcontext
*);
51 unsigned long k_sa_mask
;
52 unsigned long k_sa_flags
;
53 void (*k_sa_restorer
) (void);
59 struct kernel_old_sigaction kact; \
60 kact.k_sa_handler = catch_segv; \
62 kact.k_sa_flags = 0; \
63 if (syscall (SYS_sigaction, SIGSEGV, &kact, NULL) != 0) \
64 __asm__ __volatile__ (".long 0"); \
71 struct kernel_old_sigaction kact; \
72 kact.k_sa_handler = catch_fpe; \
74 kact.k_sa_flags = 0; \
75 if (syscall (SYS_sigaction, SIGFPE, &kact, NULL) != 0) \
76 __asm__ __volatile__ (".long 0"); \
82 struct kernel_sigaction
84 void (*k_sa_handler
) (int, struct sigcontext
*);
85 unsigned long k_sa_flags
;
86 void (*k_sa_restorer
)(void);
87 unsigned long k_sa_mask
;
93 struct kernel_sigaction kact; \
94 memset (&kact, 0, sizeof (kact)); \
95 kact.k_sa_handler = catch_segv; \
96 if (syscall (SYS_rt_sigaction, SIGSEGV, &kact, NULL, 8) != 0) \
97 __asm__ __volatile__ (".long 0"); \
104 struct kernel_sigaction kact; \
105 memset (&kact, 0, sizeof (kact)); \
106 kact.k_sa_handler = catch_fpe; \
107 if (syscall (SYS_rt_sigaction, SIGFPE, &kact, NULL, 8) != 0) \
108 __asm__ __volatile__ (".long 0"); \
113 #endif /* JAVA_SIGNAL_H */