1 // ppc-signal.h - Catch runtime signals and turn them into exceptions.
3 /* Copyright (C) 2000 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 #define JAVA_SIGNAL_H 1
20 #define SIGNAL_HANDLER(_name) \
21 __asm ("\t.section\t\".text\"\n" \
25 "\tb _Jv_stub_" #_name "\n"); \
26 extern "C" void _Jv_##_name (int _dummy); \
27 extern "C" void _Jv_stub_##_name (char *_sp) \
29 class java::lang::Throwable;
31 // Unwind the stack to the point at which the signal was generated and
32 // then throw an exception.
34 #define MAKE_THROW_FRAME(_exception) \
37 struct sigcontext_struct *_context \
38 = (struct sigcontext_struct *)(_sp + __SIGNAL_FRAMESIZE); \
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; \
46 "\tmr 3,%1 # exception to throw\n" \
47 "\tlwz 0,128(31) # ip\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" \
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) \
93 nullp = new java::lang::NullPointerException (); \
94 struct sigaction act; \
95 act.sa_handler = _Jv_catch_segv; \
96 sigemptyset (&act.sa_mask); \
98 __sigaction (SIGSEGV, &act, NULL); \
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); \
111 __sigaction (SIGFPE, &act, NULL); \
115 #endif /* JAVA_SIGNAL_H */