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

Re: reentrant functions in Linux/glibc-2.1

From: joe bester <bester@mcs.anl.gov>
Date: Tue, 14 Sep 1999 12:39:24 -0500
Message-Id: <199909141739.MAA03960@pitcairn-9.mcs.anl.gov>
To: WWWLIB Mailing List <www-lib@w3.org>
AIX and HPUX have another set of these defintions. (HPUX is also missing
the declaration of h_errno in the <netdb.h> header.)

These prototypes for these functions are
int gethostbyname_r(const char *name,
		    struct hostent *result,
		    struct hostent_data *buffer);

int gethostbyaddr_r(const char *addr,
                    int len,
		    int type,
		    struct hostent *result,
		    struct hostent_data *buffer);

The hostent_data structure is defined in netdb.h, and is filled in to
contain the pointed-to data in the hostent struct.

I've written some code to deal with several gethostbyname_r,
gethostbyaddr_r, and ctime_r variants for the project I work on.
If you'd like, I can send it to the list. 

joe

But then Bjoern Voigt wrote this:
> 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=3D\"/usr/local/share/w3c-l=
> ibwww\" -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 incompatibl=
> e pointer type
> HTDNS.c:287: too few arguments to function `gethostbyname_r'
> HTDNS.c:287: warning: assignment makes pointer from integer without a cas=
> t
> HTDNS.c: In function `HTGetHostBySock':
> HTDNS.c:331: warning: passing arg 7 of `gethostbyaddr_r' from incompatibl=
> e pointer type
> HTDNS.c:331: too few arguments to function `gethostbyaddr_r'
> HTDNS.c:331: warning: assignment makes pointer from integer without a cas=
> t
> 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 =3D 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,=20
>                              struct hostent *restrict RESULT_BUF,=20
>                              char *restrict BUF,=20
>                              size_t BUFLEN,=20
>                              struct hostent **restrict RESULT,=20
>                              int *restrict H_ERRNOP);
> 
> There are some other reentrant functions which are incorrectly used:
> 
>         gethostbyaddr_r(), ctime_r(), readdir_r()=20
> 
> 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.
> 
> --=20
> Bj=F6rn Voigt <bjoern@cs.tu-berlin.de>
> WWW:     http://www.cs.tu-berlin.de/~bjoern
> 
> 
Received on Tuesday, 14 September 1999 13:39:26 UTC

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