source: branches/libc-0.6/src/gcc/libjava/include/powerpc-signal.h

Last change on this file was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.7 KB
Line 
1// powerpc-signal.h - Catch runtime signals and turn them into exceptions
2// on a powerpc based Linux system.
3
4/* Copyright (C) 2003 Free Software Foundation
5
6 This file is part of libgcj.
7
8This software is copyrighted work licensed under the terms of the
9Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
10details. */
11
12
13#ifndef JAVA_SIGNAL_H
14# define JAVA_SIGNAL_H 1
15
16# include <signal.h>
17# include <sys/syscall.h>
18
19# define HANDLE_SEGV 1
20# undef HANDLE_FPE
21
22# define SIGNAL_HANDLER(_name) \
23 static void _name (int /* _signal */, struct sigcontext *_sc)
24
25/* PPC either leaves PC pointing at a faulting instruction or the
26 following instruction, depending on the signal. SEGV always does
27 the former, so we adjust the saved PC to point to the following
28 instruction. This is what the handler in libgcc expects. */
29
30# define MAKE_THROW_FRAME(_exception) \
31do \
32 { \
33 _sc->regs->nip += 4; \
34 } \
35while (0)
36
37/* For an explanation why we cannot simply use sigaction to
38 install the handlers, see i386-signal.h. */
39
40/* We use kernel_old_sigaction here because we're calling the kernel
41 directly rather than via glibc. The sigaction structure that the
42 syscall uses is a different shape from the one in userland and not
43 visible to us in a header file so we define it here.
44 Additionally we want a proper prototype for the handler function
45 with the struct sigcontext pointer passed by the kernel as the 2nd
46 argument, which isn't there in userland headers.
47
48 Note that we explicitly avoid the SA_SIGINFO flag in INIT_SEGV and
49 INIT_FPE below. Using the ucontext pointer passed as 3rd argument
50 of a SA_SIGINFO type handler would need complicated backwards
51 compatibility hacks in MAKE_THROW_FRAME, as the ucontext layout
52 on PPC changed during the 2.5 kernel series. */
53
54struct kernel_old_sigaction {
55 void (*k_sa_handler) (int, struct sigcontext *);
56 unsigned long k_sa_mask;
57 unsigned long k_sa_flags;
58 void (*k_sa_restorer) (void);
59};
60
61# define INIT_SEGV \
62do \
63 { \
64 nullp = new java::lang::NullPointerException (); \
65 struct kernel_old_sigaction kact; \
66 kact.k_sa_handler = catch_segv; \
67 kact.k_sa_mask = 0; \
68 kact.k_sa_flags = 0; \
69 syscall (SYS_sigaction, SIGSEGV, &kact, NULL); \
70 } \
71while (0)
72
73# define INIT_FPE \
74do \
75 { \
76 arithexception = new java::lang::ArithmeticException \
77 (JvNewStringLatin1 ("/ by zero")); \
78 struct kernel_old_sigaction kact; \
79 kact.k_sa_handler = catch_fpe; \
80 kact.k_sa_mask = 0; \
81 kact.k_sa_flags = 0; \
82 syscall (SYS_sigaction, SIGFPE, &kact, NULL); \
83 } \
84while (0)
85
86#endif /* JAVA_SIGNAL_H */
87
Note: See TracBrowser for help on using the repository browser.