C/C++ Programmer's Guide (G06.25+)
Using the C Run-Time Library
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
4-6
Alternate-Model I/O
Alternate-Model I/O
As mentioned earlier, the alternate-model I/O functions use file descriptors to identify
files. The alternate-model I/O functions are not available in standard ISO/ANSI C. In
the Guardian TNS environment, alternate-model I/O functions are defined by HP. In all
other environments, alternate-model I/O functions are defined by the XPG4
specification.
The arguments required by the function file descriptors are simply variables of type
int, so to create one you make a declaration of the form:
int identifier;
The functions that open a physical file for alternate-model I/O return a file descriptor
that denotes the newly opened file. You then use that file descriptor to direct I/O
requests to the physical file.
Note that file descriptors are different from file numbers:
•
Alternate-model I/O functions use file descriptors to identify files
•
Guardian system procedures use file numbers to identify files
Use errno to determine whether there is an error when I/O is performed using the
alternate-model I/O functions. The I/O error handling for the alternate model is an HP
extension not specified in the ISO/ANSI C standard.
The header file errnoh or errno.h declares the variable errno and several object-
like macros that are used to report errors. Include the errnoh header file, then set
errno to zero and call the alternate-model I/O function. If the function fails, errno
contains the error code.
Mathematical Functions
This subsection describes mathematical functions available on HP NonStop systems
before the G06.06 release, and available after the G06.06 release if you specify
Tandem floating-point format. Additional mathematical functions that are available with
IEEE floating-point format are described in IEEE Floating-Point Arithmetic on page 4-7.
The C run-time libraries provide mathematical functions, such as cos() and exp(),
defined in the ISO/ANSI C standard and XPG4 specification. For specific conditions,
these standards define the actions taken by a mathematical function. These actions
are specified as either required or optional.
There are conditions defined in these standards that could not occur in the HP
implementation on older systems. These conditions include an argument or return
value of NaN (not-a-number) and positive and negative infinity. Because these
conditions could not occur, the Tandem floating-point format variants of the
mathematical functions do not take actions defined in the standards.
For example, the XPG4 cos() function definition requires that NaN be returned if the
parameter to the function is NaN. The definition further states that errno optionally