Guardian Procedure Calls Reference Manual (G06.25+)

Guardian Procedure Calls (A-B)
Guardian Procedure Calls Reference Manual522629-013
2-39
ARMTRAP Procedure
(Superseded by SIGACTION_INIT_ Procedure )
Terminating a trap handler
A trap handler can terminate in the following ways on either a TNS or native
system:
Clear the overflow (or trap) bit in the trap ENV variable and resume from a trap
2 (arithmetic overflow). See “Resuming at the point of the trap” later in
“Considerations.” (If the overflow and trap bits of ENV are both set upon exit
from the trap handler, then 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 “Resuming
at the point of the trap” later in “Considerations.”
Jump to a restart point by changing the trap variables P, L, ENV, space ID,
and S. See “Resuming at another point in the program” later in
“Considerations.”
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 as follows:
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. Starting in D20, such a call disarms all trap handling.
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