diff options
author | Tero Koskinen <tero.koskinen@iki.fi> | 2008-01-03 11:35:04 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@gcc.gnu.org> | 2008-01-03 09:35:04 +0000 |
commit | e0658eda3cfe217aa1cf8548642ef99490ef0b27 (patch) | |
tree | ea49403f80c5d0fc80e878e9940c64c8c3c9d476 /gcc/ada/init.c | |
parent | 2092ee7d08be8897d85309fbffc395602e67a3fd (diff) | |
download | gcc-e0658eda3cfe217aa1cf8548642ef99490ef0b27.zip gcc-e0658eda3cfe217aa1cf8548642ef99490ef0b27.tar.gz gcc-e0658eda3cfe217aa1cf8548642ef99490ef0b27.tar.bz2 |
re PR ada/34647 (Ada runtime includes unsafe calls to mktemp and tmpname on OpenBSD)
2008-01-03 Tero Koskinen <tero.koskinen@iki.fi>
gcc/ada/
PR ada/34647
* adaint.c (__gnat_open_new_temp, __gnat_tmp_name): Use mkstemp()
on OpenBSD as is done on other BSD systems.
PR ada/34645
* sysdep.c (__gnat_ttyname, getc_immediate_nowait,
getc_immediate_common): Treat OpenBSD as FreeBSD regarding immediate
I/O.
PR ada/34644
* env.c (__gnat_clearenv): Treat OpenBSD as other BSD systems missing
clearenv().
PR ada/34646
* init.c (__gnat_error_handler, __gnat_install_handler,
__gnat_init_float): Define for OpenBSD.
* initialize.c (__gnat_initialize): Define for OpenBSD.
From-SVN: r131301
Diffstat (limited to 'gcc/ada/init.c')
-rw-r--r-- | gcc/ada/init.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/gcc/ada/init.c b/gcc/ada/init.c index fdfd31a..caf3adc 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -1902,6 +1902,69 @@ __gnat_install_handler(void) __gnat_handler_installed = 1; } +/*******************/ +/* OpenBSD Section */ +/*******************/ + +#elif defined(__OpenBSD__) + +#include <signal.h> +#include <unistd.h> + +static void +__gnat_error_handler (int sig) +{ + struct Exception_Data *exception; + const char *msg; + + switch(sig) + { + case SIGFPE: + exception = &constraint_error; + msg = "SIGFPE"; + break; + case SIGILL: + exception = &constraint_error; + msg = "SIGILL"; + break; + case SIGSEGV: + exception = &storage_error; + msg = "stack overflow or erroneous memory access"; + break; + case SIGBUS: + exception = &constraint_error; + msg = "SIGBUS"; + break; + default: + exception = &program_error; + msg = "unhandled signal"; + } + + Raise_From_Signal_Handler(exception, msg); +} + +void +__gnat_install_handler(void) +{ + struct sigaction act; + + act.sa_handler = __gnat_error_handler; + act.sa_flags = SA_NODEFER | SA_RESTART; + sigemptyset (&act.sa_mask); + + /* Do not install handlers if interrupt state is "System" */ + if (__gnat_get_interrupt_state (SIGFPE) != 's') + sigaction (SIGFPE, &act, NULL); + if (__gnat_get_interrupt_state (SIGILL) != 's') + sigaction (SIGILL, &act, NULL); + if (__gnat_get_interrupt_state (SIGSEGV) != 's') + sigaction (SIGSEGV, &act, NULL); + if (__gnat_get_interrupt_state (SIGBUS) != 's') + sigaction (SIGBUS, &act, NULL); + + __gnat_handler_installed = 1; +} + #else /* For all other versions of GNAT, the handler does nothing */ @@ -1927,7 +1990,8 @@ __gnat_install_handler (void) WIN32 and could be used under OS/2 */ #if defined (_WIN32) || defined (__INTERIX) || defined (__EMX__) \ - || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) + || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) \ + || defined (__OpenBSD__) #define HAVE_GNAT_INIT_FLOAT |