Commit 49dc768d4c579298d56777348422ebdca565a3ef

Authored by aliguori
1 parent 2734c703

Fix windows build and clean up use of <windows.h>

We want to globally define WIN_LEAN_AND_MEAN and WINVER to particular values so
let's do it in OS_CFLAGS.

Then, we can pepper in windows.h includes where using #includes that require it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6783 c046a42c-6fe2-441c-8c8c-71466251a162
block-raw-win32.c
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 #include "qemu-timer.h" 25 #include "qemu-timer.h"
26 #include "block_int.h" 26 #include "block_int.h"
27 #include <assert.h> 27 #include <assert.h>
  28 +#include <windows.h>
28 #include <winioctl.h> 29 #include <winioctl.h>
29 30
30 //#define WIN32_AIO 31 //#define WIN32_AIO
@@ -40,6 +40,10 @@ @@ -40,6 +40,10 @@
40 #endif 40 #endif
41 #endif 41 #endif
42 42
  43 +#ifdef _WIN32
  44 +#include <windows.h>
  45 +#endif
  46 +
43 #define SECTOR_BITS 9 47 #define SECTOR_BITS 9
44 #define SECTOR_SIZE (1 << SECTOR_BITS) 48 #define SECTOR_SIZE (1 << SECTOR_BITS)
45 49
configure
@@ -590,6 +590,7 @@ if test &quot;$mingw32&quot; = &quot;yes&quot; ; then @@ -590,6 +590,7 @@ if test &quot;$mingw32&quot; = &quot;yes&quot; ; then
590 oss="no" 590 oss="no"
591 linux_user="no" 591 linux_user="no"
592 bsd_user="no" 592 bsd_user="no"
  593 + OS_CFLAGS="$OS_CFLAGS -DWIN32_LEAN_AND_MEAN -DWINVER=0x501"
593 fi 594 fi
594 595
595 if test ! -x "$(which cgcc 2>/dev/null)"; then 596 if test ! -x "$(which cgcc 2>/dev/null)"; then
@@ -19,7 +19,6 @@ @@ -19,7 +19,6 @@
19 */ 19 */
20 #include "config.h" 20 #include "config.h"
21 #ifdef _WIN32 21 #ifdef _WIN32
22 -#define WIN32_LEAN_AND_MEAN  
23 #include <windows.h> 22 #include <windows.h>
24 #include <winioctl.h> 23 #include <winioctl.h>
25 #else 24 #else
@@ -102,6 +102,7 @@ @@ -102,6 +102,7 @@
102 #endif 102 #endif
103 103
104 #ifdef _WIN32 104 #ifdef _WIN32
  105 +#include <windows.h>
105 #include <malloc.h> 106 #include <malloc.h>
106 #include <sys/timeb.h> 107 #include <sys/timeb.h>
107 #include <mmsystem.h> 108 #include <mmsystem.h>
@@ -37,7 +37,6 @@ @@ -37,7 +37,6 @@
37 #include "config-host.h" 37 #include "config-host.h"
38 38
39 #ifdef _WIN32 39 #ifdef _WIN32
40 -#define WIN32_LEAN_AND_MEAN  
41 #include <windows.h> 40 #include <windows.h>
42 #elif defined(HOST_BSD) 41 #elif defined(HOST_BSD)
43 #include <stdlib.h> 42 #include <stdlib.h>
qemu-common.h
@@ -2,12 +2,6 @@ @@ -2,12 +2,6 @@
2 #ifndef QEMU_COMMON_H 2 #ifndef QEMU_COMMON_H
3 #define QEMU_COMMON_H 3 #define QEMU_COMMON_H
4 4
5 -#ifdef _WIN32  
6 -#define WIN32_LEAN_AND_MEAN  
7 -#define WINVER 0x0501 /* needed for ipv6 bits */  
8 -#include <windows.h>  
9 -#endif  
10 -  
11 #define QEMU_NORETURN __attribute__ ((__noreturn__)) 5 #define QEMU_NORETURN __attribute__ ((__noreturn__))
12 6
13 /* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that 7 /* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that
qemu-img.c
@@ -27,7 +27,6 @@ @@ -27,7 +27,6 @@
27 #include <assert.h> 27 #include <assert.h>
28 28
29 #ifdef _WIN32 29 #ifdef _WIN32
30 -#define WIN32_LEAN_AND_MEAN  
31 #include <windows.h> 30 #include <windows.h>
32 #endif 31 #endif
33 32
qemu_socket.h
@@ -3,8 +3,6 @@ @@ -3,8 +3,6 @@
3 #define QEMU_SOCKET_H 3 #define QEMU_SOCKET_H
4 4
5 #ifdef _WIN32 5 #ifdef _WIN32
6 -#define WIN32_LEAN_AND_MEAN  
7 -#define WINVER 0x0501 /* needed for ipv6 bits */  
8 #include <windows.h> 6 #include <windows.h>
9 #include <winsock2.h> 7 #include <winsock2.h>
10 #include <ws2tcpip.h> 8 #include <ws2tcpip.h>
savevm.c
@@ -71,6 +71,7 @@ @@ -71,6 +71,7 @@
71 #endif 71 #endif
72 72
73 #ifdef _WIN32 73 #ifdef _WIN32
  74 +#include <windows.h>
74 #include <malloc.h> 75 #include <malloc.h>
75 #include <sys/timeb.h> 76 #include <sys/timeb.h>
76 #include <mmsystem.h> 77 #include <mmsystem.h>
slirp/slirp.h
@@ -29,7 +29,6 @@ typedef uint32_t u_int32_t; @@ -29,7 +29,6 @@ typedef uint32_t u_int32_t;
29 typedef uint64_t u_int64_t; 29 typedef uint64_t u_int64_t;
30 typedef char *caddr_t; 30 typedef char *caddr_t;
31 31
32 -#define WIN32_LEAN_AND_MEAN  
33 # include <windows.h> 32 # include <windows.h>
34 # include <winsock2.h> 33 # include <winsock2.h>
35 # include <ws2tcpip.h> 34 # include <ws2tcpip.h>
sysemu.h
@@ -4,6 +4,10 @@ @@ -4,6 +4,10 @@
4 4
5 #include "qemu-common.h" 5 #include "qemu-common.h"
6 6
  7 +#ifdef _WIN32
  8 +#include <windows.h>
  9 +#endif
  10 +
7 /* vl.c */ 11 /* vl.c */
8 extern const char *bios_name; 12 extern const char *bios_name;
9 extern const char *bios_dir; 13 extern const char *bios_dir;
tap-win32.c
@@ -30,7 +30,6 @@ @@ -30,7 +30,6 @@
30 #include "net.h" 30 #include "net.h"
31 #include "sysemu.h" 31 #include "sysemu.h"
32 #include <stdio.h> 32 #include <stdio.h>
33 -#define WIN32_LEAN_AND_MEAN  
34 #include <windows.h> 33 #include <windows.h>
35 34
36 /* NOTE: PCIBus is redefined in winddk.h */ 35 /* NOTE: PCIBus is redefined in winddk.h */
@@ -103,6 +103,7 @@ @@ -103,6 +103,7 @@
103 #endif 103 #endif
104 104
105 #ifdef _WIN32 105 #ifdef _WIN32
  106 +#include <windows.h>
106 #include <malloc.h> 107 #include <malloc.h>
107 #include <sys/timeb.h> 108 #include <sys/timeb.h>
108 #include <mmsystem.h> 109 #include <mmsystem.h>