TNS/R Native Application Migration Guide

C and C++ Migration Tasks
TNS/R Native Application Migration Guide523745-001
3-15
Changing Code That Relies on Arithmetic Overflow
Traps
_guardian variant. For example, replace calls to fopen() with either fopen_oss()
or fopen_guardian(), as appropriate.
Changing Code That Relies on Arithmetic
Overflow Traps
Guardian TNS C library functions, such as the tan() function, generate a trap on
arithmetic overflow. In the Guardian native C library, such functions generate neither a
trap nor a signal on arithmetic overflow. In most cases, the functions set errno to
[ERANGE] or [EDOM] to indicate arithmetic overflow. The behavior of Guardian native
C library functions now matches the behavior of the TNS and native OSS C library
functions. Change your code that relies on arithmetic overflow to evaluate either
errno or the parameters to function call.
By default, the native C and C++ compilers do not generate code that traps on
arithmetic overflow. Specify an OVERFLOW_TRAPS pragma to generate code that traps
(raises a signal) on arithmetic overflow. The overflow traps occur in code generated by
the compiler, not code linked into the program (for example, C library functions).
Note. Guardian native C programs compiled in the D42, D43, and G02 RVUs that call any of
the following twelve functions to access files in the Open System Services (OSS) environment
must be recompiled with the native C compiler on the D44, G03 or later RVU:
fopen()
fopen_oss()
freopen()
freopen_oss()
remove()
remove_oss()
rename()
rename_oss()
tmpnam()
tmpnam_oss()
tmpfile()
tmpfile_oss()
If you do not recompile, the programs fail at run time. Very few programs are believed to exist
that use this obscure Guardian and OSS interoperability feature. Guardian programs that call
these functions to access Guardian files and OSS programs that calls these functions to
access OSS files do not need to be recompiled.