changeset 13271:b18fb24cf606

netdb: Add support for GNULIB_POSIXCHECK.
author Bruno Haible <bruno@clisp.org>
date Mon, 26 Apr 2010 10:25:56 +0200
parents f36dcb5c4dae
children c9ecff74d08f
files ChangeLog lib/netdb.in.h m4/netdb_h.m4 modules/netdb
diffstat 4 files changed, 50 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-04-25  Bruno Haible  <bruno@clisp.org>
+
+	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  <ianb@erislabs.net>
 
 	build: avoid "make check" failure without .git/ directory
--- 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 <netdb.h>, 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 */
--- 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 <netdb.h>]],
+    [getaddrinfo freeaddrinfo gai_strerror getnameinfo])
 ])
 
 AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
--- 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 <netdb.h> 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 $@