gcc/
[official-gcc.git] / libjava / include / sh-signal.h
blob3a96ce25fb2d580b539304e2b4b840ae4aec505f
1 // sh-signal.h - Catch runtime signals and turn them into exceptions
2 // on a SuperH based Linux system.
4 /* Copyright (C) 2004, 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
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 #define HANDLE_FPE 1
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;
28 stack_t uc_stack;
29 struct sigcontext uc_mcontext;
30 sigset_t uc_sigmask;
31 } sig_ucontext_t;
33 #define SIGNAL_HANDLER(_name) \
34 static void _name (int , siginfo_t *, sig_ucontext_t *_uc)
36 #define MAKE_THROW_FRAME(_exception)
38 /* For an explanation why we cannot simply use sigaction to
39 install the handlers, see i386-signal.h. */
41 /* We use kernel_old_sigaction here because we're calling the kernel
42 directly rather than via glibc. The sigaction structure that the
43 syscall uses is a different shape from the one in userland and not
44 visible to us in a header file so we define it here. */
46 struct kernel_old_sigaction {
47 void (*k_sa_handler) (int, siginfo_t *, sig_ucontext_t *);
48 unsigned long k_sa_mask;
49 unsigned long k_sa_flags;
50 void (*k_sa_restorer) (void);
53 #define INIT_SEGV \
54 do \
55 { \
56 struct kernel_old_sigaction kact; \
57 kact.k_sa_handler = catch_segv; \
58 kact.k_sa_mask = 0; \
59 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
60 syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
61 } \
62 while (0)
64 #define INIT_FPE \
65 do \
66 { \
67 struct kernel_old_sigaction kact; \
68 kact.k_sa_handler = catch_fpe; \
69 kact.k_sa_mask = 0; \
70 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
71 syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
72 } \
73 while (0)
75 #endif /* JAVA_SIGNAL_H */