From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26470 invoked by alias); 12 Sep 2003 20:46:47 -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 26463 invoked from network); 12 Sep 2003 20:46:47 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 12 Sep 2003 20:46:47 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h8CKkjl25716 for ; Fri, 12 Sep 2003 16:46:46 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h8CKkje04101 for ; Fri, 12 Sep 2003 16:46:45 -0400 Received: from localhost.localdomain (vpn50-21.rdu.redhat.com [172.16.50.21]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id h8CKkixI018866; Fri, 12 Sep 2003 16:46:44 -0400 Received: (from kev@localhost) by localhost.localdomain (8.11.6/8.11.6) id h8CKkdM00730; Fri, 12 Sep 2003 13:46:39 -0700 Date: Fri, 12 Sep 2003 20:46:00 -0000 From: Kevin Buettner Message-Id: <1030912204638.ZM729@localhost.localdomain> In-Reply-To: Andrew Cagney "[patch/rfc] align_up, align_down" (Sep 12, 4:08pm) References: <3F6227D6.3040300@redhat.com> To: Andrew Cagney , gdb-patches@sources.redhat.com Subject: Re: [patch/rfc] align_up, align_down MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-09/txt/msg00275.txt.bz2 On Sep 12, 4:08pm, Andrew Cagney wrote: > 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? Looks good to me... Kevin