Guardian Procedure Calls Reference Manual
on TNS systems, another overflow trap immediately occurs and on native systems, the
process abends.)
◦ Resume with no modifications (modifying the overflow or trap bit of the trap ENV variable
is permitted) after a trap 4 (loop timer interrupt). See the “Resuming at the point of the
trap” consideration below.
◦ Jump to a restart point by changing the trap variables P, L, ENV, space ID, and S. See
the “Resuming at the point of the trap” consideration below.
◦ Terminate the process (for example, by a call to PROCESS_STOP_).
Attempting to exit from a trap handler in any other way is not recommended; the results are
likely to vary between TNS and native systems.
• Resuming from (exiting) a trap handler
The only way to exit from a trap handler is by a call to ARMTRAP specifying
traphandlr-addr = 0; the value supplied for trapstack-addr determines whether the
trap handler is rearmed or disarmed when program execution resumes. The trap handler must
use ARMTRAP. (It cannot use an EXIT instruction to exit through the stack marker at the current
L register location; using EXIT would result in an invalid S register setting following the exit
and would leave trap handling disabled.)
If a call to ARMTRAP is made from within a trap handler and if a value other than 0 is specified
for traphandlr-addr, the trap handler continues to execute. The result of such a call is:
◦ If the call specifies a new trap handler (by supplying a nonzero value for
trapstack-addr), the new trap handler is not armed until a call with
traphandlr-addr = 0 is made that explicitly arms it.
◦ If the call disables trap handling (by specifying trapstack-addr < 0), traps remain
disabled even after a call with traphandlr-addr = 0 that would normally rearm them.
A call to ARMTRAP with traphandlr-addr = 0 is invalid if not made from within a trap
handler.
• Resuming at the point of the trap
To resume execution at the point of the trap, the trap handler should not modify any of the
values passed to it except, under some circumstances, the overflow bit or trap bit of the trap
ENV variable at ‘L'[-1]. Such resumption is valid only for trap 2 (arithmetic overflow) or trap
4 (loop timeout). An attempt to resume at the point of any other trap typically causes the same
trap to occur again on a TNS system; on a native system, such an attempt causes the process
to abend.
• Resuming at another point in the program
To resume execution at some other point in the program, you need to change the P register
value at ‘L'[-2], the space index at ‘L'[-5], and, if necessary, the library space bit in ENV at
‘L'[-1] to reflect the new location within your program. You also need to set appropriate values
for the S register at ‘L'[-3] and the L register at ‘L'[0] and the appropriate environment state
in ENV at ‘L'[-1]: The RP field (ENV.<13:15>) should be set to 7 if the resumption point is the
beginning of a statement; ENV.<0> should be set to 0.
• Traps in protected code
If the trap occurs in system code or system library and the trap handler is in user code or user
library, or if the trap occurs in a licensed user library and the trap handler is in user code,
the reported program location and process state (space ID, P, ENV, and L) indicate the point
of the user call to one of these protected code regions and S is reported as -1.
ARMTRAP Procedure (Superseded by SIGACTION_INIT_ Procedure) 73