aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/init.c
diff options
context:
space:
mode:
authorDoug Rupp <rupp@adacore.com>2024-02-03 04:18:51 -0800
committerMarc Poulhiès <poulhies@adacore.com>2024-06-20 10:50:56 +0200
commit980fddd8d90c97d44074021c6121a8d134e6c88c (patch)
treefd29c4707f79cc1267d0210bb5f060a9656b9ea2 /gcc/ada/init.c
parent3a16f19777f882f98b6d901a81157779e898f636 (diff)
downloadgcc-980fddd8d90c97d44074021c6121a8d134e6c88c.zip
gcc-980fddd8d90c97d44074021c6121a8d134e6c88c.tar.gz
gcc-980fddd8d90c97d44074021c6121a8d134e6c88c.tar.bz2
ada: New pragma to default all interrupts to system.
New pragma Interrupts_System_By_Default defaults all interrupts/signals to system (which will inhibit the installation of default signal handlers). Note this changes the ALI format: it optionally adds an identifier to the 'P' line (similar to pragma Unreserve_All_Interrupts). As per comment in lib-writ spec regarding new modifiers, adding modifiers to the P line is always safe. Also note this does not introduce a bootstrap problem because the compiler and binder do not set the underlying _gl global nor do they use this pragma. gcc/ada/ * ali.ads (Interrupts_Default_To_System): New boolean. (Interrupts_Default_To_System_Specified): New boolean. * ali.adb (Interrupts_Default_To_System_Specified): Initialize. (Interrupts_Default_To_System): Initialize. (Scan_ALI): Processing for "ID". * bindgen.adb: Coallesce comments on interrupt settings to ... (Gen_Adainit): Import Interrupts_Default_To_System flag and set if pragma specified. (Gen_Output_File_Ada): Generate Local_Interrupt_States according to pragma. * init.c: ... here. [vxworks] (__gnat_install_handler): Test for interrupt_state. (__gl_interrupts_default_to_system): New global flag. (__gnat_get_interrupt_State): return interrupt state according to new global flag. * lib-writ.ads: Document "ID". * lib-writ.adb: Write out "ID". * opt.ads (Interrupts_System_By_Default): New boolean, defaulted to False. * par-prag.adb (Pragma_Interrupts_System_By_Default): New. * sem_prag.adb (Pragma_Interrupts_System_By_Default): Handle it. (Pragma_Interrupts_System_By_Default): Default it. * snames.ads-tmpl (Name_Interrupts_System_By_Default): New name. (Pragma_Interrupts_System_By_Default): New * libgnarl/s-intman__posix.adb (Initialize): Ensure the Keep_Unmasked signal is sigset-able. * doc/gnat_rm/implementation_defined_pragmas.rst: Document pragma Interrupts_System_By_Default. * doc/gnat_ugn/the_gnat_compilation_model.rst (Configuration pragmas): Add Interrupts_System_By_Default. (Partition-Wide Settings): Mention pragma Interrupts_System_By_Default. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
Diffstat (limited to 'gcc/ada/init.c')
-rw-r--r--gcc/ada/init.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/gcc/ada/init.c b/gcc/ada/init.c
index 7cf7747..acb8c7c 100644
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -122,6 +122,7 @@ int __gl_leap_seconds_support = 0;
int __gl_canonical_streams = 0;
char *__gl_bind_env_addr = NULL;
int __gl_xdr_stream = 0;
+int __gl_interrupts_default_to_system = 0;
/* This value is not used anymore, but kept for bootstrapping purpose. */
int __gl_zero_cost_exceptions = 0;
@@ -148,20 +149,25 @@ int __gnat_inside_elab_final_code = 0;
char __gnat_get_interrupt_state (int);
/* This routine is called from the runtime as needed to determine the state
- of an interrupt, as set by an Interrupt_State pragma appearing anywhere
- in the current partition. The input argument is the interrupt number,
- and the result is one of the following:
+ of an interrupt, as set by an Interrupt_State pragma or an
+ Interrupts_System_By_Default pragma appearing anywhere in the current
+ partition. The input argument is the interrupt number, and the result
+ is one of the following:
- 'n' this interrupt not set by any Interrupt_State pragma
- 'u' Interrupt_State pragma set state to User
- 'r' Interrupt_State pragma set state to Runtime
- 's' Interrupt_State pragma set state to System */
+ 'u' if Interrupt_State pragma set to User;
+ 'r' if Interrupt_State pragma set to Runtime;
+ 's' if Interrupt_State pragma set to System or
+ Interrupts_System_By_Default in effect; otherwise
+ 'n' (there is no Interrupt_State pragma and no request for a default).
+
+ See pragma Interrupt_State documentation for a description
+ of the effect and meaning of states User, Runtime, and System. */
char
__gnat_get_interrupt_state (int intrup)
{
if (intrup >= __gl_num_interrupt_states)
- return 'n';
+ return (__gl_interrupts_default_to_system ? 's' : 'n');
else
return __gl_interrupt_states [intrup];
}
@@ -2094,10 +2100,14 @@ __gnat_install_handler (void)
/* For VxWorks, install all signal handlers, since pragma Interrupt_State
applies to vectored hardware interrupts, not signals. */
- sigaction (SIGFPE, &act, NULL);
- sigaction (SIGILL, &act, NULL);
- sigaction (SIGSEGV, &act, NULL);
- sigaction (SIGBUS, &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 (SIGSEGV) != 's')
+ sigaction (SIGSEGV, &act, NULL);
+ if (__gnat_get_interrupt_state (SIGBUS) != 's')
+ sigaction (SIGBUS, &act, NULL);
#if defined(__leon__) && defined(_WRS_KERNEL)
/* Specific to the LEON VxWorks kernel run-time library */