H-Series Application Migration Guide (H06.03+)

General Programming Issues
H-Series Application Migration Guide429855-006
4-2
Misaligned Data Causes Performance Loss
addition, avoid using those few features in your TNS/R programs that are not
supported in the H-series RVUs.
Misaligned Data Causes Performance Loss
Programs compiled with the native compilers align data items according to certain
rules. 4-byte data items are aligned on boundaries whose addresses are a multiple of
4, and 8-byte data items are aligned on boundaries whose addresses are a multiple of
8. Additionally, TNS/E native GETPOOL and malloc procedures allocate buffers
aligned on 16-byte boundaries. Occasionally, however, a programming error or a run-
time event will cause a data item to violate these alignment rules.
The behavior of programs having misaligned data items, and the options available for
handling misaligned data, differ between H-series and G-series systems. On G-series
systems, misaligned addresses are sometimes rounded down to the next lower even-
byte address. This “round-down” behavior can result in unexpected program behavior,
including run-time errors or incorrect results when a load or store operation is done at
the rounded-down address. Furthermore, it is impossible to predict when a
misalignment will result in a round-down.
In native mode on H-series systems, misaligned addresses are never rounded down;
thus, an address that was rounded down in native mode on a G-series system will not
be rounded down in native mode on an H-series system, possibly resulting in different
program behavior.
Misalignments in TNS/R Native Programs
In TNS/R native programs, misaligned addresses with round-down can occur only in
calls to atomic library routines, and these occur very infrequently. G-series systems
provide options to change program behavior if a misalignment that would result in
round-down is detected. These options are set through the System Configuration
Facility (SCF). The options are:
Allow execution to continue using the rounded down address (Round option)
Allow execution to continue using the natural (unrounded) address (Noround
option)
Generate a failure trap (Guardian) or a SIGILL signal (OSS) when a misaligned
address is detected (Fail option)
In addition, an SCF option is provided to generate a trace of misalignment events and
enter it into the EMS event log (Logging option).
The Round, Fail, and Logging options do not apply to misalignments that occur in
ordinary data references. These misalignments are never rounded down and are not
considered to be erroneous.