| United States-English |
|
|
|
![]() |
Release Notes for HP-UX 10.30: HP 9000 Computers > Chapter 9 Commands and Libraries Library Routines (libc) |
|
This section covers the following topics:
NLS (Native Language Support) changes to libc are covered in the README for NLS in 10.01. Starting with 10.30, the C runtime library has added support for the following:
Summary of changes:
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.
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. 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
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. The function prototype of asctime_r() has changed from
to
for conformance with POSIX.1C. The function prototype of ctime_r() has changed from
to
for conformance with POSIX.1C. The function prototype of getgrgid_r() has changed from
to
for conformance with POSIX.1C. The function prototype of getgrnam_r() has changed from
to
for conformance with POSIX.1C. The function prototype of getlogin_r() has changed from
to
for conformance with POSIX.1C. The function prototype of getpwuid_r() has changed from
to
for conformance with POSIX.1C. The function prototype of getpwnam_r() has changed from
to
for conformance with POSIX.1C. The function prototype of gmtime_r() has changed from
to
for conformance with POSIX.1C. The function prototype of localtime_r() has changed from
to
for conformance with POSIX.1C. The function prototype of readdir_r() has changed from
to
for conformance with POSIX.1C. The function prototype of ttyname_r() has changed from
to
for conformance with POSIX.1C. 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.
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:
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. 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. There is added support for NIS+; modprpw.c now uses private routines from libsec. There are two new command line switches added:
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. 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:
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. 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. 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() and dirname() are now safe for usage in multi-threaded applications. In a multi-threaded application, basename() or dirname() will behave as described below:
There is no change in behavior for non-threaded applications. See the manpage for a detailed example on how to correctly use these interfaces. 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 scanf(3C) family of C library routines will add support for converting symbolic representations of infinity and NaN to their floating point representations:
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:
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:
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. 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. 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 Return values on error are now provided in stdlib.h as: _LDBL_MAX, _LDBL_NMAX, and _ZERO. 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. This feature is to enable an application to identify the version of libc in use. The format of the value returned is as follows:
where
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() 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. This section describes the new features that impact application developers. 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. 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. Suppose your application:
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. This section describes the new features that impact library providers.
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:
This change has the following implications:
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.
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. 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. 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:
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. The default value that RLIM_FSIZE returned was 2GB - 511. The new default is RLIM_INFINITY. The lockf()/fcntl() interfaces previously did not allow locking of the byte at offset 2GB - 1. This byte is now lockable. 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.
See the corresponding manpages for details. 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.
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 is the X/Open Portability Guide, Issue 4. HP-UX 10.x conforms to the "Base Profile", which consists of:
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. The following tables list the new features and significant bug fixes.
For more information, see the "New Behavior in Replacement Routines", "iconv", and "XPG4 Conformance" sections in the README for NLS in 10.01.
See “Math Library Routines (libm, libM) ” later in this chapter for more information.
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. 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. The following routines were new at 10.0 on the Series 700, Series 800, or both.
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. 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 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 ”. 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:
New, thread-safe routines in libsec are:
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. The following routines support locking in threaded applications:
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:
The following routines have slightly different semantics when called from a multi-threaded application using a NULL pointer.
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. The following routines are not supported for use in threaded applications and have no corresponding thread-safe version.
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.
Applications that will make use of the transition links include those that call any of the following functions, directly or indirectly:
This section discusses the following routines:
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. 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 has changed in the following ways:
For 10.0:
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. 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,
would become:
Such a change would require source code changes to application code which calls nftw. For 10.0:
How This Affects Your Code
The following three categories of routines were no longer supported as of 10.0:
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. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||