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.20: HP 9000 Computers > Chapter 7 Commands and Libraries

Library Routines (libc)

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

This section covers the following topics:

  • 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.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 effects 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
© Hewlett-Packard Development Company, L.P.