netdb: Add support for GNULIB_POSIXCHECK.
authorBruno Haible <bruno@clisp.org>
Mon, 26 Apr 2010 08:25:56 +0000 (10:25 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 26 Apr 2010 08:25:56 +0000 (10:25 +0200)
ChangeLog
lib/netdb.in.h
m4/netdb_h.m4
modules/netdb

index 8d6acc0..94f0e57 100644 (file)
--- 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
index 8f09141..8789550 100644 (file)
@@ -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 @@ 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 */
index e04a2d1..c870fb6 100644 (file)
@@ -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 <netdb.h>]],
+    [getaddrinfo freeaddrinfo gai_strerror getnameinfo])
 ])
 
 AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
index a7dfd7a..dbdfc8c 100644 (file)
@@ -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 <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 @@ 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 $@