From patchwork Mon Oct 29 11:34:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 194976 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 529012C0084 for ; Mon, 29 Oct 2012 22:34:18 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352115259; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=d2xEas3hgXsWzLJl1Cbz 2DM6mqg=; b=TswL4dvRnNiaTSuFYJofIfZcKlVbI8A+XtuDb/E6S9ay37UBbNFJ kDdgdXSystAaX+3ZSdNvSd5p3CAZt+2H2IQsNLBUUEV/0VKf+MeDd10GnmUxIWwF JQep5IzUejqdgOfkWqEDzRFG4xl/okMj7wAVYZgoHwPv2Tfoj/sbi/Y= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=BF1cWombaJNaM6lGTGBJtzR12X2EWNQ54vfVwJjmRuwGgs2hoUsBEbNoYiFqJ0 kJwPt6uD1dzPgmLjrxZHAm/Cpq8k62TiaFMaF3qkpYID4VgkuNkmdFmM/t5k1h7H 8EPeSlsXPMX5d0EGbH4fRqYgYgy/cajbvNkQyE4kMUUT0=; Received: (qmail 23213 invoked by alias); 29 Oct 2012 11:34:13 -0000 Received: (qmail 22915 invoked by uid 22791); 29 Oct 2012 11:34:12 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Oct 2012 11:34:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8AF5A1C7BE7; Mon, 29 Oct 2012 07:34:02 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id y+tCFeJqUoTg; Mon, 29 Oct 2012 07:34:02 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 6F12A1C7B97; Mon, 29 Oct 2012 07:34:02 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 6D8CB3FF09; Mon, 29 Oct 2012 07:34:02 -0400 (EDT) Date: Mon, 29 Oct 2012 07:34:02 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix thinko in bignum allocation routine Message-ID: <20121029113402.GA31398@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This makes the new support for extended overflow checking work on big-endian platforms as well by fixing a thinko in the allocation routine of bignums. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-10-29 Eric Botcazou * s-bignum.adb (Allocate_Bignum): Use the exact layout of Bignum_Data for the overlay. Index: s-bignum.adb =================================================================== --- s-bignum.adb (revision 192933) +++ s-bignum.adb (working copy) @@ -233,14 +233,27 @@ pragma Import (Ada, BD); -- Expose a writable view of discriminant BD.Len so that we can - -- initialize it. + -- initialize it. We need to use the exact layout of the record + -- for the overlay to shield ourselves from endianness issues. - BL : Length; - for BL'Address use BD.Len'Address; - pragma Import (Ada, BL); + type Bignum_Data_Header is record + Len : Length; + Neg : Boolean; + end record; + for Bignum_Data_Header use record + Len at 0 range 0 .. 23; + Neg at 3 range 0 .. 7; + end record; + + BDH : Bignum_Data_Header; + for BDH'Address use BD'Address; + pragma Import (Ada, BDH); + + pragma Assert (BDH.Len'Size = BD.Len'Size); + begin - BL := Len; + BDH.Len := Len; return B; end; end if;