1 // mips-signal.h - Catch runtime signals and turn them into exceptions
2 // on an mips based Linux system.
4 /* Copyright (C) 1998, 1999, 2001, 2002, 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
12 /* Adapted from sparc-signal.h and powerpc-signal.h
13 by David Daney <ddaney@avtrex.com> */
16 #define JAVA_SIGNAL_H 1
20 #include <sys/syscall.h>
21 /* #include <asm/ucontext.h> structures we use are here but clash with
22 sys/ucontext.h included by java-signal.h from prims.cc */
27 /* The third parameter to the signal handler points to something with
28 * this structure defined in asm/ucontext.h, but the name clashes with
29 * struct ucontext from sys/ucontext.h so this private copy is used. */
30 typedef struct _sig_ucontext
{
31 unsigned long uc_flags
;
32 struct _sig_ucontext
*uc_link
;
34 struct sigcontext uc_mcontext
;
38 /* We use kernel_sigaction here because we're calling the kernel
39 directly rather than via glibc. The sigaction structure that the
40 syscall uses is a different shape from the one in userland and not
41 visible to us in a header file so we define it here.
42 Additionally we want a proper prototype for the handler function
43 with the struct sigcontext pointer passed by the kernel as the 2nd
44 argument, which isn't there in userland headers. */
46 struct kernel_sigaction
{
47 unsigned int k_sa_flags
;
48 void (*k_sa_handler
) (int, siginfo_t
*, sig_ucontext_t
*);
50 void (*k_sa_restorer
)(void);
51 int k_sa_resv
[1]; /* reserved */
56 #define SIGNAL_HANDLER(_name) \
57 static void _name (int _dummy, siginfo_t *_info, sig_ucontext_t *_arg)
60 * MIPS leaves pc pointing at the faulting instruction, but the
61 * unwinder expects it to point to the following instruction
64 #define MAKE_THROW_FRAME(_exception) \
67 _arg->uc_mcontext.sc_pc += 4; \
73 /* For an explanation why we cannot simply use sigaction to
74 install the handlers, see i386-signal.h. */
79 struct kernel_sigaction kact; \
80 kact.k_sa_handler = catch_segv; \
81 kact.k_sa_flags = SA_SIGINFO | SA_NODEFER; \
82 sigemptyset (&kact.k_sa_mask); \
83 syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
88 #endif /* JAVA_SIGNAL_H */