W3C home > Mailing lists > Public > www-lib@w3.org > July to September 1999

reentrant functions in Linux/glibc-2.1

From: Bjoern Voigt <bjoern@cs.tu-berlin.de>
Date: Sat, 11 Sep 1999 14:43:35 +0200 (CEST)
To: WWWLIB Mailing List <www-lib@w3.org>
Message-ID: <Pine.LNX.4.10.9909111357010.11878-100000@chemnitz.dialup.cs.tu-berlin.de>
If I try to compile the newest CVS source of the libwww on a linux
system (SuSE 6.2 with kernel 2.2.12 and glibc-2.1) with support for
reentrant functions (configure --enable-reentrant) I get several error
messages. For instance:

gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I/usr/local/include -I../../modules/md5 -I../../modules/expat/xmlparse -DW3C_ICONS=\"/usr/local/share/w3c-libwww\" -g -O2 -D_REENTRANT -Wp,-MD,.deps/HTDNS.pp -c  -fPIC -DPIC HTDNS.c -o .libs/HTDNS.lo
  HTDNS.c: In function `HTGetHostByName':
HTDNS.c:287: warning: passing arg 5 of `gethostbyname_r' from incompatible pointer type
HTDNS.c:287: too few arguments to function `gethostbyname_r'
HTDNS.c:287: warning: assignment makes pointer from integer without a cast
HTDNS.c: In function `HTGetHostBySock':
HTDNS.c:331: warning: passing arg 7 of `gethostbyaddr_r' from incompatible pointer type
HTDNS.c:331: too few arguments to function `gethostbyaddr_r'
HTDNS.c:331: warning: assignment makes pointer from integer without a cast
make[4]: *** [HTDNS.lo] Error 1

The reason is a incorrectly use of reentrant functions. In HTDNS:287
(version 2.30) the function gethostbyname_r() is used as

	hostelement = gethostbyname_r(hostname, &result, buffer,
				      HOSTENT_MAX, &thd_errno);

This may be valid for some systems (solaris 2.6, etc.). But in
glibc-2 systems gethostbyname_r() should be used as

        int gethostbyname_r (const char *restrict NAME, 
                             struct hostent *restrict RESULT_BUF, 
                             char *restrict BUF, 
                             size_t BUFLEN, 
                             struct hostent **restrict RESULT, 
                             int *restrict H_ERRNOP);

There are some other reentrant functions which are incorrectly used:

        gethostbyaddr_r(), ctime_r(), readdir_r() 

The function are documented in the glibc-Info-Docs. Because there are
two (Solaris, glibc) or more different headers for the reentrant
functions, the configure-script should respect this.

-- 
Björn Voigt <bjoern@cs.tu-berlin.de>
WWW:     http://www.cs.tu-berlin.de/~bjoern
Received on Saturday, 11 September 1999 08:49:48 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:17 UTC