Skip to content

Commit 9f713b8

Browse files
committed
Merge bitcoin/bitcoin#32837: depends: fix libevent _WIN32_WINNT usage
f5647c6 depends: fix libevent _WIN32_WINNT usage (fanquake) Pull request description: Starting with version 13.x, the mingw headers will define the value of `NTDDI_VERSION`, based on the value of `_WIN32_WINNT`, if that version is < Windows 10. Given that libevent was undefining our `_WIN32_WINNT`, and redefining it to a value < Windows 10 (`0x0501`), `NTDDI_VERSION` was also being defined to that value, leading to functions not being exposed in the mingw-w64 headers; see here: https://github.com/mingw-w64/mingw-w64/blob/9c2668ef77e75ea4d8a6c7d100b14643269caec3/mingw-w64-headers/include/iphlpapi.h#L36-L41. Imports a commit from usptream ([a14ff91254f40cf36e0fee199e26fb11260fab49](libevent/libevent@a14ff91)). Fixes #32707. ACKs for top commit: willcl-ark: crACK f5647c6 Tree-SHA512: eb429457a4af6191dd27ef3d1087667c5304ff0f49d4c6824883651e3c2dbab5d9784fa1f170402f23cd9238005c5214e0a71a4160562a59dfa35618dc702132
2 parents 184159e + f5647c6 commit 9f713b8

File tree

2 files changed

+125
-1
lines changed

2 files changed

+125
-1
lines changed

depends/packages/libevent.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz
55
$(package)_sha256_hash=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb
66
$(package)_patches=cmake_fixups.patch
77
$(package)_patches += netbsd_fixup.patch
8+
$(package)_patches += winver_fixup.patch
89
$(package)_build_subdir=build
910

1011
# When building for Windows, we set _WIN32_WINNT to target the same Windows
@@ -21,7 +22,8 @@ endef
2122

2223
define $(package)_preprocess_cmds
2324
patch -p1 < $($(package)_patch_dir)/cmake_fixups.patch && \
24-
patch -p1 < $($(package)_patch_dir)/netbsd_fixup.patch
25+
patch -p1 < $($(package)_patch_dir)/netbsd_fixup.patch && \
26+
patch -p1 < $($(package)_patch_dir)/winver_fixup.patch
2527
endef
2628

2729
define $(package)_config_cmds
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
Cherry-picked from a14ff91254f40cf36e0fee199e26fb11260fab49.
2+
3+
move _WIN32_WINNT defintions before first #include
4+
5+
_WIN32_WINNT and WIN32_LEAN_AND_MEAN need to be defined
6+
before the windows.h is included for the first time.
7+
Avoid the confusion of indirect #include by defining
8+
before any.
9+
10+
diff --git a/event_iocp.c b/event_iocp.c
11+
index 6b2a2e15..4955e426 100644
12+
--- a/event_iocp.c
13+
+++ b/event_iocp.c
14+
@@ -23,12 +23,14 @@
15+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
16+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17+
*/
18+
-#include "evconfig-private.h"
19+
20+
#ifndef _WIN32_WINNT
21+
/* Minimum required for InitializeCriticalSectionAndSpinCount */
22+
#define _WIN32_WINNT 0x0403
23+
#endif
24+
+
25+
+#include "evconfig-private.h"
26+
+
27+
#include <winsock2.h>
28+
#include <windows.h>
29+
#include <process.h>
30+
diff --git a/evthread_win32.c b/evthread_win32.c
31+
index 2ec80560..8647f72b 100644
32+
--- a/evthread_win32.c
33+
+++ b/evthread_win32.c
34+
@@ -23,18 +23,21 @@
35+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*/
38+
-#include "event2/event-config.h"
39+
-#include "evconfig-private.h"
40+
41+
#ifdef _WIN32
42+
#ifndef _WIN32_WINNT
43+
/* Minimum required for InitializeCriticalSectionAndSpinCount */
44+
#define _WIN32_WINNT 0x0403
45+
#endif
46+
-#include <winsock2.h>
47+
#define WIN32_LEAN_AND_MEAN
48+
+#endif
49+
+
50+
+#include "event2/event-config.h"
51+
+#include "evconfig-private.h"
52+
+
53+
+#ifdef _WIN32
54+
+#include <winsock2.h>
55+
#include <windows.h>
56+
-#undef WIN32_LEAN_AND_MEAN
57+
#include <sys/locking.h>
58+
#endif
59+
60+
diff --git a/evutil.c b/evutil.c
61+
index 9817f086..8537ffe8 100644
62+
--- a/evutil.c
63+
+++ b/evutil.c
64+
@@ -24,6 +24,14 @@
65+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66+
*/
67+
68+
+#ifdef _WIN32
69+
+#ifndef _WIN32_WINNT
70+
+/* For structs needed by GetAdaptersAddresses */
71+
+#define _WIN32_WINNT 0x0501
72+
+#endif
73+
+#define WIN32_LEAN_AND_MEAN
74+
+#endif
75+
+
76+
#include "event2/event-config.h"
77+
#include "evconfig-private.h"
78+
79+
@@ -31,15 +39,10 @@
80+
#include <winsock2.h>
81+
#include <winerror.h>
82+
#include <ws2tcpip.h>
83+
-#define WIN32_LEAN_AND_MEAN
84+
#include <windows.h>
85+
-#undef WIN32_LEAN_AND_MEAN
86+
#include <io.h>
87+
#include <tchar.h>
88+
#include <process.h>
89+
-#undef _WIN32_WINNT
90+
-/* For structs needed by GetAdaptersAddresses */
91+
-#define _WIN32_WINNT 0x0501
92+
#include <iphlpapi.h>
93+
#include <netioapi.h>
94+
#endif
95+
diff --git a/listener.c b/listener.c
96+
index f5c00c9c..d1080e76 100644
97+
--- a/listener.c
98+
+++ b/listener.c
99+
@@ -24,16 +24,19 @@
100+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101+
*/
102+
103+
+#ifdef _WIN32
104+
+#ifndef _WIN32_WINNT
105+
+/* Minimum required for InitializeCriticalSectionAndSpinCount */
106+
+#define _WIN32_WINNT 0x0403
107+
+#endif
108+
+#endif
109+
+
110+
#include "event2/event-config.h"
111+
#include "evconfig-private.h"
112+
113+
#include <sys/types.h>
114+
115+
#ifdef _WIN32
116+
-#ifndef _WIN32_WINNT
117+
-/* Minimum required for InitializeCriticalSectionAndSpinCount */
118+
-#define _WIN32_WINNT 0x0403
119+
-#endif
120+
#include <winsock2.h>
121+
#include <winerror.h>
122+
#include <ws2tcpip.h>

0 commit comments

Comments
 (0)