From patchwork Thu Jul 28 13:35:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 107253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1E399B6F18 for ; Thu, 28 Jul 2011 23:35:48 +1000 (EST) Received: (qmail 6708 invoked by alias); 28 Jul 2011 13:35:46 -0000 Received: (qmail 6571 invoked by uid 22791); 28 Jul 2011 13:35:45 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Jul 2011 13:35:31 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 48A647DB; Thu, 28 Jul 2011 15:35:30 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id bj0N+ma9n-gx; Thu, 28 Jul 2011 15:35:28 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 290D17DA; Thu, 28 Jul 2011 15:35:28 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id p6SDZRLQ007385; Thu, 28 Jul 2011 15:35:27 +0200 (MEST) From: Rainer Orth To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org, Arnaud Charlet Subject: Re: Allow IRIX Ada bootstrap with C++ References: <201107252334.26844.ebotcazou@adacore.com> <201107261122.29561.ebotcazou@adacore.com> Date: Thu, 28 Jul 2011 15:35:27 +0200 In-Reply-To: <201107261122.29561.ebotcazou@adacore.com> (Eric Botcazou's message of "Tue, 26 Jul 2011 11:22:29 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Eric Botcazou 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 * init.c (__gnat_error_handler): Cast reason to int. (__gnat_install_handler): Explain sa_sigaction use. 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;