diff mbox

Allow IRIX Ada bootstrap with C++

Message ID yddwrf2bk9s.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth July 28, 2011, 1:35 p.m. UTC
Eric Botcazou <ebotcazou@adacore.com> writes:

>> That's what I did in my last patch, but without SA_SIGINFO set.  This
>> doesn't work since the additional args passed in the sa_handler case are
>> not in any prototype, to g++ rightly complains (and this is an
>> implementation detail I'd not rely upon if it can be avoided).
>
> OK, I see, so there is a single prototype for the 2 variants with 3 args.

Right.  Even if I can cope with that, I haven't been able to extract all
the required info (pc, gregs, fpregs) from ucontext_t/mcontext_t with
SA_SIGINFO set.  Besides, it doesn't seem possible to distinguish
between the two cases (sa_handler/sa_sigaction).  Therefore I went back
for the following hack, adding comments to explain why it is necessary.

Bootstrapped without regressions on mips-sgi-irix6.5, all signal
handling failures introduced by my previous patch are gone again.

Ok for mainline?

	Rainer


2011-07-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* init.c (__gnat_error_handler): Cast reason to int.
	(__gnat_install_handler): Explain sa_sigaction use.

Comments

Arnaud Charlet July 28, 2011, 1:37 p.m. UTC | #1
> Bootstrapped without regressions on mips-sgi-irix6.5, all signal
> handling failures introduced by my previous patch are gone again.
> 
> Ok for mainline?

OK.
Andreas Schwab July 28, 2011, 1:52 p.m. UTC | #2
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> diff --git a/gcc/ada/init.c b/gcc/ada/init.c
> --- a/gcc/ada/init.c
> +++ b/gcc/ada/init.c
> @@ -787,7 +787,11 @@ extern struct Exception_Data _abort_sign
>  static void
>  __gnat_error_handler (int sig, siginfo_t *reason, void *uc ATTRIBUTE_UNUSED)
>  {
> -  int code = reason == NULL ? 0 : reason->si_code;
> +  /* This handler is installed with SA_SIGINFO cleared, but there's no
> +     prototype for the resulting alternative three-argument form, so we
> +     have to hack around this by casting reason to the int actually
> +     passed.  */
> +  int code = (int) reason;
>    struct Exception_Data *exception;
>    const char *msg;
>  
> @@ -872,7 +876,11 @@ __gnat_install_handler (void)
>  
>    /* Setup 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!  */
> +     signal that might cause a scheduling event!
> +
> +     The handler is installed with SA_SIGINFO cleared, but there's no
> +     C++ prototype for the three-argument form, so fake it by using
> +     sa_sigaction and casting the arguments instead.  */
>  
>    act.sa_sigaction = __gnat_error_handler;
>    act.sa_flags = SA_NODEFER + SA_RESTART;

Wouldn't it be cleanest to adjust the prototype of __gnat_error_handler
to reality, and cast it when assigning to sa_handler (not sa_sigaction,
which is only valid if SA_SIGINFO is set)?

Andreas.
Rainer Orth July 29, 2011, 9:37 a.m. UTC | #3
Andreas,

> Wouldn't it be cleanest to adjust the prototype of __gnat_error_handler
> to reality, and cast it when assigning to sa_handler (not sa_sigaction,
> which is only valid if SA_SIGINFO is set)?

probably, provided g++ accepts that.  I'd have to run two bootstraps (C
and C++) to check this.

	Rainer
diff mbox

Patch

diff --git a/gcc/ada/init.c b/gcc/ada/init.c
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -787,7 +787,11 @@  extern struct Exception_Data _abort_sign
 static void
 __gnat_error_handler (int sig, siginfo_t *reason, void *uc ATTRIBUTE_UNUSED)
 {
-  int code = reason == NULL ? 0 : reason->si_code;
+  /* This handler is installed with SA_SIGINFO cleared, but there's no
+     prototype for the resulting alternative three-argument form, so we
+     have to hack around this by casting reason to the int actually
+     passed.  */
+  int code = (int) reason;
   struct Exception_Data *exception;
   const char *msg;
 
@@ -872,7 +876,11 @@  __gnat_install_handler (void)
 
   /* Setup 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!  */
+     signal that might cause a scheduling event!
+
+     The handler is installed with SA_SIGINFO cleared, but there's no
+     C++ prototype for the three-argument form, so fake it by using
+     sa_sigaction and casting the arguments instead.  */
 
   act.sa_sigaction = __gnat_error_handler;
   act.sa_flags = SA_NODEFER + SA_RESTART;