pTAL Reference Manual (H06.08+)
Structures
HP pTAL Reference Manual—523746-006
9-17
Substructure Alignment
In Example 9-8 on page 9-17:
•
Because s1 specifies SHARED2 field alignment, pTAL generates conservative
code that ensures that an exception does not occur when you reference s1.s2.j.
•
p2 refers to t_s8, a SHARED8 substructure. p2 specifies a reference alignment of
2, which ensures that pTAL generates conservative code that will not cause
exceptions for misaligned memory references.
•
p3 does not have a REFALIGNED clause. Its reference alignment, therefore,
defaults to the field alignment of its referent, which is t_s8, which has SHARED8
field alignment. pTAL generates fast code for each reference to p3.j.
In the formal parameter specification for a structure pointer, declare reference
alignment 2 unless you are certain that all pointers passed to the parameter reference
SHARED8 structures that you know are well-aligned. If you are not certain that all
references are well-aligned, use the same approach as that shown earlier to ensure
that references to structures passed as actual parameters do not cause a trap.
Example 9-7. SHARED8 Structures With SHARED2 Substructures
STRUCT t_s2(*) FIELDALIGN(SHARED2); ! Base alignment of t_s2
BEGIN ! is 2
INT(32) j;
END;
STRUCT t_s8(*) FIELDALIGN(SHARED8); ! Base alignment of t_s8
BEGIN ! is 4
INT(32) j;
END;
Example 9-8. SHARED2 Structures With SHARED8 Substructure
STRUCT s1 FIELDALIGN(SHARED2);
BEGIN
INT i;
STRUCT s2(t_s8); ! s2 has SHARED8 alignment
END; ! Base alignment of s2 is 2
INT .p2(t_s8) REFALIGNED(2); ! Reference alignment is 2
INT .p3(t_s8); ! Reference alignment defaults
! to 8
PROC p;
BEGIN
INT i;
@p2 := @s1.s2 '>>' 1;
@p3 := @s1.s2 '>>' 1;
i := p2.j;
i := p3.j;
...
END;










