From: Olivier Hainque <[email protected]>

For non tasking programs, the Android ports currently fail to account
for pragma Interrupt_State on various signals.

gcc/ada/ChangeLog:

        * init.c (__gnat_install_handler, __ANDROID__): Guard calls
        to sigaction with a test for a possible 's' (System) interrupt
        state.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/init.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/init.c b/gcc/ada/init.c
index 551d4b1a94c..31a8f781178 100644
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -2943,12 +2943,21 @@ __gnat_install_handler (void)
   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);
+  if (__gnat_get_interrupt_state (SIGABRT) != 's')
+    sigaction (SIGABRT, &act, NULL);
+
+  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 (SIGBUS) != 's')
+    sigaction (SIGBUS,  &act, NULL);
+
   act.sa_flags |= SA_ONSTACK;
-  sigaction (SIGSEGV, &act, NULL);
+  if (__gnat_get_interrupt_state (SIGSEGV) != 's')
+    sigaction (SIGSEGV, &act, NULL);
 
   __gnat_handler_installed = 1;
 }
-- 
2.53.0

Reply via email to