qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 6/9] w32: Add and use intermediate include file for


From: Stefan Weil
Subject: [Qemu-devel] [PATCH 6/9] w32: Add and use intermediate include file for windows.h
Date: Sun, 23 Feb 2014 18:02:12 +0100

Including windows.h from the new file include/sysemu/os-winapi.h allows
better tracking of the files which depend on the Windows API.

1864 *.o files depend on windows.h in a typical build, only 88 *.o files
don't.

The windows.h specific macro WIN32_LEAN_AND_MEAN is now defined in the new
file and no longer part of the QEMU_CFLAGS. A hack in ui/sdl.c can be
removed after this change.

WINVER is still needed for all compilations with MinGW, so it cannot be
defined in the new file. Replace its numeric value by a symbolic value to
show which API is requested.

Cc: Gerd Hoffmann <address@hidden>
Cc: Jan Kiszka <address@hidden>
Cc: Anthony Liguori <address@hidden>
Signed-off-by: Stefan Weil <address@hidden>
---
 audio/audio_win_int.c         |    2 +-
 audio/dsoundaudio.c           |    2 +-
 audio/winwaveaudio.c          |    2 +-
 block.c                       |    2 +-
 block/raw-win32.c             |    2 +-
 block/win32-aio.c             |    2 +-
 configure                     |    2 +-
 include/qemu/event_notifier.h |    2 +-
 include/qemu/sockets.h        |    2 +-
 include/qemu/thread-win32.h   |    2 +-
 include/sysemu/os-win32.h     |    2 +-
 include/sysemu/os-winapi.h    |   22 ++++++++++++++++++++++
 net/tap-win32.c               |    2 +-
 os-win32.c                    |    2 +-
 qga/channel-win32.c           |    2 +-
 qga/commands-win32.c          |    2 +-
 qga/service-win32.c           |    2 +-
 qga/service-win32.h           |    2 +-
 qga/vss-win32.c               |    2 +-
 qga/vss-win32/vss-common.h    |    2 +-
 slirp/slirp.h                 |    2 +-
 translate-all.c               |    2 +-
 ui/sdl.c                      |    3 ---
 util/oslib-win32.c            |    2 +-
 24 files changed, 44 insertions(+), 25 deletions(-)
 create mode 100644 include/sysemu/os-winapi.h

diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c
index e132405..eeb41bb 100644
--- a/audio/audio_win_int.c
+++ b/audio/audio_win_int.c
@@ -3,7 +3,7 @@
 #include "qemu-common.h"
 
 #define AUDIO_CAP "win-int"
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <mmsystem.h>
 
 #include "audio.h"
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index e2d89fd..0c0b928 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -32,7 +32,7 @@
 #define AUDIO_CAP "dsound"
 #include "audio_int.h"
 
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <mmsystem.h>
 #include <objbase.h>
 #include <dsound.h>
diff --git a/audio/winwaveaudio.c b/audio/winwaveaudio.c
index 8dbd145..1d8a87d 100644
--- a/audio/winwaveaudio.c
+++ b/audio/winwaveaudio.c
@@ -7,7 +7,7 @@
 #define AUDIO_CAP "winwave"
 #include "audio_int.h"
 
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <mmsystem.h>
 
 #include "audio_win_int.h"
diff --git a/block.c b/block.c
index 6f4baca..c2f3891 100644
--- a/block.c
+++ b/block.c
@@ -47,7 +47,7 @@
 #endif
 
 #ifdef _WIN32
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #endif
 
 struct BdrvDirtyBitmap {
diff --git a/block/raw-win32.c b/block/raw-win32.c
index ae1c8e6..44d76f3 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -29,7 +29,7 @@
 #include "trace.h"
 #include "block/thread-pool.h"
 #include "qemu/iov.h"
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <winioctl.h>
 
 #define FTYPE_FILE 0
diff --git a/block/win32-aio.c b/block/win32-aio.c
index 5d1d199..e8b1d6c 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -29,7 +29,7 @@
 #include "raw-aio.h"
 #include "qemu/event_notifier.h"
 #include "qemu/iov.h"
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <winioctl.h>
 
 #define FTYPE_FILE 0
diff --git a/configure b/configure
index 39f2a1a..a460cf0 100755
--- a/configure
+++ b/configure
@@ -610,7 +610,7 @@ fi
 
 if test "$mingw32" = "yes" ; then
   EXESUF=".exe"
-  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
+  QEMU_CFLAGS="-DWINVER=_WIN32_WINNT_WINXP $QEMU_CFLAGS"
   # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
   QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h
index 88b57af..1b75f29 100644
--- a/include/qemu/event_notifier.h
+++ b/include/qemu/event_notifier.h
@@ -16,7 +16,7 @@
 #include "qemu-common.h"
 
 #ifdef _WIN32
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #endif
 
 struct EventNotifier {
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 45588d7..f82ad17 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -3,7 +3,7 @@
 #define QEMU_SOCKET_H
 
 #ifdef _WIN32
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
index 3d58081..127a7ba 100644
--- a/include/qemu/thread-win32.h
+++ b/include/qemu/thread-win32.h
@@ -1,6 +1,6 @@
 #ifndef __QEMU_THREAD_WIN32_H
 #define __QEMU_THREAD_WIN32_H 1
-#include "windows.h"
+#include "sysemu/os-winapi.h"
 
 struct QemuMutex {
     CRITICAL_SECTION lock;
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index bf8523a..2dd3b1e 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -26,7 +26,7 @@
 #ifndef QEMU_OS_WIN32_H
 #define QEMU_OS_WIN32_H
 
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <winsock2.h>
 
 /* Workaround for older versions of MinGW. */
diff --git a/include/sysemu/os-winapi.h b/include/sysemu/os-winapi.h
new file mode 100644
index 0000000..a7680fd
--- /dev/null
+++ b/include/sysemu/os-winapi.h
@@ -0,0 +1,22 @@
+/*
+ * QEMU interface to the Windows API
+ *
+ * Copyright (c) 2014 Stefan Weil
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2
+ * or later.  See the COPYING file in the top-level directory.
+ */
+
+#ifndef OS_WINAPI_H
+#define OS_WINAPI_H
+
+/* Don't include some less frequently used APIs. */
+#define WIN32_LEAN_AND_MEAN
+
+#if !defined(WINVER)
+# error Add -DWINVER=_WIN32_WINNT_WINXP to compiler options
+#endif
+
+#include <windows.h>
+
+#endif /* OS_WINAPI_H */
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 91e9e84..d55088c 100644
--- a/net/tap-win32.c
+++ b/net/tap-win32.c
@@ -35,7 +35,7 @@
 #include "sysemu/sysemu.h"
 #include "qemu/error-report.h"
 #include <stdio.h>
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <winioctl.h>
 
 //=============
diff --git a/os-win32.c b/os-win32.c
index 50b7f6f..8fcaf3f 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -22,7 +22,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <mmsystem.h>
 #include <unistd.h>
 #include <fcntl.h>
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 8a303f3..3a0bf13 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -2,7 +2,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <errno.h>
 #include <io.h>
 #include "qga/guest-agent-core.h"
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 50094dd..a57b644 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -11,8 +11,8 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "sysemu/os-winapi.h" /* OpenProcessToken, ... */
 #include <glib.h>
-#include <wtypes.h>
 #include <powrprof.h>
 #include "qga/guest-agent-core.h"
 #include "qga/vss-win32.h"
diff --git a/qga/service-win32.c b/qga/service-win32.c
index aef41f0..d8eaccd 100644
--- a/qga/service-win32.c
+++ b/qga/service-win32.c
@@ -13,7 +13,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <glib.h>
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include "qga/service-win32.h"
 
 static int printf_win_error(const char *text)
diff --git a/qga/service-win32.h b/qga/service-win32.h
index 3b9e870..718ff29 100644
--- a/qga/service-win32.h
+++ b/qga/service-win32.h
@@ -13,7 +13,7 @@
 #ifndef QGA_SERVICE_H
 #define QGA_SERVICE_H
 
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 
 #define QGA_SERVICE_DISPLAY_NAME "QEMU Guest Agent"
 #define QGA_SERVICE_NAME         "qemu-ga"
diff --git a/qga/vss-win32.c b/qga/vss-win32.c
index 24c4288..3be8b96 100644
--- a/qga/vss-win32.c
+++ b/qga/vss-win32.c
@@ -11,7 +11,7 @@
  */
 
 #include <stdio.h>
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include "qga/guest-agent-core.h"
 #include "qga/vss-win32.h"
 #include "qga/vss-win32/requester.h"
diff --git a/qga/vss-win32/vss-common.h b/qga/vss-win32/vss-common.h
index ce14e14..9ec5daa 100644
--- a/qga/vss-win32/vss-common.h
+++ b/qga/vss-win32/vss-common.h
@@ -15,7 +15,7 @@
 
 #define __MIDL_user_allocate_free_DEFINED__
 #include "config-host.h"
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <shlwapi.h>
 
 /* Reduce warnings to include vss.h */
diff --git a/slirp/slirp.h b/slirp/slirp.h
index e4a1bd4..6aad613 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -9,7 +9,7 @@
 
 typedef char *caddr_t;
 
-# include <windows.h>
+# include "sysemu/os-winapi.h"
 # include <winsock2.h>
 # include <ws2tcpip.h>
 # include <sys/timeb.h>
diff --git a/translate-all.c b/translate-all.c
index 1ac0246..69110d1 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -17,7 +17,7 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 #ifdef _WIN32
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #else
 #include <sys/types.h>
 #include <sys/mman.h>
diff --git a/ui/sdl.c b/ui/sdl.c
index 9d8583c..7c9ca8b 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -22,9 +22,6 @@
  * THE SOFTWARE.
  */
 
-/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */
-#undef WIN32_LEAN_AND_MEAN
-
 #include <SDL.h>
 #include <SDL_syswm.h>
 
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 50be044..2ea5377 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -25,7 +25,7 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include <windows.h>
+#include "sysemu/os-winapi.h"
 #include <glib.h>
 #include <stdlib.h>
 #include "config-host.h"
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]