KO Myung-Hun wrote: > diff --git a/lib/netdb.in.h b/lib/netdb.in.h > index e8ba8f0978..9cad2d937a 100644 > --- a/lib/netdb.in.h > +++ b/lib/netdb.in.h > @@ -103,7 +103,7 @@ struct addrinfo > # define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ > # endif > > -# if 0 > +# ifndef AI_NUMERICHOST > # define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ > # endif
This lacks test and documentation. Let me start by adding that, consistently. 2025-02-12 Bruno Haible <br...@clisp.org> netdb-h: Ensure AI_NUMERICHOST and AI_NUMERICSERV are defined. * lib/netdb.in.h (AI_NUMERICHOST): New macro. * tests/test-netdb-h.c: Verify that AI_NUMERICHOST and AI_NUMERICSERV are defined. * doc/posix-headers/netdb.texi: Mention the platform support for AI_NUMERICHOST and AI_NUMERICSERV. diff --git a/doc/posix-headers/netdb.texi b/doc/posix-headers/netdb.texi index aaaf05b23f..be1d8491c3 100644 --- a/doc/posix-headers/netdb.texi +++ b/doc/posix-headers/netdb.texi @@ -25,6 +25,14 @@ This header file does not define @code{AI_ADDRCONFIG} on some platforms: NetBSD 5.0. +@item +This header file does not define @code{AI_NUMERICHOST} on some platforms: +HP-UX 11.11. + +@item +This header file does not define @code{AI_NUMERICSERV} on some platforms: +macOS 10.5, HP-UX 11.11, mingw. + @item @c Defined in RFC 2553. This header file incorrectly defines @code{NI_MAXHOST} on some platforms: diff --git a/lib/netdb.in.h b/lib/netdb.in.h index e8ba8f0978..22059ea044 100644 --- a/lib/netdb.in.h +++ b/lib/netdb.in.h @@ -99,12 +99,11 @@ struct addrinfo # ifndef AI_CANONNAME # define AI_CANONNAME 0x0002 /* Request for canonical name. */ # endif -# ifndef AI_NUMERICSERV -# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ +# ifndef AI_NUMERICHOST +# define AI_NUMERICHOST 0x0004 /* Return numeric host address as name. */ # endif - -# if 0 -# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# ifndef AI_NUMERICSERV +# define AI_NUMERICSERV 0x0400 /* Return service number as service name. */ # endif /* These symbolic constants are required to be present by POSIX, but diff --git a/tests/test-netdb-h.c b/tests/test-netdb-h.c index cebd54855a..d2be1c8cc9 100644 --- a/tests/test-netdb-h.c +++ b/tests/test-netdb-h.c @@ -29,6 +29,9 @@ struct hostent t1; /* Check that the 'socklen_t' type is defined. */ socklen_t t2; +int ai1 = AI_NUMERICHOST; +int ai2 = AI_NUMERICSERV; + int main (void) {