diff options
author | Bruno Haible <bruno@clisp.org> | 2019-06-30 15:20:24 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2019-06-30 15:20:24 +0200 |
commit | 8c4ec56ee018557e4a9f0d6aa047ee0590033b6e (patch) | |
tree | 527f02c45b59d381a353d6a9f85074e786903c81 | |
parent | 6136e937969578bf4d5403b86ea3c4c8eb16d268 (diff) | |
download | gnulib-8c4ec56ee018557e4a9f0d6aa047ee0590033b6e.tar.gz |
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>.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | lib/arpa_inet.in.h | 6 | ||||
-rw-r--r-- | m4/arpa_inet_h.m4 | 4 | ||||
-rw-r--r-- | m4/sys_socket_h.m4 | 28 | ||||
-rw-r--r-- | modules/arpa_inet | 3 |
5 files changed, 44 insertions, 9 deletions
@@ -1,5 +1,17 @@ 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. * m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): On native Windows, set REPLACE_INET_NTOP to 1 always. 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 <ws2tcpip.h> +#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 <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. 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 <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' \ |