Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Use of POSIX library functions

&pagelevel(4)&pagelevel

With CRTE a C runtime system is provided, that supports C library functions with BS2000 functionality as well as POSIX functionality.

The library functions with BS2000 functionality include all ANSI-defined functions and about fifty BS2000-specific extensions.
Only these functions may be used in the following cases:

  • if no POSIX subsystem is available, or

  • if no preparatory steps are taken (see below) at compile and link time in a BS2000 operating system with an available POSIX subsystem.

The library functions with BS2000 functionality are described in the manual “C Library Functions” [2].

The following functions of the C runtime system, which were introduced for the first time with CRTE V2.0, are library functions with POSIX functionality: all functions required by the XPG4 standard and about thirty UNIX-specific extensions. For more information on these functions and all functions with BS2000 functionality, see the manual “C Library Functions for POSIX Applications” [3].

Compilation and linkage of programs that use POSIX library functions

The following steps are required in order to use library functions with POSIX functionality when developing programs in the BS2000 environment (SDF):

  1. The library SYSLIB.POSIX-HEADER, which contains the standard headers for POSIX functions, must be specified in addition to the CRTE library SYSLIB.CRTE in the search for standard headers at compilation.

    //MOD-INCLUDE-LIB STD-INCLUDE-LIB=(*STANDARD-LIBRARY,&(INSTALLATION-PATH

    (’SYSLIB’,’POSIX-HEADER’,DEFAULT=’$.SYSLIB.POSIX-HEADER’)))

  2. The _OSD_POSIX directive must always be set before the preprocessor encounters the first #include directive in the program. This can be ensured by a global setting for the entire compilation run with the SOURCE-PROPERTIES statement instead of a definition in the source program with the #define directive.

    //MODIFY-SOURCE-PROPERTIES DEFINE=_OSD_POSIX

  3. When linking, the link option library SYSLNK.CRTE.POSIX must be linked with precedence before the library SYSLNK.CRTE, SYSLNK.CRTE.PARTIAL-BIND or SYSLNK.CRTE.COMPL. When linking with BINDER, it is advisable to use an INCLUDE statement for the link option library (without specifying the module name), since the use of RESOLVE statements, by contrast, would require the appropriate order to be strictly observed. In the case of the BINDER statement, for example:

    //INCLUDE-MODULES *LIB(LIB=$.SYSLNK.CRTE.POSIX,ELEM=*ALL)

    This also applies when linking with the BIND statement of the compiler, i.e. the INCLUDE option should be used in the MODIFY-BIND-PROPERTIES statement:

    //MOD-BIND-PROP INCLUDE=*LIB-ELEM(LIB=&(INSTALLATION-PATH('SYSLNK.POSIX',

    'CRTE',DEFAULT='$.SYSLNK.CRTE.POSIX')),ELEM=*ALL)

When developing programs in the POSIX environment, by contrast, no special preparatory steps are required in order to use the POSIX library functions (see also the manual “POSIX Commands of the C/C++ Compiler” [1]).