pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
4 Data Alignment
In native mode, a data item is aligned if its address is a multiple of its size. For example, a 4-byte
data item is aligned if its address is a multiple of four. An address that is not aligned is called
misaligned. In native mode, a compiler requires data to be aligned unless otherwise indicated.
Unexpected misalignment causes the program to run slowly, but usually with the expected results.
The only time a nonprivileged program running in TNS/R native mode could have data alignment
problems is when calling the atomic routines whose names begin with “$ATOMIC_”. Those routines
operate correctly only when given aligned operand addresses. This section explains some ways
to diagnose bad calls at run time.
TNS-compiled programs must follow more stringent alignment rules, which apply to all data. Those
rules are explained in:
DocumentT NumberProduct
Accelerator Manual Data Alignment AddendumT9276Accelerator
C/C++ Programmer’s GuideT9255TNS C
C/C++ Programmer’s GuideT9541TNS C++
C/C++ Programmer’s GuideT8629TNS c89
COBOL Manual for TNS and TNS/R ProgramsT9257TNS COBOL
TAL Programmer’s Guide Data Alignment AddendumT9250TAL
Topics:
• Misalignment Tracing Facility (page 66)
• Misalignment Handling (page 67)
Misalignment Tracing Facility
The misalignment tracing facility is enabled or disabled on a system-wide basis (that is, for all
processors in the node). By default, it is enabled (set to ON). It can be disabled (set to OFF) only
by the persons who configure the system, by means of the Subsystem Control Facility (SCF) attribute
MISALIGNLOG. Instructions are in the SCF Reference Manual for the Kernel Subsystem.
NOTE: HP recommends that the MISALIGNLOG attribute be left ON (its default setting) so that
a process that is subject to rounding of misaligned addresses generates log entries, facilitating
diagnosis and repair of the code. Only if the volume of misalignment events degrades performance
should this attribute be turned OFF.
When a misaligned address causes an exception that RVUs prior to G06.17 would have rounded
down, the tracing facility traces the exception.
NOTE: The tracing facility does not count and trace every misaligned address, only those that
cause round-down exceptions. Other accesses that use misaligned addresses without rounding
them down do not cause exceptions and are not counted or traced. Also, only a periodic sample
of the counted exceptions are traced by means of their own EMS event messages.
While a process runs, the tracing facility:
• Counts the number of misaligned-address exceptions that the process causes (the exception
count)
• Records the program address and code-file name of the instruction that causes the first
misaligned-address exception
66 Data Alignment