Memory alignment on i386

Jay Monkman jtm-list-rtems at smoothsmoothie.com
Fri Aug 27 18:26:50 UTC 2004


On Fri, Aug 27, 2004 at 12:28:08PM -0400, CamiloAlejo at netscape.net wrote:
> Hello,
> 
> I'm using rtems 4.6 with pc486 BSP. As far as I can see, the memory is byte-aligned, but I would like to change it to dword-aligned.

What exactly do you want aligned? You don't really mean you want
_every_ variable 32-bit aligned, do you?

You can specify the alignment of particular variables using gcc's
__attribute__ keyword.
   int i        __attribute__(( aligned(4) ));
   struct foo   __attribute__(( aligned(4) ));

You can pass -malign-double on gcc's command line. Here's what the
documention says about it:
     Control whether GCC aligns `double', `long double', and `long
     long' variables on a two word boundary or a one word boundary.
     Aligning `double' variables on a two word boundary will produce
     code that runs somewhat faster on a `Pentium' at the expense of
     more memory.

     *Warning:* if you use the `-malign-double' switch, structures
     containing the above types will be aligned differently than the
     published application binary interface specifications for the 386
     and will not be binary compatible with structures in code
     compiled without that switch.

-malign-double is x86 specific.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.rtems.org/pipermail/users/attachments/20040827/1a6f753e/attachment-0001.bin>


More information about the users mailing list