pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11- 9
Field and Base Alignment
Field and Base Alignment
The field alignment of a structure specifies the offsets at which fields of the structure
must begin relative to the base of the structure. A scalar field is well-aligned when its
byte offset is an integral multiple of its width. A substructure is well-aligned when the
offset of its base, relative to its encompassing structure, is an integral multiple of its
widest field.
You use a FIELDALIGN on a structure declaration to specify how you want pTAL to
align the fields in the structure. Fields can be aligned for:
Nonshared access, optimized for best resource utilization on each architecture.
Shared access between TNS and native architectures. Such structures are
compatible with existing TAL structures. pTAL generates conservative code for
each reference to a field in the structure.
Shared access by program modules written in different programming languages
and running on either TNS or native architecture, but not on both.
Shared access between TNS and native architectures with optimal performance on
native architecture.
Base Alignment
The base alignment of a structure is the alignment of the widest field in the structure.
The base alignment determines where the structure can be located in memory and be
well-aligned. A structure is well-aligned when the memory address at which it is located
is an integral multiple of its base alignment.
When you declare a definition structure or a referral structure, the compiler ensures
that the structure is well-aligned. When you declare a structure pointer or a reference
parameter that points to a structure, however, you must specify whether the compiler is
to assume that the structure is well-aligned in memory. You can explicitly specify the
alignment of a structure pointer by including a REFALIGNED clause when you declare
the structure pointer. If you do not specify a REFALIGNED clause, the reference
alignment for the pointer is the field alignment specified by the referral structure you
name in the pointer declaration.
Structure Declarations
In pTAL, definition structure and template structure declarations can optionally include
a FIELDALIGN clause.
Topics:
Definition Structure Syntax on page 11-10
Template Structure Syntax on page 11-13
Referral Structure Syntax on page 11-15