# HG changeset patch # User Bruno Haible # Date 1272270356 -7200 # Node ID b18fb24cf6064e2ff5019de8ee17f5bef82ec4cc # Parent f36dcb5c4dae2f787ba6c86f20ae67b4b80d4423 netdb: Add support for GNULIB_POSIXCHECK. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-04-25 Bruno Haible + + netdb: Add support for GNULIB_POSIXCHECK. + * lib/netdb.in.h: Include warn-on-use.h. + (getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo): Warn if these + functions are used when GNULIB_POSIXCHECK is defined and the + getaddrinfo module is not in use. + * m4/netdb_h.m4 (gl_HEADER_NETDB): Test whether getaddrinfo, + freeaddrinfo, gai_strerror, getnameinfo are declared. + * modules/netdb (Depends-on): Add warn-on-use. + (Makefile.am): Include warn-on-use.h in netdb.h. + 2010-04-24 Ian Beckwith build: avoid "make check" failure without .git/ directory diff --git a/lib/netdb.in.h b/lib/netdb.in.h --- a/lib/netdb.in.h +++ b/lib/netdb.in.h @@ -41,6 +41,8 @@ /* The definition of _GL_ARG_NONNULL is copied here. */ +/* The definition of _GL_WARN_ON_USE is copied here. */ + /* Declarations for a platform that lacks , or where it is incomplete. */ @@ -186,7 +188,33 @@ # define NI_NUMERICSERV 2 # endif -#endif /* @GNULIB_GETADDRINFO@ */ +#elif defined GNULIB_POSIXCHECK + +# undef getaddrinfo +# if HAVE_RAW_DECL_GETADDRINFO +_GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +# undef freeaddrinfo +# if HAVE_RAW_DECL_FREEADDRINFO +_GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +# undef gai_strerror +# if HAVE_RAW_DECL_GAI_STRERROR +_GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +# undef getnameinfo +# if HAVE_RAW_DECL_GETNAMEINFO +_GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +#endif #endif /* _GL_NETDB_H */ #endif /* _GL_NETDB_H */ diff --git a/m4/netdb_h.m4 b/m4/netdb_h.m4 --- a/m4/netdb_h.m4 +++ b/m4/netdb_h.m4 @@ -1,4 +1,4 @@ -# netdb_h.m4 serial 8 +# netdb_h.m4 serial 9 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -15,6 +15,11 @@ HAVE_NETDB_H=0 fi AC_SUBST([HAVE_NETDB_H]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include ]], + [getaddrinfo freeaddrinfo gai_strerror getnameinfo]) ]) AC_DEFUN([gl_NETDB_MODULE_INDICATOR], diff --git a/modules/netdb b/modules/netdb --- a/modules/netdb +++ b/modules/netdb @@ -8,6 +8,7 @@ Depends-on: include_next arg-nonnull +warn-on-use sys_socket configure.ac: @@ -18,7 +19,7 @@ # We need the following in order to create when the system # doesn't have one that works with the given compiler. -netdb.h: netdb.in.h $(ARG_NONNULL_H) +netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -32,6 +33,7 @@ -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/netdb.in.h; \ } > $@-t && \ mv $@-t $@