From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32459 invoked by alias); 19 Sep 2003 16:24:08 -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 32452 invoked from network); 19 Sep 2003 16:24:06 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 19 Sep 2003 16:24:06 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 128682B89 for ; Fri, 19 Sep 2003 12:24:05 -0400 (EDT) Message-ID: <3F6B2DA4.1080306@redhat.com> Date: Fri, 19 Sep 2003 16:24:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Re: [patch/rfc] align_up, align_down References: <3F6227D6.3040300@redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-09/txt/msg00411.txt.bz2 > Hello, > > This patch introduces two utility functions: > > align_up (v, n); > align_down (v, n); > > for [re]aligning addresses vis: > > + addr = align_up (addr, 8); -- VALUE needs 8 byte alignment > + write_memory (addr, value, len); > + addr += len; > > + sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned > + write_memory (sp, value, len); > > It then goes through and replaces all occurances of round_up / round_down and align_up / align_down with these globals. > > You'll notice that I chose align_XXX rather than round_XXX. I think this better reflects the intended usage. I've noticed a lot of code doing: > > write_memory (addr, data, len); > addr += round_up (len, 16); > > instead of: > > addr = align_up (addr, 16); > write_memory (addr, data, len); > addr += len; > > as the former may not result in ADDR having the required alignment. The PPC SVr4 Altivec ABI, for instance, switches between 8 and 16 byte alignment making the former code very wrong. > > anyway, thoughts? All positive. > I'll pick it up in a week, I've committed it. Andrew > 2003-09-12 Andrew Cagney > > * utils.c (align_up, align_down): New functions. > * defs.h (align_up, align_down): Declare. > * ppc-sysv-tdep.c (align_up, align_down): Delete functions. > * s390-tdep.c: Replace "round_up" and "round_down" with "align_up" > and "align_down". > (round_up, round_down): Delete functions. > * mips-tdep.c: Replace ROUND_UP and ROUND_DOWN with "align_up" and > "align_down". > (ROUND_DOWN, ROUND_UP): Delete macros. > (mips_dump_tdep): Do not print "ROUND_UP" or "ROUND_DOWN". > * h8300-tdep.c: Replace "round_up" and "round_down" with > "align_up" and "align_down". > (round_up, round_down): Delete macros. > * frv-tdep.c: Replace ROUND_UP and ROUND_DOWN with "align_up" and > "align_down". > (ROUND_UP, ROUND_DOWN): Delete macros.