Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
Migrating Guardian Applications to the OSS
Environment
Open System Services Porting Guide520573-006
8-15
Process Target Type
Process Target Type
The target of a module, chosen at compile time, determines the environment of the
routines being selected. The chosen target interacts with special toggles (feature-test
macros) in the header files to select particular implementations appropriate for the
target. Usually, all modules of a program have the same environment and are bound
together into a program that runs as a process of that environment.
To include OSS functions in a Guardian program, separate compilation of modules
containing OSS functions may be necessary. Because the environment of the process
is determined by the environment of the module containing the main() function
(Guardian in this case), the Guardian program may consist of mixed environment
modules. The target type defines the set of process attributes a process has. Because
Guardian processes have a subset of the attributes associated with OSS processes,
Guardian processes cannot use all of the OSS functions.
Guardian programs can include:
Single-environment (Guardian) functions
Per-environment functions
Opposite-environment (OSS) functions
Both-environment functions
In some cases, there is only one version of a function, and it is intended for use only
within a single environment. For example, waitpid() can be used only in an OSS
program, and fopen_std_file() can be used only in a Guardian program. Thus,
OSS functions that fall into this category cannot be used in Guardian programs.
Both targets also contain per-environment functions with the same name but with
different implementations in each environment. The versions are usually simply
incompatible. For example, for TNS processes, there are both OSS (G-series only) and
Guardian versions of raise() and setjmp(); Guardian programs must use the
Guardian versions of these functions; otherwise unpredictable results are possible.
There is one version of the C run-time library for the native environment, so there is
more API interoperability. Refer to the API interoperability tables in the Open System
Services Programmers Guide.
Use of Environment-Specific Functions
Sometimes there are two different implementations of a function, one for each
environment, but either of these opposite-environment functions can be used within a
single program. For example, a Guardian process can call an OSS function such as
fopen(). Users of such functions should not expect these opposite-environment
functions to perform exactly as they would within same-environment processes or on
same-environment objects.
The syntax of the calling sequence can be different for opposite-environment functions.
The semantics is usually also different: for example, Guardian fopen() expects a
Guardian filename, and OSS fopen() expects an OSS pathname. These
environment-specific functions are fopen(), fclose(), freopen(), rename(),