4.2.3 Record Layout Conventions
The Alpha calling standard record layout rules are designed to provide good run-time performance on all implementations of the Alpha architecture.
Only the standard record layouts may be used across standard interfaces or between languages. Languages may support other language-specific record layout conventions, but such other record layouts are not standard.
Aligned Record Layout
The aligned record layout conventions ensure that:
- All components of a record or subrecord are naturally aligned.
- The layout and alignment of record elements and subrecords is independent of any record or subrecord in which they may be embedded.
- The layout and alignment of a subrecord is the same as if it were a top-level record.
- Declaration in high-level languages of standard records for interlanguage use is reasonably straightforward and obvious, and meets the requirements for source-level compatibility between Alpha environments and other environments.
The aligned record layout is defined by the following conventions:
- The components of a record must be laid out in memory corresponding to the lexical order of its appearance in the high-level language declaration of the record.
- The first bit of a record or subrecord must be directly addressable; i.e., it must be byte-aligned.
- Records and subrecords must be aligned according to the largest natural alignment requirements of the contained elements and subrecords.
- Bitfields (packed subranges of integers) are characterized by an underlying integer type that is a byte, word, longword, or quadword in size together with an allocation size in bits. A bitfield is allocated at the next available bit boundary provided that the resulting allocation does not cross an alignment boundary of the underlying type. Otherwise, the field is allocated at the next byte boundary that is aligned as required for the underlying type. (In the latter case, the space skipped over is left permanently not allocated.) In addition, the alignment of the record as a whole is increased to that of the underlying integer type (if needed).
- Unaligned bit strings, unaligned bit arrays, and elements of unaligned bit arrays must start at the next available bit in the record; no fill is ever supplied preceding an unaligned bit string, unaligned bit array, or unaligned bit array element.
- All other components of a record must start at the next available naturally aligned address for the data type.
- The length of a record must be a multiple of its alignment. (This includes the case when a record is a component of another record.)
- Strings and arrays must be aligned according to the natural alignment requirements of the data type of which the string or array is composed.
- The length of an array element is a multiple of its alignment, even if this leaves unused space at its end. The length of the whole array is the sum of the lengths of its elements.