lokinet/win32-setup/libzmq-latest_release-win32.patch
2020-03-05 12:47:48 -06:00

199 lines
5.4 KiB
Diff

From 00440f91ebbae83d7d2aeb429b306bee27f3b165 Mon Sep 17 00:00:00 2001
From: Rick V <rick@snowlight.net>
Date: Wed, 31 Oct 2019 17:20:05 -0500
Subject: ZMQ patches for Windows
Configure with: ./configure [--host=i686-w64-mingw32 --target=i686-w64-mingw32] --disable-shared
CFLAGS='-march=nocona -mfpmath=sse -O3' CPPFLAGS=-DZMQ_HAVE_WINDOWS_TARGET_XP
-rick
---
diff --git a/include/zmq.h b/include/zmq.h
index f5713f80..bb7b818e 100644
--- a/include/zmq.h
+++ b/include/zmq.h
@@ -65,14 +65,9 @@ extern "C" {
#endif
#ifdef __MINGW32__
-// Require Windows XP or higher with MinGW for getaddrinfo().
-#if (_WIN32_WINNT >= 0x0501)
-#else
-#error You need at least Windows XP target
-#endif
-#endif
#include <winsock2.h>
#endif
+#endif
/* Handle DSO symbol visibility */
#if defined _WIN32
diff --git a/src/address.hpp b/src/address.hpp
index b20a10e5..f848ec2b 100644
--- a/src/address.hpp
+++ b/src/address.hpp
@@ -38,6 +38,7 @@
#include <sys/socket.h>
#else
#include <ws2tcpip.h>
+#include <wspiapi.h>
#endif
namespace zmq
diff --git a/src/ip_resolver.cpp b/src/ip_resolver.cpp
index 4a8283de..a8b6fe6c 100644
--- a/src/ip_resolver.cpp
+++ b/src/ip_resolver.cpp
@@ -595,6 +595,7 @@ int zmq::ip_resolver_t::wchar_to_utf8 (const WCHAR *src_, char **dest_) const
return 0;
}
+#if !defined ZMQ_HAVE_WINDOWS_TARGET_XP
int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
{
int rc;
@@ -674,6 +675,17 @@ int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
}
return 0;
}
+#else
+// On other platforms we assume there are no sane interface names.
+int zmq::ip_resolver_t::resolve_nic_name (ip_addr_t *ip_addr_, const char *nic_)
+{
+ LIBZMQ_UNUSED (ip_addr_);
+ LIBZMQ_UNUSED (nic_);
+
+ errno = ENODEV;
+ return -1;
+}
+#endif
#else
diff --git a/src/precompiled.hpp b/src/precompiled.hpp
index f22a6937..45e5ba10 100644
--- a/src/precompiled.hpp
+++ b/src/precompiled.hpp
@@ -85,6 +85,7 @@
#include <time.h>
#include <winsock2.h>
#include <ws2tcpip.h>
+#include <wspiapi.h>
// standard C++ headers
#include <algorithm>
diff --git a/src/thread.cpp b/src/thread.cpp
index b14d7075..923d6a3d 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -61,10 +61,10 @@ void zmq::thread_t::start (thread_fn *tfn_, void *arg_, const char *name_)
strncpy (_name, name_, sizeof (_name) - 1);
#if defined _WIN32_WCE
_descriptor =
- (HANDLE) CreateThread (NULL, 0, &::thread_routine, this, 0, NULL);
+ (HANDLE) CreateThread (NULL, 0, &::thread_routine, this, 0, &_threadID);
#else
_descriptor =
- (HANDLE) _beginthreadex (NULL, 0, &::thread_routine, this, 0, NULL);
+ (HANDLE) _beginthreadex (NULL, 0, &::thread_routine, this, 0, &_threadID);
#endif
win_assert (_descriptor != NULL);
_started = true;
@@ -72,7 +72,7 @@ void zmq::thread_t::start (thread_fn *tfn_, void *arg_, const char *name_)
bool zmq::thread_t::is_current_thread () const
{
- return GetCurrentThreadId () == GetThreadId (_descriptor);
+ return GetCurrentThreadId () == _threadID;
}
void zmq::thread_t::stop ()
@@ -124,7 +124,7 @@ void zmq::thread_t::
thread_info._name = _name;
thread_info._thread_id = -1;
thread_info._flags = 0;
-
+#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 6320 6322)
__try {
@@ -136,6 +136,9 @@ void zmq::thread_t::
__except (EXCEPTION_CONTINUE_EXECUTION) {
}
#pragma warning(pop)
+#else
+(void)thread_info;
+#endif
}
#elif defined ZMQ_HAVE_VXWORKS
diff --git a/src/thread.hpp b/src/thread.hpp
index b13fc923..b4429af4 100644
--- a/src/thread.hpp
+++ b/src/thread.hpp
@@ -107,6 +107,7 @@ class thread_t
#ifdef ZMQ_HAVE_WINDOWS
HANDLE _descriptor;
+ unsigned _threadID;
#elif defined ZMQ_HAVE_VXWORKS
int _descriptor;
enum
diff --git a/src/udp_address.cpp b/src/udp_address.cpp
index d0dda564..1228e621 100644
--- a/src/udp_address.cpp
+++ b/src/udp_address.cpp
@@ -104,7 +104,11 @@ int zmq::udp_address_t::resolve (const char *name_, bool bind_, bool ipv6_)
if (src_name == "*") {
_bind_interface = 0;
} else {
+#ifndef _WIN32
_bind_interface = if_nametoindex (src_name.c_str ());
+#else
+ _bind_interface = 0;
+#endif
if (_bind_interface == 0) {
// Error, probably not an interface name.
_bind_interface = -1;
diff --git a/src/windows.hpp b/src/windows.hpp
index 2d3b4985..78c071a7 100644
--- a/src/windows.hpp
+++ b/src/windows.hpp
@@ -47,14 +47,6 @@
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#endif
-#ifdef __MINGW32__
-// Require Windows XP or higher with MinGW for getaddrinfo().
-#if (_WIN32_WINNT >= 0x0501)
-#else
-#error You need at least Windows XP target
-#endif
-#endif
-
#include <winsock2.h>
#include <windows.h>
#include <mswsock.h>
@@ -78,6 +70,7 @@ struct tcp_keepalive
#endif
#include <ws2tcpip.h>
+#include <wspiapi.h>
#include <ipexport.h>
#if !defined _WIN32_WCE
#include <process.h>
diff --git a/tests/testutil_monitoring.cpp b/tests/testutil_monitoring.cpp
index 75bd763c..7fb8dedb 100644
--- a/tests/testutil_monitoring.cpp
+++ b/tests/testutil_monitoring.cpp
@@ -26,6 +26,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define __USE_MINGW_ANSI_STDIO 1
#include "testutil_monitoring.hpp"
#include "testutil_unity.hpp"