1 // sh-signal.h - Catch runtime signals and turn them into exceptions
2 // on a SuperH based Linux system.
4 /* Copyright (C) 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
14 #define JAVA_SIGNAL_H 1
17 #include <sys/syscall.h>
22 /* The third parameter to the signal handler points to something with
23 * this structure defined in asm/ucontext.h, but the name clashes with
24 * struct ucontext from sys/ucontext.h so this private copy is used. */
25 typedef struct _sig_ucontext
{
26 unsigned long uc_flags
;
27 struct _sig_ucontext
*uc_link
;
29 struct sigcontext uc_mcontext
;
33 #define SIGNAL_HANDLER(_name) \
34 static void _name (int , siginfo_t *, sig_ucontext_t *_uc)
36 /* SH 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. */
42 #define MAKE_THROW_FRAME(_exception) \
45 volatile struct sigcontext *_sc = &_uc->uc_mcontext; \
50 #define MAKE_THROW_FRAME(_exception) \
53 volatile struct sigcontext *_sc = &_uc->uc_mcontext; \
59 /* For an explanation why we cannot simply use sigaction to
60 install the handlers, see i386-signal.h. */
62 /* We use kernel_old_sigaction here because we're calling the kernel
63 directly rather than via glibc. The sigaction structure that the
64 syscall uses is a different shape from the one in userland and not
65 visible to us in a header file so we define it here. */
67 struct kernel_old_sigaction
{
68 void (*k_sa_handler
) (int, siginfo_t
*, sig_ucontext_t
*);
69 unsigned long k_sa_mask
;
70 unsigned long k_sa_flags
;
71 void (*k_sa_restorer
) (void);
77 struct kernel_old_sigaction kact; \
78 kact.k_sa_handler = catch_segv; \
80 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
81 syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
88 struct kernel_old_sigaction kact; \
89 kact.k_sa_handler = catch_fpe; \
91 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
92 syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
96 #endif /* JAVA_SIGNAL_H */