From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10837 invoked by alias); 28 Nov 2002 13:52:55 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10793 invoked from network); 28 Nov 2002 13:52:54 -0000 Received: from unknown (HELO fw-maid.maidenhead.arm.com) (194.201.77.34) by sources.redhat.com with SMTP; 28 Nov 2002 13:52:54 -0000 Received: by fw-maid.maidenhead.arm.com; id NAA22168; Thu, 28 Nov 2002 13:46:11 GMT Received: from mhsun1.maidenhead.arm.com(192.168.2.10) by fw-maid.maidenhead.arm.com via smap (V5.0) id xma022124; Thu, 28 Nov 02 13:46:08 GMT Received: from mhpc6.arm.com (mhpc6 [192.168.2.53]) by mhsun1.maidenhead.arm.com (8.9.3/8.9.3) with ESMTP id LAA18393; Thu, 28 Nov 2002 11:07:11 GMT Message-Id: <4.3.2.7.2.20021128105650.01e91010@mhsun1.maidenhead.arm.com> X-Sender: kwalker@mhsun1.maidenhead.arm.com Date: Thu, 28 Nov 2002 05:52:00 -0000 To: Richard.Earnshaw@arm.com, Andreas Schwab From: Keith Walker Subject: Re: [rfa?] Add frame_align(); Was: ARM stack alignment on hand called functions Cc: gdb-patches@sources.redhat.com In-Reply-To: <200211281040.gASAeCC03374@pc960.cambridge.arm.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-SW-Source: 2002-11/txt/msg00712.txt.bz2 At 10:40 28/11/2002 +0000, Richard Earnshaw wrote: > > Richard Earnshaw writes: > > > > |> > +/* Ensure that the ARM's stack pointer has the correct alignment > for a > > |> > + new frame. */ > > |> > +static CORE_ADDR > > |> > +arm_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) > > |> > +{ > > |> > + return (addr & -16); > > |> > +} > > |> > > |> Yuck, two's complement assumption. > > > > No, -16 is implicitly cast to bfd_vma, which is unsigned, and this > > operation is completely defined independent of the representation of > > signed integers. > >Hmm, strictly speaking you are correct. I don't have to like it though, >and it means that the code is heavily dependent on the non-obvious fact >that addr is an unsigned type to get the correct behaviour (if bfd_vma >were to be changed to a signed type then this code would quietly break). > >So I'll change my comment to: > >Yuck, implicit cast of negative number to unsigned. I notice that the h8300-tdep.c file defines some macros to do this sort of rounding ... round_up() and round_down(). As aligning addresses is a reasonable common thing to do maybe these macros should be moved to a more generic place and used whenever such rounding is required. It doesn't fix the implicit cast issue, but would at least make finding where such alignment occurs easier. Keith