From: Kevin Buettner <kevinb@redhat.com>
To: Andrew Cagney <ac131313@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [patch/rfc] align_up, align_down
Date: Fri, 12 Sep 2003 20:46:00 -0000 [thread overview]
Message-ID: <1030912204638.ZM729@localhost.localdomain> (raw)
In-Reply-To: Andrew Cagney <ac131313@redhat.com> "[patch/rfc] align_up, align_down" (Sep 12, 4:08pm)
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
next prev parent reply other threads:[~2003-09-12 20:46 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 [this message]
2003-09-15 3:21 ` Jim Blandy
2003-09-19 16:24 ` Andrew Cagney
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=1030912204638.ZM729@localhost.localdomain \
--to=kevinb@redhat.com \
--cc=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