aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/init.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-01-24 15:23:03 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2014-01-24 15:23:03 +0100
commit7610fee82af0217dd376ce0213d195209f72b606 (patch)
tree9c66fd5109d2f7bfc6e07d67646d74a2c885dbf7 /gcc/ada/init.c
parent4a8548473e9241313033cbd0ff3e37ab1f6971fe (diff)
downloadgcc-7610fee82af0217dd376ce0213d195209f72b606.zip
gcc-7610fee82af0217dd376ce0213d195209f72b606.tar.gz
gcc-7610fee82af0217dd376ce0213d195209f72b606.tar.bz2
[multiple changes]
2014-01-24 Doug Rupp <rupp@adacore.com> * init.c: Add a handler section for Android. 2014-01-24 Arnaud Charlet <charlet@adacore.com> * i-cexten.ads (Unsigned_33..64, Unsigned_33..64): New types. 2014-01-24 Ed Schonberg <schonberg@adacore.com> * sem_ch4.adb (Operator_Check): If one operand is a Raise_Expression, set its type to that of the other operand. * sem_res.adb (Resolve_Raise_Expression): new procedure. (Resolve_Actuals): For an actual that is a Raise_Expression, set the type to that of the formal. * sem_type.adb (Find_Unique_Type): If one of the operands is a Raise_Expression, return type of the other operand. 2014-01-24 Ed Schonberg <schonberg@adacore.com> * sem_aggr.adb (Resolve_Record_Aggregate): If a scalar component of the record has a type with a default aspect, and the corresponding aggregate component is initiaized with a box, use the default value in the rewritten aggregate. 2014-01-24 Tristan Gingold <gingold@adacore.com> * s-interr.ads, s-interr.adb, s-interr-hwint.adb, s-interr-vms.adb, s-interr-sigaction.adb, s-interr-dummy.adb (Install_Restricted_Handlers): Add Prio parameter. * exp_ch9.adb (Make_Initialize_Protection): Add Prio parameter to the call to Install_Restricted_Handlers. 2014-01-24 Emmanuel Briot <briot@adacore.com> * prj-nmsc.adb (Check_File): Add protection when the source is not fully initialized. From-SVN: r207033
Diffstat (limited to 'gcc/ada/init.c')
-rw-r--r--gcc/ada/init.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/gcc/ada/init.c b/gcc/ada/init.c
index 7f8b3a3..e943837 100644
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -2320,6 +2320,83 @@ __gnat_install_handler (void)
__gnat_handler_installed = 1;
}
+#elif defined(__ANDROID__)
+
+/*******************/
+/* Android Section */
+/*******************/
+
+#include <signal.h>
+#include <stdlib.h>
+
+static void
+__gnat_error_handler (int sig,
+ siginfo_t *si ATTRIBUTE_UNUSED,
+ void *ucontext ATTRIBUTE_UNUSED)
+{
+ struct Exception_Data *exception;
+ const char *msg;
+
+ switch (sig)
+ {
+ case SIGSEGV:
+ exception = &storage_error;
+ msg = "stack overflow or erroneous memory access";
+ break;
+
+ case SIGBUS:
+ exception = &constraint_error;
+ msg = "SIGBUS";
+ break;
+
+ case SIGFPE:
+ exception = &constraint_error;
+ msg = "SIGFPE";
+ break;
+
+ default:
+ exception = &program_error;
+ msg = "unhandled signal";
+ }
+
+ Raise_From_Signal_Handler (exception, msg);
+}
+
+/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */
+char __gnat_alternate_stack[16 * 1024];
+
+void
+__gnat_install_handler (void)
+{
+ struct sigaction act;
+
+ /* Set up signal handler to map synchronous signals to appropriate
+ exceptions. Make sure that the handler isn't interrupted by another
+ signal that might cause a scheduling event! Also setup an alternate
+ stack region for the handler execution so that stack overflows can be
+ handled properly, avoiding a SEGV generation from stack usage by the
+ handler itself. */
+
+ stack_t stack;
+ stack.ss_sp = __gnat_alternate_stack;
+ stack.ss_size = sizeof (__gnat_alternate_stack);
+ stack.ss_flags = 0;
+ sigaltstack (&stack, NULL);
+
+ act.sa_sigaction = __gnat_error_handler;
+ act.sa_flags = SA_NODEFER | SA_RESTART | SA_SIGINFO;
+ sigemptyset (&act.sa_mask);
+
+ sigaction (SIGABRT, &act, NULL);
+ sigaction (SIGFPE, &act, NULL);
+ sigaction (SIGILL, &act, NULL);
+ sigaction (SIGBUS, &act, NULL);
+ act.sa_flags |= SA_ONSTACK;
+ sigaction (SIGSEGV, &act, NULL);
+
+ __gnat_handler_installed = 1;
+}
+
#else
/* For all other versions of GNAT, the handler does nothing. */