curl-library
Detection of HAVE_GETADDRINFO_THREADSAFE in configure
Date: Tue, 20 Mar 2012 18:00:58 +0100
Hello,
In the configure script, the program to detect whether
getaddrinfo is thread-safe is (pre-processor directives
omitted for brevity):
int main (void)
{
#ifdef h_errno
return 0;
#else
force compilation error
#endif
}
There are two problems with this strategy.
1) In the latest POSIX standard (Issue 7), h_errno has been removed
altogether.
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netdb.h.html
> The obsolescent h_errno external integer, and the obsolescent gethostbyaddr(),
> and gethostbyname() functions are removed, along with the HOST_NOT_FOUND,
> NO_DATA, NO_RECOVERY, and TRY_AGAIN macros.
2) In the previous POSIX standard (Issue 6), h_errno existed,
but it didn't have to be a macro.
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html
> When the <netdb.h> header is included, h_errno shall be available as a modifiable
> lvalue of type int. It is unspecified whether h_errno is a macro or an identifier
> declared with external linkage.
Thus if h_errno is an identifier declared with external linkage,
the macro test will fail.
Now what?
getaddrinfo is thread-safe /by definition/
(both in Issue 6 and in Issue 7)
http://pubs.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html
> The freeaddrinfo() and getaddrinfo() functions shall be thread-safe.
Maybe it would be sufficient to test for the POSIX feature macro?
http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
int main (void)
{
#if _POSIX_C_SOURCE >= 200112L (or 199506L ??)
return 0;
#else
force compilation error
#endif
}
Comments?
-- Regards. ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2012-03-20