Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Release Notes for HP-UX 10.30: HP 9000 Computers > Chapter 9 Commands and Libraries

Library Routines (libc)

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

This section covers the following topics:

  • For 10.30:

    • POSIX.1c Threads

    • NIS+/Dynamic Name Service Switch

    • Internationalization- and Localization-related Changes

  • For 10.20:

    • getrlimit()

    • lockf()/fcntl()

    • ulimit()

  • For 10.10:

    • UNIX 95 Conformance

    • New Functionality

    • Incompatibilities with Previous Versions

    • Additional Changes

    • curses(3X)

  • For 10.0:

    • SVID3 and XPG4 Conformance

    • XPG4 Base Profile Branding

    • Summary of Changes for XPG4

    • How This Affects Your Code

    • New libc Routines at 10.0

    • libc Changes to Support Threads

    • The 10.0 File System Layout and libc

    • Other Changes to libc Routines

    • libc Routines No Longer Supported

NLS (Native Language Support) changes to libc are covered in the README for NLS in 10.01.

Changes for 10.30

Starting with 10.30, the C runtime library has added support for the following:

  • POSIX.1c threads. (The implementation of POSIX.1c threads is based on 1x1 kernel threads technology that is described in a separate section of this document.)

  • NIS+/Dynamic Name Service Switch

Summary of changes:

  • System V versioning technology is used to deliver the new features. Thus, the features new to HP-UX 10.30 are supported only in libc.2 and libc.a. libc.1 will be delivered to provide binary compatibility for applications built on earlier versions of HP-UX.

  • A new networking services library (libnsl) is created. The rpc, yp, and xdr APIs are moved from libc to libnsl.

  • APIs that query the passwd, group, hosts, network, and services protocol databases are changed to use the Dynamic Name Service Switch technology. These APIs now support NIS+, in addition to NIS, files, and DNS.

  • In addition to safe operation in multi-threaded DCE applications that use user space threads technology, libc APIs will also be safe for usage in applications that use the 1x1 kernel threads (POSIX.1c threads) technology.

  • A new library (libd4r) is created for obsoleted HP-UX proprietary interfaces with suffix _r and _unlocked. This library is provided solely for compatibility with existing cma threaded applications (DCE user space threads).

  • The NLS methods, locale libraries, and the iconv method libraries are versioned.

  • There are new interfaces added to libc: vsprintf() and vsnprintf()

The changes to existing functionality affect both application developers and library providers. The section "Impact of libc Changes on Applications" summarizes the impact of the changes on application developers and the section "Impact of libc Changes on Libraries" summarizes the impact on library developers.

Usage Notes

  1. When compiling applications on HP-UX, you do not need to specify -lc on the C compiler command line. The C compiler driver automatically includes the C library during the link phase. When the application link phase is performed by explicitly invoking ld, -lc should be last argument on the command line. This is necessary to ensure a correct resolution of symbols and correct library initialization at program startup.

  2. There are two versions of the shared libc on 10.30: libc.1 and libc.2. libc.1 is supported only for binary compatibility. The compilation environment (such as header files, and so on) for libc.1 is not available on 10.30. Linking applications with libc.1 on 10.30 is not supported. Some interfaces have changed in an incompatible way between 10.20 and 10.30 and applications that link with libc.1 on 10.30 may behave incorrectly.

POSIX.1c Threads

libc APIs can now be safely used in multi-threaded applications that use either the 1x1 kernel threads (POSIX.1c threads) or CMA user space threads technology. The following APIs have changed for supporting 1x1 kernel threads.

errno, h_errno, and getdate_err

For multi-threaded applications, a thread-specific errno is implemented. Multi-threaded applications must import the errno definition from <errno.h> and compile all components of the application with -D_REENTRANT. The practice of declaring errno as extern int errno; is obsoleted.

errno is no longer a legal name for a structure member in a file that includes <errno.h> and is compiled with -D_REENTRANT. For example, the following

       #include <errno.h>

struct foo {
int errno ;
};

will not compile with -D_REENTRANT. The solution is to change erno to errnum.

The changes to h_errno and getdate_err are similar to the errno changes.

asctime_r()

The function prototype of asctime_r() has changed from

    int asctime_r(const struct tm *, char *, int);

to

    char *asctime_r(const struct tm *, char *);

for conformance with POSIX.1C.

ctime_r()

The function prototype of ctime_r() has changed from

    int ctime_r(const time_t *, char *, int);

to

    char *ctime_r(const time_t *, char *);

for conformance with POSIX.1C.

getgrgid_r()

The function prototype of getgrgid_r() has changed from

    int getgrgid_r(gid_t, struct group *, char *, int);

to

    int getgrgid_r(gid_t, struct group *, char *, size_t, struct group**);

for conformance with POSIX.1C.

getgrnam_r()

The function prototype of getgrnam_r() has changed from

    int getgrnam_r(const char *, struct group *, char *, int);

to

    int getgrnam_r(const char *,struct group *,char *, size_t, struct group**);

for conformance with POSIX.1C.

getlogin_r()

The function prototype of getlogin_r() has changed from

    int getlogin_r (char *, int);

to

    int getlogin_r (char *, size_t);

for conformance with POSIX.1C.

getpwuid_r()

The function prototype of getpwuid_r() has changed from

int getpwuid_r(uid_t, struct passwd *, char *, int);

to

int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);

for conformance with POSIX.1C.

getpwnam_r()

The function prototype of getpwnam_r() has changed from

    int getpwnam_r(const char *, struct passwd *, char *, int);

to

    int getpwnam_r(const char *,struct passwd *,char *,size_t,struct passwd **);

for conformance with POSIX.1C.

gmtime_r()

The function prototype of gmtime_r() has changed from

    int gmtime_r(const time_t *, struct tm *);

to

    struct tm *gmtime_r(const time_t *, struct tm *);

for conformance with POSIX.1C.

localtime_r()

The function prototype of localtime_r() has changed from

    int localtime_r(const time_t *, struct tm *);

to

    struct tm *localtime_r(const time_t *, struct tm *);

for conformance with POSIX.1C.

readdir_r()

The function prototype of readdir_r() has changed from

    int readdir_r(DIR *, struct dirent *);

to

    int readdir_r(DIR *, struct dirent *,struct dirent **);

for conformance with POSIX.1C.

ttyname_r()

The function prototype of ttyname_r() has changed from

    int ttyname_r (int, char *, int);

to

    int ttyname_r (int, char *, size_t);

for conformance with POSIX.1C.

rand_r()

The function prototype of rand_r() has changed from

    int rand_r(long *, int *);

to

    int rand_r(unsigned int *);

for conformance with POSIX.1C.

NIS+/Dynamic Name Service Switch

The following APIs in libc now support the NIS+ name service in addition to the local file, NIS, and DNS (applicable only to hosts) name service access that was supported in HPUX 10.20.

endgrent()             endhostent()        endnetent()
endnetgrent() endprotoent() endpwent()
fgetgrent() fgetpwent() getgrent()
getgrgid() getgrgid_r() getgrnam()
getgrnam_r() gethostbyaddr() gethostbyname()
gethostent() getnetbyaddr() getnetbyname()
getnetent() getnetgrent() getprotobyname()
getprotobynumber() getprotoent() getpwent()
getpwnam() getpwnam_r() getpwuid()
getpwuid_r() innetgr() setgrent()
sethostent() setnetent() setnetgrent()
setprotoent() setpwent()

Note that if an application uses any of the above interfaces, either directly, or indirectly, it cannot be built as a fully archived application.

Applications using the above interfaces that link with archive libc:

  • might dump core due to unresolved symbols.

  • might resolve symbols from the shared version of libc at run time.

  • might have duplicate symbol definitions;

For linking with archive libc, follow the instructions in the section "Archive Internationalized Applications". Following these instructions will alleviate the problem, but will not guarantee a robust solution. It is recommended that applications using any of the above interfaces link with the shared version of libc.

See Chapter 2 of the Programming on HPUX manual (part number B2355-90652) for a discussion of the problems of mixing shared and archived libraries.

map_ids.c

For 10.30, code is added to bypass the nsswitch engine to force calls to local protected password database. The intent is to bypass NIS+.

If NISPLUS_COMSEC is not defined, map_ids.c functions as before.

modprpw.c

There is added support for NIS+; modprpw.c now uses private routines from libsec.

There are two new command line switches added:

-n domain

specifies to write information to NIS+ tables

-l

specifies to write information to local files only.

When adding a user, the system displays a random password of 8 characters instead of an admin number (for example, modprpw -A uid=uid user.

The admin number is not supported.

If built without NISPLUS_COMSEC defined, modprpw behaves as before.

Internationalization- and Localization-related Changes

multibyte.3c - mblen(), mbtowc(), mbstowcs(), wctomb(), wcstombs()

The multibyte routines have been corrected for several Asian locales.

The multibyte routines (mblen(), mbtowc(), mbstowcs(), wctomb(), and wcstombs()) in past releases have incorrectly identified certain invalid characters as valid for the ko_KR.eucKR, zh_CN.hp15CN, zh_TW.big5, and zh_TW.ccdc locales.

The locale definitions and method libraries have been modified so that these locales only recognize 7-bit ASCII single-byte values and the following two-byte values as valid characters:

Locale  First byte         Second byte
- - -
ko_KR.eucKR 0xa1-0xfe 0xa1-0xfe

zh_CN.hp15CN* 0xa1-0xfe 0xa1-0xfe
0xfb 0x3f-0x7e
0xfc-0xfe 0x21-0x7e

zh_TW.ccdc 0xa1-0xfe 0x21-0x7e,0xa1-0xfe

zh_TW.big5 0x81-0xfe 0x40-0x7e,0xa1-0xfe
NOTE: * The Simplified Chinese locale is no longer supported by the HP15 method library due to the unsymetrical nature of the UDC area. A new method library, libhp15CN.sl, has been created to support the zh_CN.hp15CN locale. To access this library, the -m option of localedef must be used with a method file that specifies the libhp15CN.sl library. See /usr/lib/nls/loc/src/zh_CN.hp15CN.m for an example.

The multibyte.3c routines will now exhibit the behaviour that is documented in the manpage. As the input methods for these languages do not support the invalid characters, this should not impact customer applications. Customers will now be able to use the multibyte routines to check for character validity.

There should be limited impact on performance in most cases. The simplified Chinese locale (zh_CN.hp15CN) user-defined character range ([0xfb,0x3f-0x7e] and [0xfc-0xfe,0x21-0x7e]) requires additional checks that will cause the routines to be slower for UDCs than the other character ranges.

No applications conforming to the documented behaviour will be affected. HP has made every attempt to verify that no applications depend on the prior behaviour.

The ability exists to create and use user-defined locales and method libraries use instead of the system-provided locales.

Miscellaneous libc changes

ttrace(),ttrace_wait(),sigwait(),pstat_getlwp(),ftrylockfile()

New interfaces for POSIX.1c support.

sendfile()

A new system call for transmitting the contents of a file across a socket connection. It can be used only when the socket is in a connected state.

vsnprintf(),snprintf()

These are new interfaces that provide sprintf() type of functionality without overflowing target buffers. The use of these interfaces is recommended in situations where buffer overflows may lead to a security breach.

basename(),dirname()

basename() and dirname() are now safe for usage in multi-threaded applications. In a multi-threaded application, basename() or dirname() will behave as described below:

  • If the pathname argument is a NULL string or an empty string, basename() and dirname() may return a pointer to a string literal.

  • For all other input strings, basename() and dirname() will modify the input string and return a pointer to the modified string.

There is no change in behavior for non-threaded applications. See the manpage for a detailed example on how to correctly use these interfaces.

HUGE_VAL,atof(),strtod(),wcstod(),printf(),scanf()

The value of the symbolic constant HUGE_VAL (defined in <math.h>) is changing to IEEE infinity. The interfaces atof(), strtod(), and wcstod() return HUGE_VAL under certain error conditions; these interfaces will return the new HUGE_VAL value starting with HPUX 10.30.

The printf(3C) family of C library routines will convert the special floating point values for infinity and not a number (NaN) as follows:

  • The e,f, and g conversions will print "inf" for infinity and "nan" for both quiet and signaling NaNs.

  • The E and G conversions will print "INF" for infinity and "NAN" for both quiet and signaling NaNs.

  • There will be a new F conversion specifier that will be identical to the f conversion specifier except that it will print infinity and NaN as respectively INF and NAN.

The scanf(3C) family of C library routines will add support for converting symbolic representations of infinity and NaN to their floating point representations:

  • The e, E, f, g, and G conversions will convert any string beginning with "inf" (case insensitive) to the appropriate floating point infinity value (single, or double precision, as specified by the conversion precision modifier).

  • The e, E, f, g, and G conversions will convert any string beginning with "nan" (case insensitive) to the appropriate floating point NaNQ value (single or double precision, as specified by the conversion precision modifier).

The strtod(3C) and atof(3C) C library routines will add support for converting symbolic representations of infinity and NaN to their floating point representations as follows:

  • When the input parameter character string for strtod (atof) begins with "inf" (case insensitive), strtod (atof) will return HUGE_VAL.

  • When the input parameter character string for strtod (atof) begins with "nan" (case insensitive), strtod (atof) will return _DNANQ.

The wcstod(3C) C library routine will add support for converting symbolic representations of infinity and NaN to their floating point representations analogously to the description for strtod(3C) above, namely:

  • If wcstod encounters an input wide-char string equal to respectively inf or nan (both case insensitive), it will return respectively HUGE_VAL or _DNANQ.

Customers who do not enable floating point exceptions (by default floating point exceptions are not enabled) and use comparison with DBL_MAX will be broken when floating point overflow occurs.

For example the value 1.0e10000 previously would have been converted by strtod() or scanf() to DBL_MAX (a finite representable double precision number). It will now be converted to the IEEE representation for double precision floating point infinity.

getcwd()

The getcwd(3C) interface has been changed to opportunistically pick up the current path prefix from the /etc/mnttab file. In earlier releases, getcwd() used to scan the complete path until / and do stat for almost all the entries in the directories encountered. Now if the scan crosses a mount point, it picks up the rest of the path from the /etc/mnttab file, possibly saving a considerable amount of time.

If any file system is mounted using a symbolic path, getcwd(3C) will return the current working directory including the symbolic mount point. Because the command pwd (/usr/bin/pwd) calls getcwd(3C) to print the working directory, it will also show a similar change in behavior.

If the current path does not cross any symbolic mount point, the getcwd(3C) behavior will be identical to the behavior in HPUX 10.20.

Depending upon variables, such as the number of NFS mounts, local mounts, number of entries in a directory and number of directories the current path have, a substantial performance improvement may result.

If the original path is symbolically linked to the current path, getcwd(3C) can be made to return the original path provided the mount command was issued with original path. In other words, if you want the getcwd(3C) to return the actual path (not the symbolic one), make sure you issue the mount command with the actual path.

getdate(), strptime()

The strptime(3c) routine now returns a null pointer for dates not representable by a time_t data type.

The strptime(3c) and getdate(3c) APIs are affected by the changes for the year 2000 rollover. Refer to the section "Support for Dates Beyond the Year 2000" in this document in Chapter 2 for details of the specific changes

strtold(3C)

Return values on error are now provided in stdlib.h as: _LDBL_MAX, _LDBL_NMAX, and _ZERO.

frexp(),ldexp(),modf()

frexp(), ldexp(), and modf() have been moved to the math library. Applications and libraries that reference these interfaces will now have to include -lm to link with these interfaces.

Support for _SC_LIBC_VERSION by sysconf()

This feature is to enable an application to identify the version of libc in use. The format of the value returned is as follows:

XXyyZZZZqNL

where

XX

is an HP-UX major release number (such as 10, 11, and so on).

yy

is an HP-UX minor release number (such as 00, 01, 10, and so on). 99 is reserved for unknown release.

ZZZZ

is a library-specific number:

q

0=32PA; 1=64PA; 2=32EM; 3=64EM; 4-9=Reserved

N

0 = archive library; 1-9 = SYSV version of shared library

perror(), strerror(), regex(), regerror(), getopt()

The perror(), strerror(), regex(), regerror(), and getopt() APIs are changed to support XPG4 messaging. A language-dependent message catalog returns error messages by these APIs. The environment variable NLSPATH searches this message catalog. If NLSPATH does not exist in the environment or if the message catalog cannot be found in any of the components specified by NLSPATH, an implementation-dependent default path is used. This default is affected by the setting of LC_MESSAGES.

setlocale(), iconv_open()

setlocale() in the 10.30 libc will load locales and methods from /usr/lib/nls/loc/locales.2 and /usr/lib/nls/loc/methods.2, respectively.

iconv_open() in the 10.30 libc will load codeset conversion methods from /usr/lib/nls/iconv/methods.2.

Developers of customized locales, methods and codeset conversion methods will need to deliver these libraries in the new locations described above if they are intended for use in applications built on 10.30.

Developers of customized locales, methods and codeset conversion methods will also need to deliver these libraries in the old locations (methods.1 and locales.1 directories) if they are intended for use in applications built on on prior releases.

Note that the use of setlocale() in applications linked with the archive version of libc is not recommended because it does not guarantee binary compatibility.

Internationalized applications using setlocale() that link with the archive version of libc will not work correctly unless they are built with the compiler option -Wl,-E. Refer to the section on localedef(1M) for details on building such applications.

Impact of libc Changes on Applications

This section describes the new features that impact application developers.

Impact on Fully Archive Bound Applications with No Dynamically-Loaded Components

No impact.

Impact on fully shared bound applications

Fully shared bound applications built on prior HPUX releases will not be impacted by the libc changes in HPUX 10.30, provided none of the third party libraries that are used by the application are rebuilt on 10.30.

If you are an application provider that relies on third-party libraries, see the section "Impact of libc Changes on Libraries" that describes the impact.

Source Compatibility

For applications that do a full rebuild, there is an impact on source compatibility in the APIs affected by the libnsl and Dynamic Name Service Switch related changes.

For details on the source compatibility impact, see the relevant section in this document.

Applications using APIs that will move to libd4r and libnsl need to make makefile changes to link with the new libraries.

Impact on Applications that Rely on Unsupported Linking Behavior

Suppose your application:

  • mixes components from different releases

  • binds all (or some) system libraries archived, but dynamically loads some shared libraries

Such applications are not guaranteed to work correctly for 10.30. For example, multi-threaded DCE applications that linked with archived libc and shared libdce on an earlier release will not run on HP-UX 10.30.

Impact on Applications that Call strptime(3c) and getdate(3c)

Applications that use these calls might have to change their source code to accommodate behavior changes. Refer to the section "Support for Dates Beyond the Year 2000" in this document in Chapter 2 for details of the specific changes.

Impact of libc Changes on Libraries

This section describes the new features that impact library providers.

Thread-specific errno, h_errno, and getdate_err

NOTE: This feature impacts thread-safe library providers only.

In traditional non-threaded applications on HP-UX, errno is a global integer. This traditional errno behavior works correctly in user space (DCE) multi-threaded applications because threads are managed in the user space and errno is a part of the context of an individual thread.

In HP-UX 10.30, with the introduction of 1x1 kernel threads, thread management is done within the kernel and therefore errno has to be managed on a per-thread basis.

The per-thread errno is implemented by mapping the symbol errno to an expression that is a modifiable lvalue managed on a per-thread basis when an application compiles with -D_REENTRANT.

How the thread-specific errno works:

  • All non-threaded applications continue to use global int errno.

  • All user space threads applications use the global int errno.

  • The main thread in a kernel threads application uses the global int errno — other threads in a kernel threads application use thread-specific storage.

This change has the following implications:

  • All thread-safe libraries must compile using -D_REENTRANT and obtain the errno definition from <errno.h>.

    If a library provider wants to provide restricted usability in a threaded application, doing the above step enables the usage of an otherwise non-thread-safe library from a single thread in a multi-threaded application.

  • errno is no longer a legal name for a structure member in a file that includes <errno.h> and is compiled with -D_REENTRANT. For example,

           #include <errno.h>

    struct foo {
    int errno ;
    };

    will not compile with -D_REENTRANT. The solution is to change errno to errnum.

    The variable getdate_err and the variable h_errno become a per-thread variable in a similar way. The names getdate_err and h_errno also are unusable for structure element names for source compiled with -D_REENTRANT that uses <time.h>.

  • If a shared library libother.sl is rebuilt on 10.30 to take advantage of the new per-thread-errno feature, it may break binary compatibility for applications linked against it on earlier releases. Specifically, applications that have linked with an archived libc and shared libother on a prior release will be broken. (Note that HP-UX does not support such linkage.) Applications linked with shared libc will not be broken.

    The solution is that the per-thread-errno feature is relevant only to applications using 1x1 kernel threads. Compilation with -D_REENTRANT is not required for libraries that will not be used in such applications.

    Application breakage can be prevented by versioning libother.1.

API Changes

To align with the POSIX.1c standard, the function prototypes of the following twelve libc APIs have been changed in HP-UX 10.30. The HP-UX 10.20 versions of these interfaces move to libd4r.

    asctime_r()
ctime_r()
getgrnam_r()
getgrgid_r()
getlogin_r()
getpwnam_r()
getpwuid_r()
gmtime_r()
localtime_r()
rand_r()
readdir_r()
ttyname_r()

Shared libraries that rely on these APIs and that have a need to continue supporting applications built on older HP-UX releases may have to version.

New libraries libnsl and libd4r

At 10.30, The RPC and YP APIs are moved to libnsl. The obsoleted HP-UX proprietary _r and _unlocked are moved to libd4r. Refer to the relevant sections in this section for specific details.

This change has the following implications for library providers: library providers either have to establish explicit dependencies on these libraries, or notify end users to also link one or both of these libraries for the application to link successfully.

Shared libraries with explicit dependency on libc

A shared library can be built by explicitly specifying on the command line the list of libraries that it depends on.

If a shared library has been built with -lc on its ld command line on HPUX 10.30, it has an explicit dependency on libc.2. If an attempt is made to use this library in an application built on a prior release (which is linked with libc.1), the application will be implicitly linking with both libc.1 and libc.2.

Thus, if a shared library is being built with -lc on its ld command line, it can either be used exclusively with applications built on HP-UX 10.30 (if it is rebuilt on HP-UX 10.30), or it can be used exclusively with applications built on older releases (if it is not rebuilt on HP-UX 10.30).

The recommended actions for impacted libraries are:

  1. Remove -lc from the ld line in HP-UX 10.30.

  2. If removing this dependency is not possible, version the impacted libraries.

Shared libraries with explicit dependency on HUGE_VAL

The value of the constant HUGE_VAL defined in <math.h> has changed to IEEE Infinity in 10.30. atof(), wcstod(), and strtod() return the value of HUGE_VAL under certain error conditions.

Libraries that rely on comparing the return values of atof(), wcstod(), and strtod() with HUGE_VAL will need to version in 10.30.

Changes for 10.20

getrlimit()

The default value that RLIM_FSIZE returned was 2GB - 511. The new default is RLIM_INFINITY.

lockf()/fcntl()

The lockf()/fcntl() interfaces previously did not allow locking of the byte at offset 2GB - 1. This byte is now lockable.

ulimit()

The default UL.FILESIZE that a process used to get was (2GB - 511)/512. The new default is 2GB/512. This value now corresponds to INFINITY in the kernel. Therefore, the default file size limit for a process is RLIM_INFINITY.

Changes for 10.10

UNIX 95 Conformance

As of HP-UX 10.10, HP-UX conforms to XPG4 and to the X/Open extensions to XPG4 (X/Open Portability Guide Issue 4 version 2). This means that HP-UX conforms to UNIX 95. See the individual commands for descriptions of changes.

New Functionality for 10.10

  • The following application programming interfaces have been added to libc(3):

    • bsd_signal

    • dbm_close

    • dbm_delete

    • dbm_fetch

    • dbm_firstkey

    • dbm_forder

    • dbm_init

    • dbm_nextkey

    • dbm_open

    • dbm_store

    • endutxent

    • getdtablesize

    • gethostid

    • getpagesize

    • getrusage

    • gettimeofday

    • getutxent

    • getutxid

    • getutxline

    • getwd

    • getcontext

    • killpg

    • makecontext

    • pututxline

    • pstat_getprocvm

    • pstat_getstable

    • random

    • re_comp

    • re_exec

    • regcmp

    • regex

    • setcontext

    • setstate

    • sighold

    • sigignore

    • sigrelse

    • sigset

    • setreuid

    • setutxent

    • sigaltstack

    • siginterrupt

    • srandom

    • swapcontext

    • ualarm

    • usleep

    • utimes

    • waitid

  • The functions makecontext, setcontext, swapcontext, and getcontext are only available in the archived version of libc.

  • The database management functions have been moved from libdbm.a and libndbm.a to libc. Both libdbm.a, libndbm.a and the corresponding shared libraries are now obsolete.

  • The functions initstate, setstate, random, and srandom have been moved from the math library to libc.

  • The SVID3 signal handling interfaces sighold, sigignore, sigrelse, and sigset have been moved from libV3.a to libc.

  • If UNIX95 is set as described in the section "UNIX95", the fourth parameter of the function passed to the nftw() call is now a pass-by-reference (not a pass-by-value as in previous releases). If UNIX95 is not set, the default behavior is the previous behavior (a pass-by-value).

  • The parameter passed to sigpause() is now a signal number, not as mask.

  • If the calling process is not already a session leader, setpgrp() sets the process group ID of the calling process to the process ID of the calling process. If setpgrp() creates a new session, the new session has no controlling terminal.

  • The XPG4 behavior is activated if you set the UNIX95 environment variable.

See the corresponding manpages for details.

Incompatibilities with Previous Versions

To conform to UNIX95, the following libc interfaces have changed and are now incompatible with previous versions:

The default for the above interfaces is the previous HP-UX behavior, which provides compatibility for existing applications. The XPG4 behavior is an option that is activated if you set the UNIX95 environment variable and include /usr/bin/xpg4 in the path for executables.

  • If UNIX95 is set as described in the section "UNIX95", the fourth parameter of the function passed to the nftw() call is now a pass-by-reference, not a pass-by-value as in previous releases. If UNIX95 is not set, the default behavior is the previous behavior (a pass-by-value).

  • The parameter passed to sigpause() is now a signal number, not a mask.

  • The behavior for the setpgrp() function is as follows:

    • If the calling process is not already a session leader, setpgrp() sets the process group ID of the calling process to the process ID of the calling process.

    • If setpgrp() creates a new session, the new session has no controlling terminal.

Additional Changes

  • getdate() - this function now conforms to XPG4 specifications. This function now recognizes leap seconds. In addition, the %r and %R formats work with the current locale for backwards compatibility.

  • syslog() — this function now conforms to XPG4 specifications. This function now returns void rather than int.

  • dbm_open() — the fourth parameter, formerly an int is now mode_t.

  • getmsg(), putmsg(), and getpmsg() — the last parameter of these functions, formerly a ''long'', has been changed to int.

  • setpriority() and getpriority() — the second parameter of these functions, formerly an int, has been changed to id_t.

  • poll — the second parameter, formerly an int, has been changed to nfsd_t.

  • tcgetsid() — the first parameter, formerly a pid_t, has been changed to int.

  • nftwh() — is now obsolete.

curses(3X)

  • Now conforms to the X/Open Curses, Issue 4 Specification, which includes support for color, new attributes, and codesets supported by libc.

  • The library libcurses.a has been removed.

  • libcurses.sl and /usr/include/curses.h have been replaced with a library that confirms to the X/Open Specification. However, the previous library is still available. The old header file is accessed by using the _HP_CURSES define on the command line with -D_HP_CURSES.

  • Linking .o files that were developed for use with the old curses is no longer supported with libcurses. These .o files can be linked with libHcurses (use -lHcurses).

  • You should begin movement to the new default curses library because the ability to use libHcurses and -D_HP_CURSES will eventually be removed.

Changes for 10.0

SVID3 and XPG4 Conformance

As of HP-UX 10.0, libc conforms to the X/Open Portability Guide Issue 4 (XPG4) and System V Interface Definition, third edition (SVID3).

XPG4 Base Profile Branding

XPG4 is the X/Open Portability Guide, Issue 4. HP-UX 10.x conforms to the "Base Profile", which consists of:

  • XPG4 Internationalized System Interfaces and Headers

  • XPG4 Commands and Utilities (Historical Compatibility)

  • XPG4 C Language (ANSI C)

HP-UX has passed the VSX4 test suite; HP has received certificates from X/Open certifying HP-UX's conformance to the above components and to the profile.

The next section summarizes the changes that were made at 10.0.

Summary of Changes for XPG4

The following tables list the new features and significant bug fixes.

Changes to libc
Routine         Change
===========================================================


catopen New NL_CAT_LOCALE processing.
iconv* New iconv(), iconv_open(), iconv_close()
functions.
nl_langinfo New ALT_DIGITS, ERA, ERA_D_T_FMT, ERA_T_FMT
processing.
printf New grouping specifier functionality (') to
printf() family of functions.
strfmon New strfmon() function, and new header
file monetary.h.
strptime New strptime() function.

For more information, see the "New Behavior in Replacement Routines", "iconv", and "XPG4 Conformance" sections in the README for NLS in 10.01.

Changes to libM
Routine         Change
===========================================================

y0/y1/yn Bug fix: y0(0.0), y1(0.0), yn(3.0,0.0)
now return HUGE_VAL.
log/log10 Bug fix: log(0.0), log10(0.0) now return
ERANGE.

See “Math Library Routines (libm, libM) ” later in this chapter for more information.

Changes to Commands
Routine         Change
===========================================================

tar Bug fix: tar now handles 100 character
link name properly.
type Added exec'able version of POSIX shell
built-in command.
patch Created dummy command. Full functionality
will be in next major HP-UX release (after
10.x).
talk Created dummy command. Full functionality
will be in next major HP-UX release.
Changes to Headers
Routine         Change
===========================================================

glob.h Added new GLOB_NOSYS #define.
iconv.h Added new function prototypes for iconv(),
iconv_open() and iconv_close().
langinfo.h Added new ALT_DIGITS, ERA, ERA_D_T_FMT,
ERA_T_FMT #defines.
Corrected _NL_ITEM_MAX #define.
monetary.h New header file
nl_types.h Added new NL_CAT_LOCALE #define.
Added new strord() function prototype.
regex.h Added new REG_ENOSYS #define.
wchar.h Corrected wcschr(), wcsrchr() and wcwidth()
prototypes.
wordexp.h Added new WRDE_NOSYS #define.
sys/fcntl.h Cloned definitions of S_ISUID and S_ISGID
from sys/stat.h.
sys/ipc.h Added definition of mode_t; used it for
struct ipc member "mode". Hid struct ipc
members "ndx" and "wait" with __
(except in _KERNEL).
sys/msg.h Added definitions of msgqnum_t and msglen_t.
Used msgqnum_t for msg_qnum, and msglen_t
for msg_qbytes and msg_ts. Corrected ANSI
prototypes of msgrcv() and msgsnd()to match
manpage.
sys/shm.h Added definition of shmatt_t.
Used shmatt_t for struct msg members
"shm_nattch" and "shm_cnattch".
Corrected ANSI prototype of shmget() to
match manpage.
sys/stat.h Protected S_ISUID and S_ISGID against
redefinition.
sys/time.h Added ANSI prototype and external
declaration of strptime().

Certain additional changes to HP-UX commands were made for consistency with XPG4 specifications. These changes affect all the utilities in the HP-UX CMDS-MIN fileset. They support the use of the LC_MESSAGES environment variable for selecting localized message catalogs. HP will make similar changes to other commands in a future release to provide a completely consistent messaging environment.

How This Affects Your Code

The declarations of some functions have changed (as shown above), so programmers may see compilation warning messages in some instances. The programmer can either ignore these messages, or update the source code to conform to the new declarations. (In most cases, external function declarations in application source code can just be deleted, as these are provided in the system header files).

To get a consistent messaging environment across all HP-provided applications and utilities, set the new LC_MESSAGES environment variable to match the LANG or LC_ALL environment variable, since some utilities and most applications are still using LANG rather than LC_MESSAGES.

In future releases, HP will modify all HP utilities to use LC_MESSAGES instead of LANG for message catalog selection.

See the NL_CAT_LOCALE information in the catopen(3C) manpage for information on how to make this change to your own internationalized utilities and applications.

New libc Routines at 10.0

The following routines were new at 10.0 on the Series 700, Series 800, or both.

New on Both Series 700 and S800
======================================

authdes_create key_gendes
basename key_setsecret
authdes_getucred lckpwdf
clearenv netname2host
dirname netname2user
endspent putws
getnetname re_comp
getspent re_exec
getspnam remque
grantpt setspent
host2netname sigsend
iconv sigsendset
iconv_close strfmon
iconv_open strptime
insque tcgetsid
isastream ulckpwdf
key_decryptsession unlockpt
key_encryptsession user2netname
yp_update
New on Series 700;      New on Series 800;
already on Series 800 already on Series 700
===================== =====================

blmode getclock
endfsgent gettimer
getfsgdef mktimer
getfsgent reltimer
getfsgid rmtimer
getfsgnam setclock
getfsguser
setfsgent
setfsgfil

For more information, see “Commercial Security ” and the "New and Changed Commands and Routines" and "iconv(3C)" sections in the README for NLS in 10.01.

For full details of all these routines, see the corresponding manpages or section 3 of the HP-UX Reference.

lckpwdf(3C), ulckpwdf(3C)

These routines have been added to conform to the SVR4 specification. They provide programmatic access to a standard locking mechanism for controlling access to the /etc/passwd file. Any program that modifies /etc/passwd should be modified to call these routines.

lckpwdf locks /etc/passwd; ulckpwdf unlocks it.

See also “Commercial Security ”.

libc Changes to Support Threads

libc routines now support threads. Most of the routines that have been modified will continue to work in a threaded application as they did in non-threaded ones, requiring no changes on the part of a programmer porting code to a threaded environment.

But in some cases the interface had to be changed, and in these cases HP-UX 10.x provides two versions of the routine: the original version for non-threaded applications, and a new version for threaded applications. For a list of these new thread-safe routines, see “Thread-Safe Routines ” later in this section.

In addition, HP has provided new routines to support locking. For a list of these, see “New libc Routines for Locking in Threaded Applications ” later in this section.

A few routines behave slightly differently in a threaded as opposed to a non-threaded context; these are discussed under “libc Routines that Behave Differently in Threaded Applications ” later in this section.

A small number of libc routines are not supported for threaded applications. For a list of these, see “libc Routines Not Supported for Threaded Applications ”.

Thread-Safe Routines

In each case that required an interface change, HP is delivering a new, thread-safe routine alongside the existing, non-threaded routine. The name of the thread-safe version is the name of the existing routine plus the suffix _r; for example, the thread-safe version of acltostr is acltostr_r.

New, thread-safe routines in libc are:

acltostr_r           getlogin_r              nrand48_r
asctime_r getmntent_r ptsname_r
crypt_r getnetbyaddr_r pututline_r
ctime_r getnetbyname_r rand_r
drand48_r getnetent_r readdir_r
ecvt_r getprotobyname_r seed48_r
encrypt_r getprotobynumber_r setgrent_r
endgrent_r getprotoent_r sethostent_r
endhostent_r getpwent_r setkey_r_r
endnetent_r getpwnam_r setlocale_r
endprotoent_r getpwuid_r setnetent_r
endpwent_r getservbyname_r setprotoent_r
endservent_r getservbyport_r setpwent_r
endusershell_r getservent_r setservent_r
endutent_r getutid-r setusershell_r
erand48_r getutent_r setutent_r
fcvt_r getusershell_r srand48_r
fgetgrent_r getutline_r strerror_r
fgetpwent_r gmtime_r strtoacl_r
getdate_r inet_ntoa_r strtoaclpatt_r
getdiskbyname_r jrand48_r strtok_r
getgrent_r l64a_r ttyname_r
getgrgid_r lcong48_r ultoa_r
getgrnam_r localtime_r ultostr_r
gethostbyaddr_r lrand48_r utmpname_r
gethostbyname_r ltoa_r wcstok_r
gethostent_r ltostr_r
getlocale_r mrand48_r

New, thread-safe routines in libsec are:

endspwent_r
getspwaid_r
getspwaid_r
getspwent-r
getspwnam_r
getspuid_r
setspwent_r

For more information on routines in libsec, refer to "Shadow Password Routines" in the "Compatibility with 9.x Releases" section of the Upgrading from HP-UX 9.x to 10.x manual.

New libc Routines for Locking in Threaded Applications

The following routines support locking in threaded applications:

flockfile
funlockfile

flockfile and funlockfile explicitly lock and unlock a FILE object. But a programmer may not need to incur the overhead of locking and unlocking the file on every call.

The programmer can minimize the locking overhead for a series of calls in a threaded application by using the following new routines, which ensure exclusive access to a file for a series of _unlocked stdio calls:

clearerr_unlocked   fseek_unlocked      putwchar_unlocked
fclose_unlocked ftell_unlocked putws_unlocked
feof_unlocked fwrite_unlocked rewind_unlocked
ferror_unlocked getc_unlocked setvbuf_ulocked
fflush_unlocked getchar_unlocked ungetc_unlocked
fgets_unlocked getw_unlocked
fgetwc_unlocked getwc_unlocked
fgetws_unlocked getwchar_unlocked
fileno_unlocked putc_unlocked
fputs_unlocked putchar_unlocked
fputwc_unlocked puts_unlocked
fputws_unlocked putw_unlocked
fread_unlocked putwc_unlocked
libc Routines that Behave Differently in Threaded Applications

The following routines have slightly different semantics when called from a multi-threaded application using a NULL pointer.

ctermid
cuserid
tmpnam

These routines are called with a pointer to a buffer in which the result is to be stored. For non-threaded applications, providing a NULL pointer indicates that the routine is to store the result in an internal static buffer and return a pointer to that internal buffer. But if a NULL pointer is passed to one of these routines from a multi-threaded application, the operation is not performed and a NULL pointer is returned.

libc Routines Not Supported for Threaded Applications

The following routines are not supported for use in threaded applications and have no corresponding thread-safe version.

authdes_getucred        getrpcbyname
authnone_create getrpcbynumber
bindresvport getrpcent
callrpc gettransient
clnt_create hcreate
clnt_pcreateerror hdestroy
clnt_perrno innetgr
clnt_perror registerrpc
clnt_spcreateerror remexportent
clnt_sperrno setnetgrent
clnt_sperror setrpcent
endnetgrent svc_register
endrpcent svc_unregister
getexportent xprt_register
getexportopt xprt_unregister
getnetgrent

The 10.0 File System Layout and libc

Applications that were created on pre-10.0 HP-UX releases may need transition links to work properly on 10.x.

Transition links are a mechanism that HP is providing as part of HP-UX 10.x to help ensure binary compatibility with pre-10.0 releases; they link 9.x pathnames to their 10.x equivalents.

NOTE: Transition links are in effect by default on all 10.x systems. (See the Upgrading from HP-UX 9.x to 10.x manual for more information.)

Applications that will make use of the transition links include those that call any of the following functions, directly or indirectly:

 confstr    ftw           getusershell   sysconf
devnm getdate msemlock system
dial getfsent nftw tempnam
endfsent getfsfile popen undial
execlp getfsspec setfsent wordexp
execvp getfstype

Other Changes to libc Routines

This section discusses the following routines:

  • closelog(3C)

  • crypt(3C)

  • fnmatch(3C)

  • glob(3C), globfree(3C)

  • nftw(3C)

  • openlog(3C)

  • regcomp(3C), regexec(3C), regfree(3C), regerr(3C)

  • setlocale(3C)/iconv(3C)

  • wordexp(3C), wordfree(3C)

See also the next section of this document, “Math Library Routines (libm, libM) ”, the README for NLS in 10.01, and the "Compatibility with 9.x Releases" section of the Upgrading from HP-UX 9.x to 10.x manual for a summary of the affects of library changes on application code.

closelog(3C)

10.x closelog conforms to COSE XPG4.2 (SPEC1170); it returns void rather than int.

crypt(3C)

In the past, when the edflag was non-zero (requesting decryption), encrypt() would return an error. The decrypt capability of the encrypt() function is now available; you no longer need to get a special patch from HP and link in /usr/lib/libcrypt with your applications in order to do decryption.

fnmatch(3C)

fnmatch has changed in the following ways:

  • Treatment of "[.", "[=", and "[:" characters within bracketed expressions.

    The sequences "[.", "[=" and "[:" are now treated as special within bracketed expressions. They must be used to represent collation characters, equivalence classes, or ctypes, and they must also be properly formed.

    To represent the characters "[", "." (period),"=", and ":" (colon) within a bracketed expression, make sure you do not order the characters so as to form the above sequences.

    For example, an expression for a sequence of "a" followed by "[" or "." (period) would be formed as follows:

    a[.[]

    See also “regcomp(3C), regexec(3C), regfree(3C), regerr(3C) ”

  • Header fnmatch.h:

    • The flag FNM_QUOTE has been added. Its meaning is the inverse of FNM_NOESCAPE.

    • The following error messages have been added:

      FNM_ESLASH * ? [] can't match /
      FNM_EPERIOD * ? [] can't match .
glob(3C), globfree(3C)

For 10.0:

  • Context-dependent files (CDFs)

    CDFs were no longer supported as of HP-UX 10.0. If glob is used against a disk containing CDF, they will look like directories.

  • Directory names in matched strings

    The trailing slash (/) in a directory name is now included as part of the sorting key when matched strings are being sorted.

  • Header glob.h:

    • Values for some flags and error codes have changed.

    • The flag LIB-OTHER-GLOB_QUOTE has been added.

      It creates the backslash character (\), which protects the next character.

Do not mix calls to 9.x glob() and globfree() with calls to their 10.x equivalents; see "Specific Guidelines for Moving Code from 9.x to 10.01" in the "Compatibility with 9.x Releases" section of the Upgrading from HP-UX 9.x to 10.x manual.

nftw(3C)

10.x nftw passes the constant FTW_SLN to the passed function fn whenever the target is a dangling symbolic link.

In a future release, nftw(3C) may be further changed for COSE XPG4.2 (SPEC1170) compliance, to pass the address of the struct FTW which is passed to the called function fn. The existing prototype,

extern int nftw(const char *path,
int(*fn)(const char *, const struct stat *, int,
struct FTW), int depth, int flags);

would become:

extern int nftw(const char *path, int(*fn)
(const char *, const struct stat *, int, struct FTW *),
int depth, int flags);

Such a change would require source code changes to application code which calls nftw.

openlog(3C)

10.x openlog, like closelog, returns void rather than int.

regcomp(3C), regexec(3C), regfree(3C), regerr(3C)

For 10.0:

  • Treatment of "[.", "[=", and "[:" characters within bracketed expressions.

    See “fnmatch(3C) ” earlier in this section.

  • Treatment of ^ and $ anchors in Extended Regular Expression (ERE).

    The use of duplication characters (+, *) following anchors is now illegal. The error message returned by regcomp() is REG_EEOL or REG_BOL.

  • Anchor characters incorrectly placed.

    Anchor characters incorrectly placed in an expression now cause the error REG_EEOL.

  • Flags removed:

    • _REG_ALT

    • _REC_C_ESC

  • Header regex.h:

    • Values for some flags and error codes have changed.

    • The following error values have been removed:

      REG_ENEWLINE

      \n found before end of pattern and REG_NEWLINE flag not set

      REG_ENSUB

      more than nine \( \) pairs or nesting level too deep

      REG_EMEM

      Out of memory while matching expression

      REG_ENOSEARCH

      No remembered search string

      REG_EDUPOPER

      Duplication operator in illegal position

      REG_ENOEXPR

      No expression with () or on one side of an `|'

    • The following error codes have been added:

      REG_EBOL

      Anchor character ^ not at beginning of line

      REG_EEOL

      Anchor characters $ not at end of line

      REG_ECHAR

      Invalid multibyte character

    • The regex_t structure has changed. All internal data structures have been encapsulated. Only the members defined by XPG4 are visible.

How This Affects Your Code

  • Applications that have hardcoded return codes and flags may have to be modified.

    But code using the standard constants defined in the regex.h header file should not have any problems.

  • The regex_t data structure is larger than the 9.x version.

setlocale(3C)/iconv(3C)

For information on setlocale(3C)/iconv(3C) see the Locales section of the README for NLS in 10.01 (online as /usr/lib/nls/README.nls.10.01).

wordexp(3C), wordfree(3C)

Change:

  • The error code WRDE_SYNTAX in some cases may be returned in place of WRDE_BADCHAR.

See also "Pattern-Matching Routines Mixed in Unusual Ways" in the "Compatibility with 9.x Releases" section of the Upgrading from HP-UX 9.x to 10.x manual.

libc Routines No Longer Supported

The following three categories of routines were no longer supported as of 10.0:

  • HP-proprietary routines for HP-UX clusters.

  • Many HP-proprietary routines for NLS (see "Routines and Macros No Longer Supported" and "New Behavior in Replacement Routines" in the README for NLS in 10.01).

For more information and advice, programmers should read "Specific Guidelines for Moving Code from 9.x to 10.01" in the "Compatibility with 9.x Releases" section of the Upgrading from HP-UX 9.x to 10.x manual.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997, Hewlett-Packard Development Company, L.P.