pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11- 7
Overview of Field Alignment
Figure 11-4 on page 11-7 shows which fields are misaligned if s2 is allocated at an
address other than a four-byte address.
Overview of Field Alignment
When you declare a definition or template structure, you specify (either explicitly using
a FIELDALIGN clause or implicitly according to the current setting of the FIELDALIGN
compiler directive) how you want the compiler to allocate memory for the structure. The
field alignment for each such structure is specified by one of the following parameters
to a FIELDALIGN clause or directive:
SHARED2 directs the compiler to allocate the structure’s fields using the rules that
TAL uses to generate structure layouts. Specify SHARED2 when the structure will
be used to hold data that is shared—for example, using interprocess messages,
memory, or files—between processes of different types.
SHARED8 directs the compiler to allocate the structure’s fields for optimal
performance on native architecture. Specify SHARED2 when the structure will be
used to hold data that is shared—for example, using interprocess messages,
memory, or files—between processes of different types.
PLATFORM directs the compiler to allocate the structure’s fields according to a
layout that is consistent across different programming languages running as the
same type of process (TNS process, TNS/R native process, or TNS/E native
process). The data might be shared among modules written in different
programming languages, in one of these ways:
°
Running within a single process.
°
Running in separate processes, all of which are of the same type.
Figure 11-4. Well-Aligned and Misaligned SHARED8 Structures With Base
Alignment of 4
02
8
46
18 20 22 24
12 1410 16
28 3026
Misaligned fields: none
02
8
46
18 20 22 24
12 1410 16
28 3026
Misaligned fields: i32a, i32b
02
8
46
18 20 22 24
12 1410 16
28 3026
Misaligned fields: none
s1 i32a s2 s3 filler i32b k fillerfiller
s1 i32a s2 s3 filler i32b k fillerfiller
s1 i32a s2 s3 filler i32b k fillerfiller
VST114.vsd