summaryrefslogtreecommitdiff
path: root/gcc/ada/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/init.c')
-rw-r--r--gcc/ada/init.c176
1 files changed, 86 insertions, 90 deletions
diff --git a/gcc/ada/init.c b/gcc/ada/init.c
index 0637b781ad1..f5888b0f995 100644
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -4,11 +4,11 @@
* *
* I N I T *
* *
- * $Revision: 1.7 $
+ * $Revision$
* *
* C Implementation File *
* *
- * Copyright (C) 1992-2001 Free Software Foundation, Inc. *
+ * Copyright (C) 1992-2002 Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
@@ -51,6 +51,9 @@
#include "tconfig.h"
#include "tsystem.h"
#include <sys/stat.h>
+
+/* We don't have libiberty, so us malloc. */
+#define xmalloc(S) malloc (S)
#else
#include "config.h"
#include "system.h"
@@ -94,14 +97,16 @@ extern void Propagate_Signal_Exception
PARAMS ((struct Machine_State *, struct Exception_Data *, const char *));
/* Copies of global values computed by the binder */
-int __gl_main_priority = -1;
-int __gl_time_slice_val = -1;
-char __gl_wc_encoding = 'n';
-char __gl_locking_policy = ' ';
-char __gl_queuing_policy = ' ';
-char __gl_task_dispatching_policy = ' ';
-int __gl_unreserve_all_interrupts = 0;
-int __gl_exception_tracebacks = 0;
+int __gl_main_priority = -1;
+int __gl_time_slice_val = -1;
+char __gl_wc_encoding = 'n';
+char __gl_locking_policy = ' ';
+char __gl_queuing_policy = ' ';
+char *__gl_restrictions = 0;
+char __gl_task_dispatching_policy = ' ';
+int __gl_unreserve_all_interrupts = 0;
+int __gl_exception_tracebacks = 0;
+int __gl_zero_cost_exceptions = 0;
/* Indication of whether synchronous signal handler has already been
installed by a previous call to adainit */
@@ -126,14 +131,15 @@ int __gnat_handler_installed = 0;
void
__gnat_set_globals (main_priority, time_slice_val, wc_encoding, locking_policy,
- queuing_policy, task_dispatching_policy, adafinal_ptr,
- unreserve_all_interrupts, exception_tracebacks)
+ queuing_policy, task_dispatching_policy, restrictions,
+ unreserve_all_interrupts, exception_tracebacks,
+ zero_cost_exceptions)
int main_priority;
int time_slice_val;
- int wc_encoding;
- int locking_policy, queuing_policy, task_dispatching_policy;
- void (*adafinal_ptr) PARAMS ((void)) ATTRIBUTE_UNUSED;
- int unreserve_all_interrupts, exception_tracebacks;
+ char wc_encoding;
+ char locking_policy, queuing_policy, task_dispatching_policy;
+ char *restrictions;
+ int unreserve_all_interrupts, exception_tracebacks, zero_cost_exceptions;
{
static int already_called = 0;
@@ -163,14 +169,14 @@ __gnat_set_globals (main_priority, time_slice_val, wc_encoding, locking_policy,
if (already_called)
{
- if (__gl_locking_policy != locking_policy ||
- __gl_queuing_policy != queuing_policy ||
- __gl_task_dispatching_policy != task_dispatching_policy ||
- __gl_unreserve_all_interrupts != unreserve_all_interrupts ||
- __gl_exception_tracebacks != exception_tracebacks)
- {
- __gnat_raise_program_error (__FILE__, __LINE__);
- }
+ if (__gl_locking_policy != locking_policy
+ || __gl_queuing_policy != queuing_policy
+ || __gl_task_dispatching_policy != task_dispatching_policy
+ || __gl_unreserve_all_interrupts != unreserve_all_interrupts
+ || __gl_exception_tracebacks != exception_tracebacks
+ || __gl_zero_cost_exceptions != zero_cost_exceptions)
+ __gnat_raise_program_error (__FILE__, __LINE__);
+
return;
}
already_called = 1;
@@ -180,9 +186,25 @@ __gnat_set_globals (main_priority, time_slice_val, wc_encoding, locking_policy,
__gl_wc_encoding = wc_encoding;
__gl_locking_policy = locking_policy;
__gl_queuing_policy = queuing_policy;
+ __gl_restrictions = restrictions;
__gl_task_dispatching_policy = task_dispatching_policy;
__gl_unreserve_all_interrupts = unreserve_all_interrupts;
__gl_exception_tracebacks = exception_tracebacks;
+
+ /* ??? __gl_zero_cost_exceptions is new in 3.15 and is referenced from
+ a-except.adb, which is also part of the compiler sources. Since the
+ compiler is built with an older release of GNAT, the call generated by
+ the old binder to this function does not provide any value for the
+ corresponding argument, so the global has to be initialized in some
+ reasonable other way. This could be removed as soon as the next major
+ release is out. */
+
+#ifdef IN_RTS
+ __gl_zero_cost_exceptions = zero_cost_exceptions;
+#else
+ __gl_zero_cost_exceptions = 0;
+ /* We never build the compiler to run in ZCX mode currently anyway. */
+#endif
}
/*********************/
@@ -268,13 +290,9 @@ __gnat_install_handler ()
(void) sigaction (SIGABRT, &act, NULL);
(void) sigaction (SIGFPE, &act, NULL);
-
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
__gnat_handler_installed = 1;
}
@@ -393,13 +411,9 @@ __gnat_install_handler ()
(void) sigaction (SIGABRT, &act, NULL);
(void) sigaction (SIGFPE, &act, NULL);
-
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
__gnat_handler_installed = 1;
}
@@ -491,12 +505,14 @@ __gnat_install_handler ()
handled properly, avoiding a SEGV generation from stack usage by the
handler itself. */
- static char handler_stack [SIGSTKSZ];
+ static char handler_stack[SIGSTKSZ*2];
+ /* SIGSTKSZ appeared to be "short" for the needs in some contexts
+ (e.g. experiments with GCC ZCX exceptions). */
stack_t stack;
stack.ss_sp = handler_stack;
- stack.ss_size = SIGSTKSZ;
+ stack.ss_size = sizeof (handler_stack);
stack.ss_flags = 0;
(void) sigaltstack (&stack, NULL);
@@ -507,13 +523,10 @@ __gnat_install_handler ()
(void) sigaction (SIGABRT, &act, NULL);
(void) sigaction (SIGFPE, &act, NULL);
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
__gnat_handler_installed = 1;
}
@@ -654,13 +667,10 @@ __gnat_install_handler ()
(void) sigaction (SIGABRT, &act, NULL);
(void) sigaction (SIGFPE, &act, NULL);
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
__gnat_handler_installed = 1;
}
@@ -878,10 +888,9 @@ __gnat_install_handler ()
/* (void) sigaction (SIGABRT, &act, NULL); */
/* (void) sigaction (SIGFPE, &act, NULL); */
/* (void) sigaction (SIGBUS, &act, NULL); */
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGSEGV, &act, NULL);
- }
+
+ (void) sigaction (SIGSEGV, &act, NULL);
+
__gnat_handler_installed = 1;
}
@@ -1061,13 +1070,9 @@ __gnat_install_handler ()
(void) sigaction (SIGABRT, &act, NULL);
(void) sigaction (SIGFPE, &act, NULL);
-
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
(void) sigaction (SIGADAABORT, &act, NULL);
__gnat_handler_installed = 1;
}
@@ -1170,13 +1175,10 @@ __gnat_install_handler ()
(void) sigemptyset (&act.sa_mask);
(void) sigaction (SIGABRT, &act, NULL);
+ (void) sigaction (SIGFPE, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGFPE, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
__gnat_handler_installed = 1;
}
@@ -1256,13 +1258,10 @@ __gnat_install_handler ()
(void) sigaction (SIGABRT, &act, NULL);
(void) sigaction (SIGFPE, &act, NULL);
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
__gnat_handler_installed = 1;
}
@@ -1317,21 +1316,21 @@ extern struct Exception_Data *Coded_Exception (int);
struct descriptor_s {unsigned short len, mbz; char *adr; };
-static long __gnat_error_handler PARAMS ((int *, void *));
+long __gnat_error_handler PARAMS ((int *, void *));
-static long
+long
__gnat_error_handler (sigargs, mechargs)
int *sigargs;
void *mechargs;
{
struct Exception_Data *exception = 0;
char *msg = "";
- char message [256];
+ char message[256];
long prvhnd;
struct descriptor_s msgdesc;
int msg_flag = 0x000f; /* 1 bit for each of the four message parts */
unsigned short outlen;
- char curr_icb [544];
+ char curr_icb[544];
long curr_invo_handle;
long *mstate;
@@ -1359,20 +1358,20 @@ __gnat_error_handler (sigargs, mechargs)
#ifdef IN_RTS
/* See if it's an imported exception. Mask off severity bits. */
- exception = Coded_Exception (sigargs [1] & 0xfffffff8);
+ exception = Coded_Exception (sigargs[1] & 0xfffffff8);
if (exception)
{
msgdesc.len = 256;
msgdesc.mbz = 0;
msgdesc.adr = message;
SYS$GETMSG (sigargs[1], &outlen, &msgdesc, msg_flag, 0);
- message [outlen] = 0;
+ message[outlen] = 0;
msg = message;
exception->Name_Length = 19;
/* The full name really should be get sys$getmsg returns. ??? */
exception->Full_Name = "IMPORTED_EXCEPTION";
- exception->Import_Code = sigargs [1] & 0xfffffff8;
+ exception->Import_Code = sigargs[1] & 0xfffffff8;
}
#endif
@@ -1440,7 +1439,7 @@ __gnat_error_handler (sigargs, mechargs)
msgdesc.mbz = 0;
msgdesc.adr = message;
SYS$GETMSG (sigargs[1], &outlen, &msgdesc, msg_flag, 0);
- message [outlen] = 0;
+ message[outlen] = 0;
msg = message;
break;
}
@@ -1463,7 +1462,7 @@ __gnat_install_handler ()
long prvhnd;
char *c;
- c = (char *) malloc (2049);
+ c = (char *) xmalloc (2049);
__gnat_error_prehandler_stack = &c[2048];
@@ -1593,13 +1592,10 @@ __gnat_install_handler ()
(void) sigemptyset (&act.sa_mask);
(void) sigaction (SIGFPE, &act, NULL);
+ (void) sigaction (SIGILL, &act, NULL);
+ (void) sigaction (SIGSEGV, &act, NULL);
+ (void) sigaction (SIGBUS, &act, NULL);
- if (__gl_unreserve_all_interrupts == 0)
- {
- (void) sigaction (SIGILL, &act, NULL);
- (void) sigaction (SIGSEGV, &act, NULL);
- (void) sigaction (SIGBUS, &act, NULL);
- }
__gnat_handler_installed = 1;
}