[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
inet_ntop, inet_pton: forward-compatibility with newer Windows versions
From: |
Bruno Haible |
Subject: |
inet_ntop, inet_pton: forward-compatibility with newer Windows versions |
Date: |
Sun, 30 Jun 2019 15:15:05 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-151-generic; KDE/5.18.0; x86_64; ; ) |
The functions inet_ntop and inet_pton exist in Windows Vista or newer:
https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-inet_ntop
https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-inet_pton
So far, gnulib tests whether they are declared. Which, on mingw, by default
is not the case. So, there is the possibility of a conflict at the linker level.
I don't think a linker error would probably be seen, because the function
from Windows is in libws2_32.dll, whereas the function from gnulib is in
libgnu.a. But it is possible that a program that #includes <ws2tcpip.h>
instead of <arpa/inet.h> ends up calling gnulib's function with the wrong
calling convention (stdcall), which will likely lead to a crash.
This patch fixes it. It renames the gnulib function, by adding an 'rpl_' prefix,
thus avoiding any possible conflict.
2019-06-30 Bruno Haible <address@hidden>
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.
* m4/inet_pton.m4 (gl_FUNC_INET_PTON): On native Windows, set
REPLACE_INET_PTON to 1 always.
diff --git a/m4/inet_ntop.m4 b/m4/inet_ntop.m4
index 3804e88..d71246b 100644
--- a/m4/inet_ntop.m4
+++ b/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 20
+# inet_ntop.m4 serial 21
dnl Copyright (C) 2005-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,15 +24,16 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
INET_NTOP_LIB=
gl_PREREQ_SYS_H_WINSOCK2
if test $HAVE_WINSOCK2_H = 1; then
+ dnl It needs to be overridden, because the stdcall calling convention
+ dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid
+ dnl a name conflict at the linker level, even though the header file
+ dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600.
+ REPLACE_INET_NTOP=1
AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
if test $ac_cv_have_decl_inet_ntop = yes; then
- dnl It needs to be overridden, because the stdcall calling convention
- dnl is not compliant with POSIX.
- REPLACE_INET_NTOP=1
INET_NTOP_LIB="-lws2_32"
else
HAVE_DECL_INET_NTOP=0
- HAVE_INET_NTOP=0
fi
else
gl_save_LIBS=$LIBS
diff --git a/m4/inet_pton.m4 b/m4/inet_pton.m4
index 72a9bc2..264892c 100644
--- a/m4/inet_pton.m4
+++ b/m4/inet_pton.m4
@@ -1,4 +1,4 @@
-# inet_pton.m4 serial 18
+# inet_pton.m4 serial 19
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,15 +24,16 @@ AC_DEFUN([gl_FUNC_INET_PTON],
INET_PTON_LIB=
gl_PREREQ_SYS_H_WINSOCK2
if test $HAVE_WINSOCK2_H = 1; then
+ dnl It needs to be overridden, because the stdcall calling convention
+ dnl is not compliant with POSIX. Set REPLACE_INET_PTON in order to avoid
+ dnl a name conflict at the linker level, even though the header file
+ dnl <ws2tcpip.h> declares inet_pton only if _WIN32_WINNT >= 0x0600.
+ REPLACE_INET_PTON=1
AC_CHECK_DECLS([inet_pton],,, [[#include <ws2tcpip.h>]])
if test $ac_cv_have_decl_inet_pton = yes; then
- dnl It needs to be overridden, because the stdcall calling convention
- dnl is not compliant with POSIX.
- REPLACE_INET_PTON=1
INET_PTON_LIB="-lws2_32"
else
HAVE_DECL_INET_PTON=0
- HAVE_INET_PTON=0
fi
else
gl_save_LIBS=$LIBS
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- inet_ntop, inet_pton: forward-compatibility with newer Windows versions,
Bruno Haible <=