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?
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.