bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: netdb.h, getaddrinfo


From: Bruno Haible
Subject: Re: netdb.h, getaddrinfo
Date: Mon, 26 Apr 2010 01:14:51 +0200
User-agent: KMail/1.9.9

Hi Simon,

A week ago I proposed:
> > I propose to generate netdb.h always, like we do
> > with stdlib.h and unistd.h for 3 years and for many others for
> > 2 months. Then we can also add GNULIB_POSIXCHECK advice to <netdb.h>.

Here's the second part: The patch to add GNULIB_POSIXCHECK advice.

OK to commit?

Bruno


2010-04-25  Bruno Haible  <address@hidden>

        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.

--- lib/netdb.in.h.orig Mon Apr 26 01:10:34 2010
+++ lib/netdb.in.h      Mon Apr 26 00:58:58 2010
@@ -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 */
--- m4/netdb_h.m4.orig  Mon Apr 26 01:10:34 2010
+++ m4/netdb_h.m4       Mon Apr 26 01:02:55 2010
@@ -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],
--- modules/netdb.orig  Mon Apr 26 01:10:34 2010
+++ modules/netdb       Mon Apr 26 01:08:42 2010
@@ -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 address@hidden $@ && \
        { 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; \
        } > address@hidden && \
        mv address@hidden $@




reply via email to

[Prev in Thread] Current Thread [Next in Thread]