OSDN Git Service

2011-10-17 Paul Brook <paul@codesourcery.com>
[pf3gnuchains/gcc-fork.git] / libjava / include / posix-signal.h
1 // posix-signal.h - Catch runtime signals and turn them into exceptions.
2
3 /* Copyright (C) 1998, 1999, 2000, 2009, 2011  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
16 #define HANDLE_SEGV 1
17 #define HANDLE_FPE 1
18
19 /* Different implementations of MD_FALLBACK_FRAME_STATE_FOR either require
20    SA_SIGINFO being set or fail if so.  Cf. gcc/ada/init.c
21    (__gnat_install_handler) for details.  */
22
23 #if (defined __alpha__ && defined __osf__) \
24   || (defined __sun__ && defined __svr4__)
25 #define SA_FLAGS SA_NODEFER | SA_SIGINFO
26 #elif defined __sgi__
27 #define SA_FLAGS SA_NODEFER
28 #else
29 #error Must define SA_FLAGS.
30 #endif
31
32 #if SA_FLAGS & SA_SIGINFO
33 #define SIGNAL_HANDLER(_name)                                           \
34 static void _Jv_##_name (int,                                           \
35                          siginfo_t *_si __attribute__ ((__unused__)),   \
36                          void *_uc __attribute__ ((__unused__)))
37 #define sa_signal_handler sa_sigaction
38 #else
39 #define SIGNAL_HANDLER(_name)                                           \
40 static void _Jv_##_name (int)
41 #define sa_signal_handler sa_handler
42 #endif
43
44 #define MAKE_THROW_FRAME(_exception)
45
46 #define _INIT_SIG_HANDLER(_SIG, _ACTION)                                \
47 do                                                                      \
48   {                                                                     \
49     struct sigaction act;                                               \
50     act.sa_signal_handler = _Jv_##_ACTION;                              \
51     act.sa_flags = SA_FLAGS;                                            \
52     sigemptyset (&act.sa_mask);                                         \
53     sigaction(_SIG, &act, NULL);                                        \
54   }                                                                     \
55 while (0)
56
57 #define INIT_SEGV       _INIT_SIG_HANDLER (SIGSEGV, catch_segv)
58 #define INIT_FPE        _INIT_SIG_HANDLER (SIGFPE, catch_fpe)
59
60 #endif /* JAVA_SIGNAL_H */