From 1bd9ffdd44000b208d29d35451f4dc9f1ac9318f Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Thu, 13 Dec 2018 18:24:30 +0800 Subject: [PATCH 1/4] windows: Set _WIN32_WINNT to 0x0601 (Windows 7) Also remove all defines in many places and define it in configure stage to keep consistency. --- build_msvc/common.vcxproj | 1 + configure.ac | 2 +- src/compat.h | 4 ---- src/qt/guiutil.cpp | 4 ---- src/support/lockedpool.cpp | 4 ---- src/util/system.cpp | 5 ----- 6 files changed, 2 insertions(+), 18 deletions(-) diff --git a/build_msvc/common.vcxproj b/build_msvc/common.vcxproj index c7c20622e..a9fb0c891 100644 --- a/build_msvc/common.vcxproj +++ b/build_msvc/common.vcxproj @@ -17,6 +17,7 @@ /utf-8 %(AdditionalOptions) 4018;4244;4267;4715;4805; true + _WIN32_WINNT=0x0601;%(PreprocessorDefinitions) diff --git a/configure.ac b/configure.ac index c4b1d63bf..8d7334ab6 100644 --- a/configure.ac +++ b/configure.ac @@ -485,7 +485,7 @@ case $host in AC_MSG_ERROR("windres not found") fi - CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB" + CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0601" LEVELDB_TARGET_FLAGS="-DOS_WINDOWS" if test "x$CXXFLAGS_overridden" = "xno"; then CXXFLAGS="$CXXFLAGS -w" diff --git a/src/compat.h b/src/compat.h index 7b164d563..68f6eb692 100644 --- a/src/compat.h +++ b/src/compat.h @@ -11,10 +11,6 @@ #endif #ifdef WIN32 -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0501 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 71e987c8f..ba0a5abdf 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -21,10 +21,6 @@ #include #ifdef WIN32 -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0501 #ifdef _WIN32_IE #undef _WIN32_IE #endif diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 627018083..5c2050e4a 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -10,10 +10,6 @@ #endif #ifdef WIN32 -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0501 #define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX diff --git a/src/util/system.cpp b/src/util/system.cpp index 06317a3a9..789dcfaba 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -44,11 +44,6 @@ #pragma warning(disable:4717) #endif -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0501 - #ifdef _WIN32_IE #undef _WIN32_IE #endif From d8a299206780b38959d732cbe40ba1dd25834f0e Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Wed, 23 Jan 2019 21:37:44 +0800 Subject: [PATCH 2/4] windows: Call SetProcessDEPPolicy directly --- src/init.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 77d050561..a6a8b7fde 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -891,16 +891,7 @@ bool AppInitBasicSetup() #endif #ifdef WIN32 // Enable Data Execution Prevention (DEP) - // Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008 - // A failure is non-critical and needs no further attention! -#ifndef PROCESS_DEP_ENABLE - // We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7), - // which is not correct. Can be removed, when GCCs winbase.h is fixed! -#define PROCESS_DEP_ENABLE 0x00000001 -#endif - typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD); - PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy"); - if (setProcDEPPol != nullptr) setProcDEPPol(PROCESS_DEP_ENABLE); + SetProcessDEPPolicy(PROCESS_DEP_ENABLE); #endif if (!SetupNetworking()) From d0522ec94ebbaa564f5f6b31236d4df032664411 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Sun, 20 Jan 2019 14:58:59 -0800 Subject: [PATCH 3/4] Drop defunct Windows compat fixes "The AI_ADDRCONFIG flag is defined on the Windows SDK for Windows Vista and later. The AI_ADDRCONFIG flag is supported on Windows Vista and later." https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo However, the version of MinGW we use on Travis is not current and does not carry the relevant definition, as such I defined it in compat. https://github.com/wine-mirror/wine/blob/master/include/ws2tcpip.h Testing confirms that the PROTECTION_LEVEL_UNRESTRICTED, IPV6_PROTECTION_LEVEL, PROCESS_DEP_ENABLE, AI_ADDRCONFIG, are now supported by the version of Windows that we test against, so can be removed. https://travis-ci.org/bitcoin/bitcoin/jobs/483255439 https://travis-ci.org/Empact/bitcoin/jobs/484123087 --- src/net.cpp | 11 ----------- src/netbase.cpp | 4 ---- 2 files changed, 15 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 0490ccd6d..4bf7e7172 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -58,17 +58,6 @@ static constexpr int DUMP_PEERS_INTERVAL = 15 * 60; #define MSG_DONTWAIT 0 #endif -// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h. -// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version. -#ifdef WIN32 -#ifndef PROTECTION_LEVEL_UNRESTRICTED -#define PROTECTION_LEVEL_UNRESTRICTED 10 -#endif -#ifndef IPV6_PROTECTION_LEVEL -#define IPV6_PROTECTION_LEVEL 23 -#endif -#endif - /** Used to pass flags to the Bind() function */ enum BindFlags { BF_NONE = 0, diff --git a/src/netbase.cpp b/src/netbase.cpp index 355e21d4e..6c386a9ad 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -80,11 +80,7 @@ bool static LookupIntern(const char *pszName, std::vector& vIP, unsign aiHint.ai_socktype = SOCK_STREAM; aiHint.ai_protocol = IPPROTO_TCP; aiHint.ai_family = AF_UNSPEC; -#ifdef WIN32 - aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST; -#else aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; -#endif struct addrinfo *aiRes = nullptr; int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes); if (nErr) From 0164b0f5cf80cd00a4914d9fea0bcb9508cb7607 Mon Sep 17 00:00:00 2001 From: Chun Kuan Lee Date: Sat, 26 Jan 2019 09:28:48 +0800 Subject: [PATCH 4/4] build: Remove WINVER pre define in Makefile.leveldb.inlcude --- src/Makefile.leveldb.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.leveldb.include b/src/Makefile.leveldb.include index 833f3d2a1..bd08bcb4e 100644 --- a/src/Makefile.leveldb.include +++ b/src/Makefile.leveldb.include @@ -24,7 +24,7 @@ LEVELDB_CPPFLAGS_INT += -DLEVELDB_ATOMIC_PRESENT LEVELDB_CPPFLAGS_INT += -D__STDC_LIMIT_MACROS if TARGET_WINDOWS -LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_WINDOWS -DWINVER=0x0500 -D__USE_MINGW_ANSI_STDIO=1 +LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_WINDOWS -D__USE_MINGW_ANSI_STDIO=1 else LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_POSIX endif