i960 Processor Compiler User's Guide
7-6
7
Structure alignment can result in unused space, called padding, between
members of the structure and between the last member and the end of the
space occupied by the structure. The padding at the end of the structure is
called tail padding. Because of differences in padding under different
alignments, changing the alignment can change both the size of the
structure and the offsets of members relative to the beginning of the
structure.
The offset of a structure member from the beginning of the structure is as
follows:
• Under both forms of natural alignment, the offset of a structure
member is a multiple of the member's natural alignment. For
example, since a
short aligns on a 2-byte boundary, the offset of a
short member from the beginning of a structure is a multiple of
2 bytes.
• Under user-constrained alignment, the offset of a structure member is
a multiple of the lesser of the member's alignment or the alignment
constraint you specify.
• For example, in a 1-byte alignment (
noalign), the offset of a short
member is not necessarily even.
The rules for structure member natural alignment are:
Scalar types align according to their natural architectural
alignment. For example, a
short data type
aligns on a 2-byte boundary.
Array types align according to the alignment of the array
elements. For example, an array of
short data
type aligns on a 2-byte boundary.