2016-09-25 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / libjava / include / posix-signal.h
bloba0f96a905eac70e1dd287a9f983831f73817ad48
1 // posix-signal.h - Catch runtime signals and turn them into exceptions.
3 /* Copyright (C) 1998, 1999, 2000, 2009, 2011, 2012 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
9 details. */
11 #ifndef JAVA_SIGNAL_H
12 #define JAVA_SIGNAL_H 1
14 #include <signal.h>
16 #define HANDLE_SEGV 1
17 #define HANDLE_FPE 1
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. */
23 #if defined __sun__ && defined __svr4__
24 #define SA_FLAGS SA_NODEFER | SA_SIGINFO
25 #else
26 #error Must define SA_FLAGS.
27 #endif
29 #if SA_FLAGS & SA_SIGINFO
30 #define SIGNAL_HANDLER(_name) \
31 static void _Jv_##_name (int, \
32 siginfo_t *_si __attribute__ ((__unused__)), \
33 void *_uc __attribute__ ((__unused__)))
34 #define sa_signal_handler sa_sigaction
35 #else
36 #define SIGNAL_HANDLER(_name) \
37 static void _Jv_##_name (int)
38 #define sa_signal_handler sa_handler
39 #endif
41 #define MAKE_THROW_FRAME(_exception)
43 #define _INIT_SIG_HANDLER(_SIG, _ACTION) \
44 do \
45 { \
46 struct sigaction act; \
47 act.sa_signal_handler = _Jv_##_ACTION; \
48 act.sa_flags = SA_FLAGS; \
49 sigemptyset (&act.sa_mask); \
50 sigaction(_SIG, &act, NULL); \
51 } \
52 while (0)
54 #define INIT_SEGV _INIT_SIG_HANDLER (SIGSEGV, catch_segv)
55 #define INIT_FPE _INIT_SIG_HANDLER (SIGFPE, catch_fpe)
57 #endif /* JAVA_SIGNAL_H */