pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-23
Using Field Alignment
Using AUTO Field Alignment
If you specify FIELDALIGN(AUTO), the compiler determines the optimal alignment for
fields and structures based on the architecture on which you will run your program.
TAL aligns an AUTO structure as SHARED2 for execution on TNS architecture. pTAL
aligns an AUTO structure for execution on native architecture.
Specify FIELDALIGN(AUTO) for structures that are not used to exchange data
between TNS processes and native processes, even though both types of processes
use the structure.
Do not assume that fields of an AUTO structure are contiguous in memory. The
compilers insert filler where required for optimal alignment.
Pointer fields and nonpointer fields in structures declared with AUTO field alignment
can be any address type or data type, respectively.
Differences Between PLATFORM and AUTO Alignment
PLATFORM structures and substructures can contain UNSIGNED and STRING items
within a two-byte word. In AUTO structures and substructures, STRING items and
UNSIGNED items are not allocated within a two-byte word.
PLATFORM structures and substructures can contain an odd number of bytes. AUTO
(and SHARED8) structures must contain an even number of bytes. TAL and pTAL add
an extra byte at the end of AUTO structures if, without the byte, the structure would
contain an odd number of bytes.
The length of PLATFORM structures or substructures that contains an UNSIGNED
item must be an integral multiple of four bytes. pTAL adds extra bytes, as needed, to
the end of such structures and substructures.
Field Alignment in TAL
When you compile your program with TAL, you must create a define called
FIELDALIGN that expands to an empty string. Do not, however, use this define when
you compile with pTAL. By using this define, TAL compiles:
SHARED2 structures optimally for TNS architecture.
SHARED8 structures optimally for native architecture because pTAL requires you
to declare explicitly all filler items in a SHARED8 structure. TAL, however, does not
verify that you have declared all filler items. By compiling your code with pTAL first,
you can ensure that you have included all filler items that pTAL requires.
AUTO structures optimally for TNS architecture.