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

Two types of user libraries are supported: TNS user libraries and native user libraries. A TNS user
library is available only to TNS interpreted and accelerated processes in the Guardian environment.
A native user library is available only to native processes in the Guardian and OSS environments.
The memory architecture and implementation of native user libraries differs from TNS user libraries,
but these differences do not affect the restrictions on and capabilities of user libraries.
A native user library can be either a position-independent code (PIC) file or a non-PIC file. A non-PIC
native user library is built using the nld linker with a -ul flag; a PIC user library is built using the
ld linker (in a TNS/R environment) or the eld linker (in a TNS/E environment) with a -ul flag.
The -ul flag causes ld, nld, or eld to link the file for use as a native user library. The user library
for native programs can be specified using the ld, nld, or eld utility or the c89 or c99 utility.
For a TNS/R non-PIC user library:
nld -libname library ...
c89 -Wnld="-libname library" ...
For a TNS/R PIC user library:
ld -libname library ...
c89 -Wld="-libname library" ...
For a TNS/E user library:
eld -libname library ...
c89 -Wld="-libname library" ...
c99 -Weld="-libname library" ...
The precedence rules for TNS and native programs are the same: user libraries specified in the
command line override those specified in Binder, ld, nld, and eld commands.
C Language Compilers
The TNS/R and TNS/E C compilers accept the Common C language as input as well as strict
ISO/ANSI C code. There are differences in the ISO/ANSI C implementation-defined behaviors
of some functions and in compiler limits for native C and C++.
Programs written for the TNS environment probably need modification if the programs are to run
in native mode. Guidelines should include the following steps. Refer to the TNS/R Native Application
Migration Guide for details on migrating to the TNS/R native environment. Refer to the H-Series
Application Migration Guide for additional changes that might be required to migrate from the
TNS/R native environment to the TNS/E native environment.
1. Make sure your C or C++ source code is written for the large memory model and the 32-bit
data model because these are the only options supported for Open System Services. The best
way to ensure this is to use the proper prototype function declarations with the proper argument
type declarations. For the standard library routines, the declarations are in the appropriate
system header files.
2. The placement of pragmas is more restrictive with the native C compilers. Some source-level
pragmas might require being moved to the command line as flags. The native C and C++
compilers require that certain pragmas be specified as flags to the OSS c89 utility if the default
settings are not desired; for instance, the INSPECT, RUNNABLE, SEARCH, SSV, and other
pragmas. For details on C or C++ program compilation in the OSS environment, refer to the
c89(1) or c99(1) reference page either online or in the Open System Services Shell and
Utilities Reference Manual.
3. Check the use of changed pragmas. Certain pragmas produce different results with the native
C compilers than with the TNS C compiler. These include the [NO]INLINE, OPTIMIZE,
SEARCH, SQL, and [NO]WARN pragmas.
4. Remove obsolete pragmas. Certain pragmas must be removed from your C and C++ source
files to use the native C and C++ compilers. These include ANSICOMPLY, [NO]CHECK,
OLDCALLS, and others.
5. Delete the use of obsolete keywords such as _cspace and _lowmem.
174 Native Migration Overview