CRE Programmer's Guide
CRE Services
Common Run-Time Environment (CRE) Programmer’s Guide—528146-004
2-53
COBOL Routines
•
A trap occurs. However, your program can retain control if an arithmetic trap (trap
4) occurs by using the C
trap_overflows() library function:
trap_overflows( enable_flag )
If your C function disables traps, enable traps when the function reaches the end of
the code that requires that traps be disabled.
The
Guardian TNS C Library Calls Reference Manual describes the
trap_overflows() library function.
See the
C/C++ Programmer’s Guide for further details on C error processing.
COBOL Routines
If an error occurs in a CRE or run-time library function called by the COBOL run-time
library, the CRE returns control to the COBOL run-time library, which calls the CRE to
write a message to standard log. If your program specifies a declarative for the
statement that failed, the COBOL run-time library sets the program’s status code and
the GUARDIAN-ERR special register, and performs your program’s declarative. Your
program’s behavior following execution of the declarative depends on the error that
occurred and the code in the declarative.
If you have not specified a declarative, the COBOL run-time library immediately calls
the CRE to terminate your program.
See the
COBOL Manual for TNS and TNS/R Programs for further details on TNS and
TNS/R COBOL error processing. See the
COBOL Manual for TNS/E Programs for
further details on TNS/E COBOL error processing
Caution. The C trap_overflows() library function takes the following actions:
•
It sets or resets the trap enable bit (bit 8) in the TNS environment register.
•
It traverses the stack markers in the run-time stack and enables or disables the trap
enable bit in each stack marker, according to whether your program calls trap_overflows to
set or to reset trapping. These actions can have two major effects on your program:
Before a call to trap_overflows, some stack markers might have the trap enable bit set,
and other stack markers might have the trap enable bit reset. After a call to
trap_overflows, all stack markers are the same—either set or reset.
If the stack markers of routines that called your C functions include routines written in
languages other than C, your program might not behave as you expect. The code emitted
by compilers for languages other than C might be based on whether or not traps are
enabled. If your C function returns to a routine written in a language other than C, for
example a COBOL routine, and the trap enable bit in the stack marker for the COBOL
routine has changed, your program might not compute the correct results.