|Re: alignment of data-types firstname.lastname@example.org (Glen Herrmannsfeldt) (2003-02-06)|
|RE: alignment of data-types email@example.com (Onder Karpat) (2003-02-11)|
|From:||Onder Karpat <firstname.lastname@example.org>|
|Date:||11 Feb 2003 01:14:29 -0500|
|Posted-Date:||11 Feb 2003 01:14:29 EST|
Alignment performance depends on target architecture. If architecture
has a set of instructions that has no penalty on accessing unaligned
data you do not need to optimize your code.
If architecture has some specifications on data alignment then it
could be wise to code your program accordingly, see the ABI of
architecture that you are coding for.
Compilers can locate global data in an optimum way but you had better
set the alignment of data explicitly. There might be compiler
extensions to set the alignment of data, both for global and structure
members. GNU has aligned attribute extension. See your compiler
Alignment is an issue for not only global variables but also structure
members. For the alignment of structure members just insert the
necessary padding-members for the recommended alignment for a specific
data type that is best as described in the ABI of the
architecture. You can put all your global data in to a structure and
align them with out using alignment extension of compiler.
If your compiler generates "natural alignment", data that is aligned
to its types size, for structure members you do not need to do this
padding at all.
Return to the
Search the comp.compilers archives again.