Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / include / sh-signal.h
blob25e873117ffe5ac37406bcb821502b850f454d22
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
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 /* 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. */
41 #ifdef __SH5__
42 #define MAKE_THROW_FRAME(_exception) \
43 do \
44 { \
45 volatile struct sigcontext *_sc = &_uc->uc_mcontext; \
46 _sc->sc_pc += 4; \
47 } \
48 while (0)
49 #else
50 #define MAKE_THROW_FRAME(_exception) \
51 do \
52 { \
53 volatile struct sigcontext *_sc = &_uc->uc_mcontext; \
54 _sc->sc_pc += 2; \
55 } \
56 while (0)
57 #endif
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);
74 #define INIT_SEGV \
75 do \
76 { \
77 struct kernel_old_sigaction kact; \
78 kact.k_sa_handler = catch_segv; \
79 kact.k_sa_mask = 0; \
80 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
81 syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
82 } \
83 while (0)
85 #define INIT_FPE \
86 do \
87 { \
88 struct kernel_old_sigaction kact; \
89 kact.k_sa_handler = catch_fpe; \
90 kact.k_sa_mask = 0; \
91 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
92 syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
93 } \
94 while (0)
96 #endif /* JAVA_SIGNAL_H */