changeset 10786:532bb85195db

Use substituted macros instead of C preprocessor macros.
author Bruno Haible <bruno@clisp.org>
date Tue, 11 Nov 2008 01:23:24 +0100
parents 044bd6e92c7f
children 14671fbf0b74
files ChangeLog lib/netdb.in.h m4/getaddrinfo.m4 m4/netdb_h.m4 modules/netdb
diffstat 5 files changed, 48 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-11-10  Bruno Haible  <bruno@clisp.org>
+
+	* lib/netdb.in.h: Use HAVE_STRUCT_ADDRINFO, HAVE_DECL_GETADDRINFO,
+	HAVE_DECL_FREEADDRINFO, HAVE_DECL_GAI_STRERROR, HAVE_DECL_GETNAMEINFO
+	as autoconf-substituted macros.
+	* m4/netdb_h.m4 (gl_NETDB_H_DEFAULTS): Initialize these variables to 1.
+	* m4/getaddrinfo.m4 (gl_PREREQ_GETADDRINFO): Require
+	gl_NETDB_H_DEFAULTS. Set these variables.
+	* modules/netdb (Makefile.am): Substitute these variables.
+
 2008-11-10  Eric Blake  <ebb9@byu.net>
 
 	standards.texi: include correct file for FDL 1.3
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -36,7 +36,7 @@
 #ifndef _GL_NETDB_H
 #define _GL_NETDB_H
 
-#if @HAVE_NETDB_H@ && HAVE_STRUCT_ADDRINFO
+#if @HAVE_NETDB_H@ && @HAVE_STRUCT_ADDRINFO@
 
 /* Declarations for a platform that has <netdb.h>.  */
 
@@ -50,7 +50,7 @@
 
 #if @GNULIB_GETADDRINFO@
 
-# ifndef HAVE_STRUCT_ADDRINFO
+# if !@HAVE_STRUCT_ADDRINFO@
 
 /* Structure to contain information about address of a service provider.  */
 struct addrinfo
@@ -139,7 +139,7 @@
 #  endif
 # endif
 
-# if !HAVE_DECL_GETADDRINFO
+# if !@HAVE_DECL_GETADDRINFO@
 /* Translate name of a service location and/or a service name to set of
    socket addresses.
    For more details, see the POSIX:2001 specification
@@ -150,21 +150,21 @@
 			struct addrinfo **restrict res);
 # endif
 
-# if !HAVE_DECL_FREEADDRINFO
+# if !@HAVE_DECL_FREEADDRINFO@
 /* Free `addrinfo' structure AI including associated storage.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
 extern void freeaddrinfo (struct addrinfo *ai);
 # endif
 
-# if !HAVE_DECL_GAI_STRERROR
+# if !@HAVE_DECL_GAI_STRERROR@
 /* Convert error return from getaddrinfo() to a string.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
 extern const char *gai_strerror (int ecode);
 # endif
 
-# if !HAVE_DECL_GETNAMEINFO
+# if !@HAVE_DECL_GETNAMEINFO@
 /* Convert socket address to printable node and service names.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getnameinfo.html>.  */
--- a/m4/getaddrinfo.m4
+++ b/m4/getaddrinfo.m4
@@ -1,4 +1,4 @@
-# getaddrinfo.m4 serial 16
+# getaddrinfo.m4 serial 17
 dnl Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -71,8 +71,9 @@
   gl_PREREQ_GETADDRINFO
 ])
 
-# Prerequisites of lib/getaddrinfo.c.
+# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
 AC_DEFUN([gl_PREREQ_GETADDRINFO], [
+  AC_REQUIRE([gl_NETDB_H_DEFAULTS])
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
   AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
@@ -104,6 +105,7 @@
   AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include <sys/socket.h>])
 
   AC_CHECK_HEADERS_ONCE(netinet/in.h)
+
   AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[
   /* sys/types.h is not needed according to POSIX, but the
      sys/socket.h in i386-unknown-freebsd4.10 and
@@ -119,6 +121,19 @@
 #include <ws2tcpip.h>
 #endif
 ])
+  if test $ac_cv_have_decl_getaddrinfo = no; then
+    HAVE_DECL_GETADDRINFO=0
+  fi
+  if test $ac_cv_have_decl_freeaddrinfo = no; then
+    HAVE_DECL_FREEADDRINFO=0
+  fi
+  if test $ac_cv_have_decl_gai_strerror = no; then
+    HAVE_DECL_GAI_STRERROR=0
+  fi
+  if test $ac_cv_have_decl_getnameinfo = no; then
+    HAVE_DECL_GETNAMEINFO=0
+  fi
+
   AC_CHECK_TYPES([struct addrinfo],,,[
 #include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
@@ -131,4 +146,7 @@
 #include <ws2tcpip.h>
 #endif
 ])
+  if test $ac_cv_type_struct_addrinfo = no; then
+    HAVE_STRUCT_ADDRINFO=0
+  fi
 ])
--- a/m4/netdb_h.m4
+++ b/m4/netdb_h.m4
@@ -1,4 +1,4 @@
-# netdb_h.m4 serial 3
+# netdb_h.m4 serial 4
 dnl Copyright (C) 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -30,4 +30,10 @@
 AC_DEFUN([gl_NETDB_H_DEFAULTS],
 [
   GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_STRUCT_ADDRINFO=1;   AC_SUBST([HAVE_STRUCT_ADDRINFO])
+  HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO])
+  HAVE_DECL_GAI_STRERROR=1; AC_SUBST([HAVE_DECL_GAI_STRERROR])
+  HAVE_DECL_GETADDRINFO=1;  AC_SUBST([HAVE_DECL_GETADDRINFO])
+  HAVE_DECL_GETNAMEINFO=1;  AC_SUBST([HAVE_DECL_GETNAMEINFO])
 ])
--- a/modules/netdb
+++ b/modules/netdb
@@ -25,6 +25,11 @@
 	      -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \
 	      -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
 	      -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \
+	      -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \
+	      -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \
+	      -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
+	      -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
+	      -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
 	      < $(srcdir)/netdb.in.h; \
 	} > $@-t
 	mv $@-t $@