OSDN Git Service

Rebuilt Makefile.ins
[pf3gnuchains/gcc-fork.git] / libjava / include / ppc-signal.h
1 // ppc-signal.h - Catch runtime signals and turn them into exceptions.
2
3 /* Copyright (C) 2000  Free Software Foundation
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 #undef HANDLE_FPE
19
20 #define SIGNAL_HANDLER(_name)                   \
21 __asm ("\t.section\t\".text\"\n"                \
22        "\t.align 2\n"                           \
23        "_Jv_" #_name ":\n"                      \
24        "\tmr 3, 1\n"                            \
25        "\tb _Jv_stub_" #_name "\n");            \
26 extern "C" void _Jv_##_name (int _dummy);       \
27 extern "C" void _Jv_stub_##_name (char *_sp)    \
28
29 class java::lang::Throwable;
30
31 // Unwind the stack to the point at which the signal was generated and
32 // then throw an exception.
33
34 #define MAKE_THROW_FRAME(_exception)                                    \
35 do                                                                      \
36 {                                                                       \
37   struct sigcontext_struct *_context                                    \
38     = (struct sigcontext_struct *)(_sp + __SIGNAL_FRAMESIZE);           \
39   long int regs [34];                                                   \
40   memcpy (regs, &_context->regs->gpr[0], 32 * sizeof (long int));       \
41   regs[32] = _context->regs->nip + sizeof (long int);                   \
42   regs[33] = _context->regs->link;                                      \
43                                                                         \
44   __asm volatile (                                                      \
45         "\tmr 31,%0\n"                                                  \
46         "\tmr 3,%1              # exception to throw\n"                 \
47         "\tlwz 0,128(31)        # ip\n"                                 \
48         "\tmtlr 0\n"                                                    \
49         "\tlwz 1,4(31)          # previous r1\n"                        \
50         "\tlwz 0,132(31)        # previous lr\n"                        \
51         "\tlwz 2,0(1)           # previous previous r1\n"               \
52         "\tstw 0,4(2)           # save previous lr\n"                   \
53         "\tlwz 0,0(31)\n"                                               \
54         "\tlwz 2,8(31)\n"                                               \
55         "\tlwz 4,16(31)\n"                                              \
56         "\tlwz 5,20(31)\n"                                              \
57         "\tlwz 6,24(31)\n"                                              \
58         "\tlwz 7,28(31)\n"                                              \
59         "\tlwz 8,32(31)\n"                                              \
60         "\tlwz 9,36(31)\n"                                              \
61         "\tlwz 10,40(31)\n"                                             \
62         "\tlwz 11,44(31)\n"                                             \
63         "\tlwz 12,48(31)\n"                                             \
64         "\tlwz 13,52(31)\n"                                             \
65         "\tlwz 14,56(31)\n"                                             \
66         "\tlwz 15,60(31)\n"                                             \
67         "\tlwz 16,64(31)\n"                                             \
68         "\tlwz 17,68(31)\n"                                             \
69         "\tlwz 18,72(31)\n"                                             \
70         "\tlwz 19,76(31)\n"                                             \
71         "\tlwz 20,80(31)\n"                                             \
72         "\tlwz 21,84(31)\n"                                             \
73         "\tlwz 22,88(31)\n"                                             \
74         "\tlwz 23,92(31)\n"                                             \
75         "\tlwz 24,96(31)\n"                                             \
76         "\tlwz 25,100(31)\n"                                            \
77         "\tlwz 26,104(31)\n"                                            \
78         "\tlwz 27,108(31)\n"                                            \
79         "\tlwz 28,112(31)\n"                                            \
80         "\tlwz 29,116(31)\n"                                            \
81         "\tlwz 30,120(31)\n"                                            \
82         "\tlwz 31,124(31)\n"                                            \
83         "\tb _Jv_ThrowSignal\n"                                         \
84                   : : "r"(regs), "r"(_exception)                        \
85                   : "r31", "r3");                                       \
86 }                                                                       \
87 while (0)  
88
89
90 #define INIT_SEGV                                               \
91 do                                                              \
92   {                                                             \
93     nullp = new java::lang::NullPointerException ();            \
94     struct sigaction act;                                       \
95     act.sa_handler = _Jv_catch_segv;                            \
96     sigemptyset (&act.sa_mask);                                 \
97     act.sa_flags = 0;                                           \
98     __sigaction (SIGSEGV, &act, NULL);                          \
99   }                                                             \
100 while (0)  
101
102 #define INIT_FPE                                                \
103 do                                                              \
104   {                                                             \
105     arithexception = new java::lang::ArithmeticException        \
106       (JvNewStringLatin1 ("/ by zero"));                        \
107     struct sigaction act;                                       \
108     act.sa_handler = _Jv_catch_fpe;                             \
109     sigemptyset (&act.sa_mask);                                 \
110     act.sa_flags = 0;                                           \
111     __sigaction (SIGFPE, &act, NULL);                           \
112   }                                                             \
113 while (0)  
114
115 #endif /* JAVA_SIGNAL_H */