C/C++ Programmer's Guide (G06.27+, H06.08+, J06.03+)

Table 58: TNS Misalignment Handling Methods lists and describes the possible settings for
TNSMISALIGN. Each setting represents a different misalignment handling method. For more details
about TNSMISALIGN, see the SCF Reference Manual for the Kernel Subsystem.
Table 58 TNS Misalignment Handling Methods
DescriptionMethod
After rounding down a misaligned address, the system proceeds to access the
address, as in G06.16 and earlier RVUs.
ROUND (default)*
Instead of rounding down a misaligned address and proceeding to access the
target, the operating system considers the instruction to have failed.For a Guardian
FAIL
process, this failure generates an Instruction Failure trap (trap #1). By default, this
trap causes the process to go into the debugger, but the program can specify other
behavior (for example, process termination or calling a specified trap-handling
procedure). For information about trap handling, see the Guardian Programmer’s
Guide. For an OSS process, this failure generates a SIGILL signal (signal #4). By
default, this signal causes process termination, but the program can specify other
behavior (for example, entering the debugger or calling a specified signal-handler
procedure). The signal cannot be ignored. For information about signal handling,
see the explanation of the sigaction() function in the Open System Services
System Calls Reference Manual.
The system uses the operand’s given odd address (not rounded down) to complete
the operation. If the operation is an atomic operation, atomicity is no longer
guaranteed.
NOROUND
* Use this method on production systems to avoid changing the semantics of old TNS programs. FAIL could cause
possibly fatal Instruction Failure traps in faulty TNS programs. NOROUND might change the semantics of some faulty
programs.
The method that you choose does not apply to every misaligned address, only to those that
would have been rounded down in RVUs prior to G06.17.
ROUND and NOROUND misalignment handling are both intended as temporary solutions,
not as a substitute for changing your program to ensure that it has only aligned addresses.
Programs that depend on NOROUND misalignment handling cannot be safely migrated to
all present and future NonStop OS platforms or to systems configured with ROUND or FAIL
misalignment handling.
Programs that depend on ROUND misalignment handling cannot be safely migrated “as is
to future NonStop platforms or to systems configured with NOROUND or FAIL misalignment
handling.
C/C++ Misalignment Examples
In native mode, the targets of C and C++ pointers are usually aligned for best performance, but
full alignment is not required. Misaligned addresses might slow down a native program, but the
misaligned addresses are never “rounded down” in native mode and do not cause the program
to terminate abnormally.
In TNS mode and accelerated mode, the targets of C and C++ pointers (except pointers to char
items) must be aligned on 2-byte memory boundaries for correct operation. The results of odd-byte
addresses depend on the specific NonStop server and the system configuration, but they might
include erratic “rounding down” and abnormal program termination.
In a TNS-compiled C or C++ program, some actions that can cause misaligned addresses are:
1. Using a null or uninitialized pointer.
When a structure pointer is null or uninitialized, the structure’s fields are random bits, which
could give a random misaligned address if a pointer field is dereferenced. Examples:
C/C++ Misalignment Examples 385