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

Table Of Contents
Introduction to Porting
Open System Services Porting Guide520573-006
1-2
Porting Is Easier When Standards Are Used
programming practice is to write your C or C++ programs using a template with items
included in the source file in the following order:
Feature test switches: define the _POSIX_SOURCE macro.
System headers: those that must be included to define symbols used by a function.
Local headers: define common data structures and symbols
Macros: defined here with comments to describe the macros.
File scope variables: those that are shared by several functions in the same file.
External variables: those defined in other modules but used in current module.
External functions: list external functions used by each module.
Structures and unions: define structures used in current file.
Signal catching functions: keep signal catching functions in this area.
Functions: define functions before use.
Main: if present, place the main() function last.
Porting Is Easier When Standards Are Used
The OSS environment is based upon standards available in the open systems
community. These standards include the POSIX standards, XPG4 interface
specifications, and the ISO/ANSI C compiler language standard. The prime purpose of
these standards is to define a consistent interface and environment for application
programs. Using standard interfaces enhances the portability of your applications to
open systems environments.
The following subsections describe the relevant standards:
POSIX Standards and OSS Conformance on page 1-2
XPG4 Specifications and OSS Compliance on page 1-4
OSS Compliance With UNIX 98 and Other Open Group Technical Standards on
page 1-4
ISO/ANSI C Standard and the HP NonStop C Compiler on page 1-4
POSIX Standards and OSS Conformance
POSIX (Portable Operating System Interface) is a group of formal standards
introduced by the IEEE in the mid-1980s. POSIX is a whole family of formal standards
defining the interface between applications and a set of system libraries. The OSS
environment is nearly completely compliant with the 1990 editions of the basic
POSIX.1 and POSIX.2 standards. For more information, refer to the ISO/IEC 9945-1
POSIX.1 Standard and ISO/IEC 9945-2 POSIX.2 Standard documents.
POSIX.1 Standard
POSIX.1 defines interface standards that make up the application program interfaces
(APIs). It defines the APIs to be used by portable programs, the system call interface,
and the C run-time routine interfaces for portable programs. If programs use only those
APIs, they are guaranteed to be portable to other POSIX-conforming environments.