From 80c47220d2d1cb0aefa1645c9f4354dd4284aa49 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 11 Nov 2008 01:23:24 +0100 Subject: [PATCH] Use substituted macros instead of C preprocessor macros. --- ChangeLog | 10 ++++++++++ lib/netdb.in.h | 12 ++++++------ m4/getaddrinfo.m4 | 22 ++++++++++++++++++++-- m4/netdb_h.m4 | 8 +++++++- modules/netdb | 5 +++++ 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f36de65e..1105e8441 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-11-10 Bruno Haible + + * 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 standards.texi: include correct file for FDL 1.3 diff --git a/lib/netdb.in.h b/lib/netdb.in.h index 9c66ae815..b0ee28679 100644 --- 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 . */ @@ -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 @@ struct addrinfo # 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 @@ extern int getaddrinfo (const char *restrict nodename, 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 . */ 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 . */ 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 . */ diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4 index c184c6f29..c3fa1c6a6 100644 --- 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 @@ AC_DEFUN([gl_GETADDRINFO], 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_DEFUN([gl_PREREQ_GETADDRINFO], [ AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include ]) 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 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [ #include #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 #ifdef HAVE_SYS_SOCKET_H @@ -131,4 +146,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [ #include #endif ]) + if test $ac_cv_type_struct_addrinfo = no; then + HAVE_STRUCT_ADDRINFO=0 + fi ]) diff --git a/m4/netdb_h.m4 b/m4/netdb_h.m4 index bbe166fab..6ae124817 100644 --- 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_MODULE_INDICATOR], 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]) ]) diff --git a/modules/netdb b/modules/netdb index 5165b5674..afac88be7 100644 --- a/modules/netdb +++ b/modules/netdb @@ -25,6 +25,11 @@ netdb.h: netdb.in.h -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 $@ -- 2.11.0