OSDN Git Service

1999-05-20 Andrew Haley <aph@cygnus.com>
[pf3gnuchains/gcc-fork.git] / libjava / include / sparc-signal.h
1 // sparc-signal.h - Catch runtime signals and turn them into exceptions.
2
3 /* Copyright (C) 1998, 1999  Cygnus Solutions
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 #ifndef JAVA_SIGNAL_H
12 #define JAVA_SIGNAL_H 1
13
14 #include <signal.h>
15 #include <ucontext.h>
16
17 #define HANDLE_SEGV 1
18 #define HANDLE_FPE 1
19
20 #define SIGNAL_HANDLER(_name)                                           \
21 static void _name (int _dummy, siginfo_t *_info, ucontext_t *_context)
22
23 #define FLUSH_REGISTER_WINDOWS                                  \
24   asm volatile ("ta 3");
25
26 #define MAKE_THROW_FRAME                                        \
27 do                                                              \
28 {                                                               \
29   (void)_dummy;                                                 \
30   (void)_info;                                                  \
31   register int sp = _context->uc_mcontext.gregs[REG_SP];        \
32   register int retaddr = _context->uc_mcontext.gregs[REG_O7];   \
33   FLUSH_REGISTER_WINDOWS;                                       \
34   asm volatile ("mov %0, %%i6; mov %1, %%i7"                    \
35                 : : "r"(sp), "r"(retaddr));                     \
36 }                                                               \
37 while (0)
38
39 #define INIT_SEGV                                               \
40 do                                                              \
41   {                                                             \
42     nullp = new java::lang::NullPointerException ();            \
43     struct sigaction act;                                       \
44     act.sa_sigaction = catch_segv;                              \
45     act.sa_flags = SA_SIGINFO;                                  \
46     sigemptyset (&act.sa_mask);                                 \
47     sigaction (SIGSEGV, &act, NULL);                            \
48   }                                                             \
49 while (0)                                                       
50                                                                 
51 #define INIT_FPE                                                \
52 do                                                              \
53   {                                                             \
54     arithexception = new java::lang::ArithmeticException        \
55       (JvNewStringLatin1 ("/ by zero"));                        \
56     struct sigaction act;                                       \
57     act.sa_flags = SA_SIGINFO;                                  \
58     act.sa_sigaction = catch_fpe;                               \
59     sigemptyset (&act.sa_mask);                                 \
60     sigaction (SIGFPE, &act, NULL);                             \
61   }                                                             \
62 while (0)
63
64 #endif /* JAVA_SIGNAL_H */