[Ada] Add signal to exception mapping for RTEMS
gcc/ada/ * init.c: Add __gnat_error_handler and __gnat_install_handler for RTEMS.
This commit is contained in:
parent
38df84ae8a
commit
ff46a531c5
1 changed files with 62 additions and 0 deletions
|
@ -2645,6 +2645,68 @@ __gnat_install_handler (void)
|
|||
__gnat_handler_installed = 1;
|
||||
}
|
||||
|
||||
/*****************/
|
||||
/* RTEMS Section */
|
||||
/*****************/
|
||||
|
||||
#elif defined(__rtems__)
|
||||
|
||||
#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 = "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;
|
||||
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;
|
||||
}
|
||||
|
||||
#elif defined (__DJGPP__)
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue