sparc-signal.h: new file.
[gcc.git] / libjava / include / i386-signal.h
1 // i386-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 /* This technique should work for all i386 based Unices which conform
12 * to iBCS2. This includes all versions of Linux more recent than 1.3
13 */
14
15
16 #ifndef JAVA_SIGNAL_H
17 #define JAVA_SIGNAL_H 1
18
19 #include <signal.h>
20
21 #define HANDLE_SEGV 1
22 #define HANDLE_FPE 1
23
24 #define SIGNAL_HANDLER(_name) \
25 static void _name (int _dummy)
26
27 #define MAKE_THROW_FRAME \
28 { \
29 void **_p = (void **)&_dummy; \
30 struct sigcontext_struct *_regs = (struct sigcontext_struct *)++_p; \
31 \
32 register unsigned long _ebp = _regs->ebp; \
33 register unsigned long _eip = _regs->eip; \
34 \
35 asm volatile ("mov %0, (%%ebp); mov %1, 4(%%ebp)" \
36 : : "r"(_ebp), "r"(_eip)); \
37 }
38
39 #define INIT_SEGV \
40 do \
41 { \
42 nullp = new java::lang::NullPointerException (); \
43 struct sigaction act; \
44 act.sa_handler = catch_segv; \
45 sigemptyset (&act.sa_mask); \
46 act.sa_flags = 0; \
47 sigaction (SIGSEGV, &act, NULL); \
48 } \
49 while (0)
50
51 #define INIT_FPE \
52 do \
53 { \
54 arithexception = new java::lang::ArithmeticException (); \
55 struct sigaction act; \
56 act.sa_handler = catch_fpe; \
57 sigemptyset (&act.sa_mask); \
58 act.sa_flags = 0; \
59 sigaction (SIGFPE, &act, NULL); \
60 } \
61 while (0)
62
63 #endif /* JAVA_SIGNAL_H */
64