Organization of the HP C/iX Library [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
Organization of the HP C/iX Library
The HP C/iX library consists of several files that can be divided into
three groups: standard library functions, mathematical library
functions, and library functions available only on HP 3000 Series 900
computers.
[REV BEG]
If you are developing POSIX applications on MPE/iX, you will be using the
POSIX/iX library. This library is separate from the HP C/iX library and
is organized differently. The POSIX/iX library is described in the
MPE/iX Developer's Kit Reference Manual. [REV END]
The Standard Library
The standard library consists of the input/output functions, the general
utility functions, and the program startup routines. All C programs must
link in the standard library because it contains the startup routines
necessary for program execution. Failure to link in this library results
in a linker or loader error.
The standard C library functions are provided in three different forms:
a relocatable library (LIBC.LIB.SYS), an executable library (XL.PUB.SYS),
and a relocatable library that is suitable for adding to an executable
library that you build (LIBCXL.LIB.SYS).
Each form of the library is intended for different uses. The relocatable
form (LIBC.LIB.SYS) is for programmers who want the HP Link Editor/iX to
bind copies of library functions to the application program at link time.
This reduces the amount of dynamic binding that must be done at run time.
However, this makes less efficient use of memory space because each
application duplicates the library functions that it uses.
The executable forms of the library are placed into shared libraries that
can be accessed when applications written in C are executed. System
memory usage decreases when C programs access the shared library. Only
one copy of each function is loaded into the computer's main memory. For
example, if several applications use printf, only one copy of the actual
printf executable code is loaded into memory. All applications share the
same copy.
The files that contain the standard library are listed in Table 1-1 :
Table 1-1. Standard Library Files
--------------------------------------------------------------------------------------------
| | |
| File | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| XL.PUB.SYS | The executable library (XL) form of the standard library, |
| | including executable libraries from other subsystems and |
| | languages. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBCINIT.LIB.SYS | The code necessary to initialize the XL form of standard |
| | library. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBC.LIB.SYS | The relocatable library (RL) form of the standard library |
| | functions. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBCANSI.LIB.SYS | The relocatable library that should be linked along with |
| | LIBCINIT or LIBC if conformance to ANSI C is desired. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBCRAND.LIB.SYS | The random number related functions, rand and srand, in RL form. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBCWC.LIB.SYS | The relocatable library that enables an HP C/iX program to |
| | expand valid file set wildcards into fully qualified permanent |
| | file names and pass them into the main program. See the HP C/iX |
| | Reference Manual for details. |
| | |
--------------------------------------------------------------------------------------------
Table 1-1. Standard Library Files (cont.)
--------------------------------------------------------------------------------------------
| | |
| File | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBCXL.LIB.SYS | A relocatable library that is used to build the XL form of the |
| | standard library. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBM.LIB.SYS | The mathematical library functions in RL form. |
| | |
--------------------------------------------------------------------------------------------
| | |
| LIBMANSI.LIB.SYS | An ANSI-conforming version of the mathematical library. |
| | |
--------------------------------------------------------------------------------------------
The executable form of the standard library in XL.PUB.SYS is
automatically searched when any C program is executed. To use the XL
form of the library, you must add the LIBCINIT.LIB.SYS file to the RL
list when linking your program.
To use the relocatable form of the standard library, you must add the
LIBC.LIB.SYS file to the RL list when linking your program. In this
case, you must not specify the LIBCINIT.LIB.SYS file.
NOTE Either the LIBCINIT.LIB.SYS file or the LIBC.LIB.SYS file, but not
both, must be specified in the RL list when linking a C program.
The relocatable library contained in LIBCANSI contains a flag that
specifies that ANSI-conformant behavior is desired. Certain functions,
primarily those that perform input/output operations on text files,
interrogate this flag and behave accordingly. To specify ANSI-conforming
behavior for the standard library functions, add LIBCANSI.LIB.SYS to the
RL list when linking your program. If you want behavior consistent with
pre-ANSI releases of the library, do not link with LIBCANSI. Normally,
ANSI-conforming behavior should be requested for new programs.
If you use the CCXLLK command to compile and link a C program, or
the CCXLGO command to compile, link, and run a C program, then
LIBCANSI.LIB.SYS is automatically added to the RL list in the link step
if you compiled in ANSI mode (-Aa option). If you compile and link with
separate commands, specify LIBCANSI if you want ANSI-conforming behavior.
The rand and srand functions are not in the XL or RL versions of
LIBC.LIB.SYS. To use the rand and srand functions, you must add the
LIBCRAND.LIB.SYS file to the RL list when linking your program. There is
no XL version of these functions. The special treatment for the rand and
srand functions is due to a name conflict between the HP C/iX library
function rand and the MPE/iX compiler library function rand.
The LIBCXL.LIB.SYS file facilitates building additional executable
libraries containing the standard library and should not be linked into C
programs.
The following examples link the standard library into a program. In the
examples, assume that the object files MYOBJ1 and MYOBJ2 were created by
the HP C/iX compiler and define the function main. To use the XL version
of the standard library in a program called MYPROG1, specify the
following LINK command:
LINK FROM=MYOBJ1; TO=MYPROG1; RL=LIBCINIT.LIB.SYS,&
LIBCANSI.LIB.SYS
To use the rand function with the RL version of the standard library in a
program called MYPROG2, specify the following LINK command:
LINK FROM=MYOBJ2;TO=MYPROG2;RL=LIBCRAND.LIB.SYS,LIBC.LIB.SYS,&
LIBCANSI.LIB.SYS
For a complete specification of available functions, see chapter 5.
The Math Library
The math library consists of additional mathematical functions, such as
trigonometric and logarithmic functions, that perform floating-point
operations.
Two relocatable versions of the math library are provided. The library
in LIBMANSI.LIB.SYS conforms to the ANSI standard for C and is the
version you should use. The library in LIBM.LIB.SYS is compatible with
older, pre-ANSI releases of the library, and is for programs that may be
relying on non-ANSI behaviors.
The primary difference between the two libraries is in the way they
handle an error, such as attempting to compute the square root of a
negative value. The ANSI version of the library calls a user-written
function named _matherr if one is provided; no error message is
displayed. The older version of the library calls a user-written
function named matherr if one is provided. Otherwise, an error message
is displayed.
To use the math library, you must add the library file to your RL list
when linking your program. The math library must precede the standard
library (LIBC.LIB.SYS) in the RL list if the RL form of the standard
library is used. The ordering of the files is significant because of the
interdependencies between the libraries. The ordering is not significant
if the XL form of the standard library is linked.
The following example links the math library into a program. In the
example, assume the object file MYOBJ was created by the HP C/iX compiler
and defines the function main. To use the ANSI-conforming math library
and the RL version of the standard library in a program called MYMATH,
specify the following link command:
LINK FROM=MYOBJ;TO=MYMATH;RL=LIBMANSI.LIB.SYS,LIBC.LIB.SYS,&
LIBCANSI.LIB.SYS
For a complete specification of math library functions, see chapter 5.
Other Library Functions
In addition to the standard library functions and the math library
functions, HP C/iX provides another set of functions that perform
miscellaneous tasks.
For a complete specification of available functions, see chapter 5.
MPE/iX 5.0 Documentation