TNS/R Native Application Migration Guide

Developing a Migration Strategy
TNS/R Native Application Migration Guide523745-001
2-7
Eliminating Compatibility Traps
Eliminating Compatibility Traps
In most cases, data misalignment in data objects and reference misalignment in
pointers cause traps. To eliminate compatibility traps caused by data misalignment in
data objects, specify a FIELDALIGN SHARED2 pragma or directive for the misaligned
data object.
By default, the native compilers generate code for pointer dereferencing operations
that expects the pointer to contain an address that satisfies the alignment requirements
of the data object being pointed to. For example, a 4-byte object should have an
address which is a multiple of four. If the data object is at an address that does not
satisfy its alignment requirements, a compatibility trap occurs. To avoid this
compatibility trap, specify a REFALIGNED 2 on the pointer to the object. This directs
the native compilers to generate code that assumes the dereferenced object is not
properly aligned and compensates for the improper alignment. While REFALIGNED 2
always generates a few extra instructions for each dereferencing operation, a
compatibility trap results in hundreds of additional instructions.
These directives and pragmas ensure that compatibility traps do not occur. For
additional information on data alignment, see:
C/C++ Programmer’s Guide
pTAL Conversion Guide