OSDN Git Service

2005-09-17 Jan Hubicka <jh@suse.cz>
[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, 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 #define HANDLE_FPE 1
19
20 #define SIGNAL_HANDLER(_name)                                           \
21 static void _name (int _dummy __attribute__ ((__unused__)), \
22                    siginfo_t *_info __attribute__ ((__unused__)), \
23                    void *arg __attribute__ ((__unused__)))
24
25 #ifdef __arch64__
26 #define FLUSH_REGISTER_WINDOWS                                  \
27   asm volatile ("flushw");
28 #else
29 #define FLUSH_REGISTER_WINDOWS                                  \
30   asm volatile ("ta 3");
31 #endif
32
33 #define MAKE_THROW_FRAME(_exception)                            \
34 do                                                              \
35 {                                                               \
36   ucontext_t *_context = (ucontext_t *) arg;                    \
37   (void)_dummy;                                                 \
38   (void)_info;                                                  \
39   register long sp = _context->uc_mcontext.gregs[REG_SP];       \
40   register long retaddr = _context->uc_mcontext.gregs[REG_O7];  \
41   FLUSH_REGISTER_WINDOWS;                                       \
42   asm volatile ("mov %0, %%i6; mov %1, %%i7"                    \
43                 : : "r"(sp), "r"(retaddr));                     \
44 }                                                               \
45 while (0)
46
47 #define INIT_SEGV                                               \
48 do                                                              \
49   {                                                             \
50     struct sigaction act;                                       \
51     act.sa_sigaction = catch_segv;                              \
52     act.sa_flags = SA_SIGINFO | SA_NODEFER;                     \
53     sigemptyset (&act.sa_mask);                                 \
54     sigaction (SIGSEGV, &act, NULL);                            \
55   }                                                             \
56 while (0)                                                       
57                                                                 
58 #define INIT_FPE                                                \
59 do                                                              \
60   {                                                             \
61     struct sigaction act;                                       \
62     act.sa_flags = SA_SIGINFO | SA_NODEFER;                     \
63     act.sa_sigaction = catch_fpe;                               \
64     sigemptyset (&act.sa_mask);                                 \
65     sigaction (SIGFPE, &act, NULL);                             \
66   }                                                             \
67 while (0)
68
69 #endif /* JAVA_SIGNAL_H */