pTAL Conversion Guide

Equivalenced Variables
pTAL Conversion Guide527302-002
12-16
Using a REFALIGNED Clause With Equivalenced
Declarations
Using a REFALIGNED Clause With
Equivalenced Declarations
You can include a REFALIGNED clause when you declare an equivalenced pointer.
pTAL generates fast code for references to a pointer that specifies REFALIGNED(8),
conservative code for references to a pointer that specifies REFALIGNED(2). If you do
not specify a REFALIGNED clause in the pointer declaration, pTAL generates fast
code or conservative code based on the current setting of the REFALIGNED compiler
directive. Equivalenced pointers do not inherit the reference alignment of the previous
variable.
For more information about reference alignment, see Reference Alignment with
Nonstructure Pointers on page 10-39.
Example 12-13. Structure Variants in Reverse Order of Example 12-12
STRUCT s FIELDALIGN(AUTO);
BEGIN
STRUCT v1;
BEGIN
INT .EXT e; ! e is 4 bytes on TNS & native architectures
END;
STRUCT v2 FIELDALIGN(SHARED8) = v1;
BEGIN
INT .p; ! p is 2 bytes on TNS architecture,
! 4 bytes on native architecture
INT q; ! pTAL reports a warning
END;
END;
Note. In pTAL, v2 is eight bytes to maintain the alignment of variables in native memory. See
Section 11, Structures, for more information about lengths of structures on native architecture.
Example 12-14. Equivalenced Declarations With REFALIGNED Clause
?REFALIGNED(8) ! Default reference alignment is 8
INT .p REFALIGNED(2); ! Reference alignment of p is 2
INT .q REFALIGNED(8) = p; ! Reference alignment of q is 8
INT .r REFALIGNED(2) = p; ! Reference alignment of r is 2
INT .s = p; ! Reference alignment of s is 8
INT .t; ! Reference alignment of t is 8