winver_fixup.patch raw
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>
123