[vlc-commits] contrib: upnp: Improve and generalize a patch for handling inet_pton
Martin Storsjö
git at videolan.org
Fri Jun 19 09:06:27 CEST 2020
vlc/vlc-3.0 | branch: master | Martin Storsjö <martin at martin.st> | Sun Feb 25 00:02:47 2018 +0200| [0cc6f6e67066f33da9ba1dbf2318ca1518ba1820] | committer: Steve Lhomme
contrib: upnp: Improve and generalize a patch for handling inet_pton
libupnp locally overrides the version of _WIN32_WINNT via
configure.ac and autoconfig.h (which is disabled by a vlc contrib
patch when targeting winrt though).
Make sure that autoconfig.h is included everywhere necessary, to
show/hide the relevant parts of winsock headers depending on the
chosen version of _WIN32_WINNT (either default or overridden).
This avoids including the system declarations of these functions if
the default target is >= vista but the build tries to override it
to a lower version.
On the other hand, if the override of _WIN32_WINNT is removed (as
when targeting winrt) and the default is >= vista, skip the local
version of inet_pton.
This should have the same effect as the previous patch, but
evaluated by the preprocessor instead of hardcoding commenting out
of certain source files.
(cherry picked from commit fa05e80c6df9d307329ef1d125e4e671c64510ee)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0cc6f6e67066f33da9ba1dbf2318ca1518ba1820
---
contrib/src/upnp/rules.mak | 2 +-
contrib/src/upnp/windows-version-inet.patch | 49 +++++++++++++++++++++++++++++
contrib/src/upnp/winrt-inet.patch | 36 ---------------------
3 files changed, 50 insertions(+), 37 deletions(-)
diff --git a/contrib/src/upnp/rules.mak b/contrib/src/upnp/rules.mak
index e52f9f840a..565bfede1f 100644
--- a/contrib/src/upnp/rules.mak
+++ b/contrib/src/upnp/rules.mak
@@ -34,10 +34,10 @@ ifdef HAVE_WIN32
$(APPLY) $(SRC)/upnp/libupnp-win32.patch
$(APPLY) $(SRC)/upnp/libupnp-win64.patch
$(APPLY) $(SRC)/upnp/windows-random.patch
+ $(APPLY) $(SRC)/upnp/windows-version-inet.patch
ifdef HAVE_WINSTORE
$(APPLY) $(SRC)/upnp/winrt-dont-force-win32-winnt.patch
$(APPLY) $(SRC)/upnp/no-getifinfo.patch
- $(APPLY) $(SRC)/upnp/winrt-inet.patch
endif
endif
$(APPLY) $(SRC)/upnp/libpthread.patch
diff --git a/contrib/src/upnp/windows-version-inet.patch b/contrib/src/upnp/windows-version-inet.patch
new file mode 100644
index 0000000000..989a3d840c
--- /dev/null
+++ b/contrib/src/upnp/windows-version-inet.patch
@@ -0,0 +1,49 @@
+diff -urN upnp-orig/upnp/src/inc/inet_pton.h upnp/upnp/src/inc/inet_pton.h
+--- upnp-orig/upnp/src/inc/inet_pton.h 2010-12-23 22:24:06.000000000 +0200
++++ upnp/upnp/src/inc/inet_pton.h 2018-02-24 23:44:22.359676036 +0200
+@@ -3,6 +3,8 @@
+
+ #ifdef WIN32
+
++#include "autoconfig.h"
++
+ #ifdef IPV6_
+ #define INET_IPV6
+ #endif
+@@ -13,6 +15,8 @@
+ #include <stdio.h>
+ #include <string.h>
+
++#if _WIN32_WINNT < 0x600
++
+ /*!
+ * \file
+ *
+@@ -45,6 +49,8 @@
+ */
+ extern int inet_pton(int af, const char *src, void *dst);
+
++#endif /* _WIN32_WINNT < 0x600 */
++
+ #endif /* WIN32 */
+
+ #endif /* INET_PTON */
+diff -urN upnp-orig/upnp/src/inet_pton.c upnp/upnp/src/inet_pton.c
+--- upnp-orig/upnp/src/inet_pton.c 2010-12-23 22:24:06.000000000 +0200
++++ upnp/upnp/src/inet_pton.c 2018-02-24 23:44:16.771807657 +0200
+@@ -24,6 +24,8 @@
+
+ #include "inet_pton.h"
+
++#if _WIN32_WINNT < 0x600
++
+ /*!
+ * \brief format an IPv4 address
+ *
+@@ -320,4 +322,6 @@
+ /* NOTREACHED */
+ }
+
++#endif /* _WIN32_WINNT < 0x600 */
++
+ #endif /* WIN32 */
diff --git a/contrib/src/upnp/winrt-inet.patch b/contrib/src/upnp/winrt-inet.patch
deleted file mode 100644
index 32003bbcf7..0000000000
--- a/contrib/src/upnp/winrt-inet.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- upnp/upnp/Makefile.am 2013-11-15 17:01:35.000000000 +0100
-+++ upnp.new/upnp/Makefile.am 2016-05-09 19:16:43.909558923 +0200
-@@ -148,9 +148,9 @@
-
-
- # inet_pton (needed on Win32, compiles to nothing elsewhere)
--libupnp_la_SOURCES += \
-- src/inet_pton.c \
-- src/inc/inet_pton.h
-+#libupnp_la_SOURCES += \
-+# src/inet_pton.c \
-+# src/inc/inet_pton.h
-
-
- # check / distcheck tests
-diff -ruN upnp.new/upnp/src/inc/inet_pton.h upnp/upnp/src/inc/inet_pton.h
---- upnp.new/upnp/src/inc/inet_pton.h 2010-12-23 21:24:06.000000000 +0100
-+++ upnp/upnp/src/inc/inet_pton.h 2016-05-09 20:25:37.765374740 +0200
-@@ -31,6 +31,11 @@
- * \return
- * pointer to presentation format address (`dst'), or NULL (see errno).
- */
-+#define inet_ntop InetNtopA
-+
-+#define inet_pton InetPtonA
-+
-+#if 0
- extern const char *inet_ntop(int af, const void *src, char *dst,
- socklen_t size);
-
-@@ -47,4 +52,5 @@
-
- #endif /* WIN32 */
-
-+#endif
- #endif /* INET_PTON */
More information about the vlc-commits
mailing list