From ad8f11251eeef41965bd7a358516325238117971 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 26 Apr 2010 10:25:56 +0200 Subject: [PATCH] netdb: Add support for GNULIB_POSIXCHECK. --- ChangeLog | 12 ++++++++++++ lib/netdb.in.h | 30 +++++++++++++++++++++++++++++- m4/netdb_h.m4 | 7 ++++++- modules/netdb | 4 +++- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d6acc051..94f0e576c 100644 --- 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 index 8f091411f..8789550b6 100644 --- 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 @@ extern int getnameinfo (const struct sockaddr *restrict sa, socklen_t salen, # 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 index e04a2d13e..c870fb61b 100644 --- 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 @@ AC_DEFUN([gl_HEADER_NETDB], 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 index a7dfd7a11..dbdfc8cfc 100644 --- a/modules/netdb +++ b/modules/netdb @@ -8,6 +8,7 @@ m4/netdb_h.m4 Depends-on: include_next arg-nonnull +warn-on-use sys_socket configure.ac: @@ -18,7 +19,7 @@ BUILT_SOURCES += netdb.h # 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 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) -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 $@ -- 2.11.0