From: Bruno Haible Date: Sun, 30 Jun 2019 13:20:24 +0000 (+0200) Subject: inet_ntop, inet_pton: Avoid conflict with native Windows functions. X-Git-Tag: v1.0~4813 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8c4ec56ee018557e4a9f0d6aa047ee0590033b6e;p=gnulib.git 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 . --- diff --git a/ChangeLog b/ChangeLog index f8e6cd0698..2fc31a3397 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2019-06-30 Bruno Haible + + 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 . + 2019-06-30 Bruno Haible inet_ntop, inet_pton: Forward-compatibility with newer Windows versions. diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h index 430c3d33ce..96793ad3ec 100644 --- a/lib/arpa_inet.in.h +++ b/lib/arpa_inet.in.h @@ -49,6 +49,12 @@ #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 +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4 index 46c7d287b8..645011d667 100644 --- a/m4/arpa_inet_h.m4 +++ b/m4/arpa_inet_h.m4 @@ -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([[ diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 1ea7b0b3f3..d0a902061a 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -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 replacement and of the @@ -142,6 +136,24 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2], AC_SUBST([HAVE_WINSOCK2_H]) ]) +# Common prerequisites of the replacement and of the +# 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. diff --git a/modules/arpa_inet b/modules/arpa_inet index 005690fefa..317bf8d7ce 100644 --- a/modules/arpa_inet +++ b/modules/arpa_inet @@ -4,6 +4,8 @@ A GNU-like . 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' \