Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)

6. There are changes in data alignment with the use of values for the FIELDALIGN pragma,
such as auto, cshared2, and shared2 in the native C compilers, from their use in the TNS
C compilers. Native C or C++ programs that share data structures with TNS C or C++ programs
might require the use of the CSHARED2 pragma. Native programs that share data structures
with TAL programs or Guardian API structures might require the use of the SHARED2 pragma.
Using the C Run-Time Library
Some of the C run-time library routines in programs written for Open System Services on D3x RVUs
might have to be replaced or changed if the programs are to run in native mode. The most significant
changes are included in the following subsections.
Obsolete Library Functions
Replace obsolete C library supplementary functions iscsym(), memswap(), stscmp(), and
others. Certain functions that are supported in the TNS C run-time library are not supported in the
native C run-time library. In almost all cases, equivalent replacement functions are available in the
native C run-time library.
Remove obsolete C run-time library functions for trap handling, such as trap_overflows() and
_is_system_trap(). The trap handling mechanism is replaced with signals in native processes.
(This is relevant only in the Guardian environment.)
Replace obsolete C library Guardian alternate-model I/O functions close(), open(), read(),
write(), and others. To improve interoperability between the Guardian and OSS environments,
the native environment does not support the Guardian alternate-model I/O functions. These functions
must be replaced by the equivalent OSS file-descriptor-model functions or by the equivalent
ISO/ANSI model I/O functions.
Changes to the exit() Function
Check the use of the changed C library exit() standard function. In the TNS Guardian
environment, a nonzero status parameter value from exit() indicates abnormal termination. In
the native Guardian environment, any status parameter value indicates normal termination. The
function call to the Guardian terminate_program() function must be changed to use the
status parameter to indicate abnormal termination, if it does not already do so.
Changes to the Scanset
Check the use of the changed C library fscanf(), scanf(), and sscanf() standard functions.
In the TNS Guardian environment, using the hyphen character (-) in a scanset in the fscanf(),
scanf(), and sscanf() functions denotes the hyphen character. In the native Guardian
environment, the hyphen character denotes a range of characters. A backslash character (\) must
be inserted before the hyphen character in the scanset to maintain the TNS Guardian environment
behavior.
Checking the Condition Code
Native C programs require a change in the manner in which the condition code (_cc_status)
returned by a Guardian procedure call is checked. In TNS programs, the condition code is checked
as follows:
_cc_status CC;
...
CC = WRITEX( ... );
if ( CC == CCG)
In native programs, the equivalent code is:
CC = WRITEX( ... );
if ( _status_gt(CC))
Using the C Run-Time Library 175