From: Andrew Cagney <ac131313@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [patch/rfc] align_up, align_down
Date: Fri, 19 Sep 2003 16:24:00 -0000 [thread overview]
Message-ID: <3F6B2DA4.1080306@redhat.com> (raw)
In-Reply-To: <3F6227D6.3040300@redhat.com>
> 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 <cagney@redhat.com>
>
> * 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.
prev parent reply other threads:[~2003-09-19 16:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-12 20:09 Andrew Cagney
2003-09-12 20:46 ` Kevin Buettner
2003-09-15 3:21 ` Jim Blandy
2003-09-19 16:24 ` Andrew Cagney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F6B2DA4.1080306@redhat.com \
--to=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox