6.15. HP-UX and Linux APIs
Linux 2.6 comes with the latest GNU C library. As of this writing, the latest release of the GNU glibc is 2.3.3. As seen in the preceding section, the GNU libc distribution installs several libraries, which may come in both archived and shared form. The main objective of this section is to compare HP-UX APIs as documented in the HP-UX version 11 man pages and GNU libc as referenced through available online manuals, header files, and Linux man pages.
Note that APIs that come standard on HP-UX have not been implemented on Linux through the GNU libc project but through other open-source projects. An example of this is the SLP (Service Location Protocol) library routines, which for Linux are handled by the OpenSLP project.
6.15.1. glibc Version
The C library used on every Linux system is the GNU libc. Much of the interface of the GNU libc has been determined by the history of UNIX and various standards. The GNU libc supports most standards that modern UNIX systems support today, such as ISO C and POSIX standards. The GNU libc also supports features of the two major UNIX variantsnamely, BSD and System V. To learn what version of glibc you have on your installation, run /lib/libc.so. Just type the following on the command line:
$ ./libc.so.6 GNU C Library stable release version 2.3.3, by Roland McGrath et al. Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3). Compiled on a Linux 2.4.20 system on 2004-10-27. Available extensions: GNU libio by Per Bothner crypt add-on version 2.1 by Michael Glad and others Native POSIX Threads Library by Ulrich Drepper et al The C stubs add-on version 2.1.2. BIND-8.2.3-T5B NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk Glibc-2.0 compatibility add-on by Cristian Gafton GNU Libidn by Simon Josefsson Thread-local storage support included. For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>.
Note that the libc.so output uses the Native POSIX Threads library by Ulrich Drepper. On some Linux installations, libc.so may still be using the POSIX Threads library by Xavier Leroy, as shown by the following output:
$ ./libc.so.6 GNU C Library stable release version 2.3.3 (20040405), by Roland McGrath et al. Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Configured for i686-suse-linux. Compiled by GNU CC version 3.3.3 (SUSE Linux). Compiled on a Linux 2.6.4 system on 2004-04-05. Available extensions: GNU libio by Per Bothner crypt add-on version 2.1 by Michael Glad and others linuxthreads-0.10 by Xavier Leroy GNU Libidn by Simon Josefsson NoVersion patch for broken glibc 2.0 binaries BIND-8.2.3-T5B libthread_db work sponsored by Alpha Processor Inc NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk Thread-local storage support included. Report bugs using the 'glibcbug' script to <firstname.lastname@example.org>.
6.15.2. glibc Conformance
GNU glibc distributes a conformance report detailing adherence to various standards. This list also shows where GNU libc needs to be improved. As of this writing, the conformance report shows that GNU libc passes conformance header checks to FIPS, POSIX90, XPG3, XPG4, POSIX96, UNIX98, ANSI, C89/99, and ISO 9899 standards. All major distributions' glibc implementations also support the LSB.
Table C-4 in appendix C shows HP-UX calls and their equivalent API calls on Linux as implemented through the GNU libc distribution.
6.15.3. Some HP-UX Nonportable Programming Practices
As the preceding comparison tables of system and library APIs show, some HP-UX calls and programming practices are not portable to the Linux platform. Table 6-22 highlights some of the top incompatible APIs that may be encountered when porting HP-UX applications to Linux.
Caution is advised when using the equivalent Linux solutions presented. This list is presented only as a reference and not as officially recommended solutions. Investigate the viability of the solutions before planning to implement them in your applications.