]> Savannah Git Hosting - gnulib.git/commitdiff
inet_ntop, inet_pton: Avoid conflict with native Windows functions.
authorBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2019 13:20:24 +0000 (15:20 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 30 Jun 2019 13:20:24 +0000 (15:20 +0200)
* m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_WS2TCPIP): New macro, extracted
from gl_PREREQ_SYS_H_SOCKET.
(gl_PREREQ_SYS_H_SOCKET): Invoke it.
* m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Invoke
gl_PREREQ_SYS_H_WS2TCPIP.
* modules/arpa_inet (Files): Add m4/sys_socket_h.m4, m4/socklen.m4.
(Makefile.am): Substitute HAVE_WS2TCPIP_H.
* lib/arpa_inet.in.h: Include <ws2tcpip.h>.

ChangeLog
lib/arpa_inet.in.h
m4/arpa_inet_h.m4
m4/sys_socket_h.m4
modules/arpa_inet

index f8e6cd0698dcbb37df32ad3ce1e3997f85bb91d0..2fc31a3397938436b866ee4cf3830689f68e05e1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2019-06-30  Bruno Haible  <bruno@clisp.org>
+
+       inet_ntop, inet_pton: Avoid conflict with native Windows functions.
+       * m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_WS2TCPIP): New macro, extracted
+       from gl_PREREQ_SYS_H_SOCKET.
+       (gl_PREREQ_SYS_H_SOCKET): Invoke it.
+       * m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Invoke
+       gl_PREREQ_SYS_H_WS2TCPIP.
+       * modules/arpa_inet (Files): Add m4/sys_socket_h.m4, m4/socklen.m4.
+       (Makefile.am): Substitute HAVE_WS2TCPIP_H.
+       * lib/arpa_inet.in.h: Include <ws2tcpip.h>.
+
 2019-06-30  Bruno Haible  <bruno@clisp.org>
 
        inet_ntop, inet_pton: Forward-compatibility with newer Windows versions.
index 430c3d33ce841a7622552e6b1cf5552d85e0ccba..96793ad3ec58536daa814883f0379380e1cc95f0 100644 (file)
 #ifndef _@GUARD_PREFIX@_ARPA_INET_H
 #define _@GUARD_PREFIX@_ARPA_INET_H
 
+/* Get all possible declarations of inet_ntop() and inet_pton().  */
+#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
+    && @HAVE_WS2TCPIP_H@
+# include <ws2tcpip.h>
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
index 46c7d287b812efcc32453f4c0726775c4e90def7..645011d6670c1c214d2787b8f722c45ab428308b 100644 (file)
@@ -1,4 +1,4 @@
-# arpa_inet_h.m4 serial 13
+# arpa_inet_h.m4 serial 14
 dnl Copyright (C) 2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -24,6 +24,8 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
 
   AC_REQUIRE([gl_FEATURES_H])
 
+  gl_PREREQ_SYS_H_WS2TCPIP
+
   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([[
index 1ea7b0b3f320c4c1d07abfd72a34ad49923d5234..d0a902061aa0ce45a4fd3201dd2995d7f01dec05 100644 (file)
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 23
+# sys_socket_h.m4 serial 24
 dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -104,17 +104,11 @@ AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
   gl_CHECK_NEXT_HEADERS([sys/socket.h])
   if test $ac_cv_header_sys_socket_h = yes; then
     HAVE_SYS_SOCKET_H=1
-    HAVE_WS2TCPIP_H=0
   else
     HAVE_SYS_SOCKET_H=0
-    if test $ac_cv_header_ws2tcpip_h = yes; then
-      HAVE_WS2TCPIP_H=1
-    else
-      HAVE_WS2TCPIP_H=0
-    fi
   fi
   AC_SUBST([HAVE_SYS_SOCKET_H])
-  AC_SUBST([HAVE_WS2TCPIP_H])
+  gl_PREREQ_SYS_H_WS2TCPIP
 ])
 
 # Common prerequisites of the <sys/socket.h> replacement and of the
@@ -142,6 +136,24 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
   AC_SUBST([HAVE_WINSOCK2_H])
 ])
 
+# Common prerequisites of the <sys/socket.h> replacement and of the
+# <arpa/inet.h> replacement.
+# Sets and substitutes HAVE_WS2TCPIP_H.
+AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP],
+[
+  AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
+  if test $ac_cv_header_sys_socket_h = yes; then
+    HAVE_WS2TCPIP_H=0
+  else
+    if test $ac_cv_header_ws2tcpip_h = yes; then
+      HAVE_WS2TCPIP_H=1
+    else
+      HAVE_WS2TCPIP_H=0
+    fi
+  fi
+  AC_SUBST([HAVE_WS2TCPIP_H])
+])
+
 AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
index 005690fefaea52d64931dfc2a800ac7ac25563d6..317bf8d7ce69c51c935161092dc1ac243b2ff1d4 100644 (file)
@@ -4,6 +4,8 @@ A GNU-like <arpa/inet.h>.
 Files:
 lib/arpa_inet.in.h
 m4/arpa_inet_h.m4
+m4/sys_socket_h.m4
+m4/socklen.m4
 
 Depends-on:
 include_next
@@ -34,6 +36,7 @@ arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON
              -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
              -e 's/@''GNULIB_INET_NTOP''@/$(GNULIB_INET_NTOP)/g' \
              -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \
+             -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
              -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
              -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
              -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \