qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Stefan Weil <sw@weilnetz.de>,
	qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>,
	Jan Kiszka <jan.kiszka@siemens.com>
Subject: [Qemu-devel] [PULL for 2.0 2/5] w32: Add and use intermediate include file for windows.h
Date: Thu, 20 Mar 2014 07:25:09 +0100	[thread overview]
Message-ID: <1395296712-25274-3-git-send-email-sw@weilnetz.de> (raw)
In-Reply-To: <1395296712-25274-1-git-send-email-sw@weilnetz.de>

Including windows.h from the new file include/qemu/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 <kraxel@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Anthony Liguori <aliguori@amazon.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 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/qemu/winapi.h         |   22 ++++++++++++++++++++++
 include/sysemu/os-win32.h     |    2 +-
 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/qemu/winapi.h

diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c
index e132405..0e9f2a4 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 "qemu/winapi.h"
 #include <mmsystem.h>
 
 #include "audio.h"
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index e2d89fd..cf779bf 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 "qemu/winapi.h"
 #include <mmsystem.h>
 #include <objbase.h>
 #include <dsound.h>
diff --git a/audio/winwaveaudio.c b/audio/winwaveaudio.c
index 8dbd145..f11f5ba 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 "qemu/winapi.h"
 #include <mmsystem.h>
 
 #include "audio_win_int.h"
diff --git a/block.c b/block.c
index acb70fd..8d308c1 100644
--- a/block.c
+++ b/block.c
@@ -47,7 +47,7 @@
 #endif
 
 #ifdef _WIN32
-#include <windows.h>
+#include "qemu/winapi.h"
 #endif
 
 struct BdrvDirtyBitmap {
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 48cb2c2..1ac9137 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -23,13 +23,13 @@
  */
 #include "qemu-common.h"
 #include "qemu/timer.h"
+#include "qemu/winapi.h"        /* HANDLE (in raw-aio.h) */
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include "raw-aio.h"
 #include "trace.h"
 #include "block/thread-pool.h"
 #include "qemu/iov.h"
-#include <windows.h>
 #include <winioctl.h>
 
 #define FTYPE_FILE 0
diff --git a/block/win32-aio.c b/block/win32-aio.c
index 5d1d199..dbcc6bc 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -23,13 +23,13 @@
  */
 #include "qemu-common.h"
 #include "qemu/timer.h"
+#include "qemu/winapi.h"        /* HANDLE (in raw-aio.h) */
 #include "block/block_int.h"
 #include "qemu/module.h"
 #include "block/aio.h"
 #include "raw-aio.h"
 #include "qemu/event_notifier.h"
 #include "qemu/iov.h"
-#include <windows.h>
 #include <winioctl.h>
 
 #define FTYPE_FILE 0
diff --git a/configure b/configure
index 5eaa802..244ad17 100755
--- a/configure
+++ b/configure
@@ -670,7 +670,7 @@ fi
 if test "$mingw32" = "yes" ; then
   EXESUF=".exe"
   DSOSUF=".dll"
-  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..bdca689 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 "qemu/winapi.h"
 #endif
 
 struct EventNotifier {
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 45588d7..a41d453 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 "qemu/winapi.h"
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
index 3d58081..7ade61a 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 "qemu/winapi.h"
 
 struct QemuMutex {
     CRITICAL_SECTION lock;
diff --git a/include/qemu/winapi.h b/include/qemu/winapi.h
new file mode 100644
index 0000000..d4cfaaa
--- /dev/null
+++ b/include/qemu/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 QEMU_WINAPI_H
+#define QEMU_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 /* QEMU_WINAPI_H */
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index bf8523a..1d6494a 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 "qemu/winapi.h"
 #include <winsock2.h>
 
 /* Workaround for older versions of MinGW. */
diff --git a/net/tap-win32.c b/net/tap-win32.c
index 8aee611..52e6143 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 "qemu/winapi.h"
 #include <winioctl.h>
 
 //=============
diff --git a/os-win32.c b/os-win32.c
index 5f95caa..f6ec112 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 "qemu/winapi.h"
 #include <mmsystem.h>
 #include <unistd.h>
 #include <fcntl.h>
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index 0d5e5f5..25c3257 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 "qemu/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 0ee07b6..48cc819 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 "qemu/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..b22ae67 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 "qemu/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..bd401f2 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 "qemu/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..c6970d2 100644
--- a/qga/vss-win32.c
+++ b/qga/vss-win32.c
@@ -11,7 +11,7 @@
  */
 
 #include <stdio.h>
-#include <windows.h>
+#include "qemu/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..9768c1e 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 "qemu/winapi.h"
 #include <shlwapi.h>
 
 /* Reduce warnings to include vss.h */
diff --git a/slirp/slirp.h b/slirp/slirp.h
index e4a1bd4..bb25ab9 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -9,7 +9,7 @@
 
 typedef char *caddr_t;
 
-# include <windows.h>
+# include "qemu/winapi.h"
 # include <winsock2.h>
 # include <ws2tcpip.h>
 # include <sys/timeb.h>
diff --git a/translate-all.c b/translate-all.c
index f243c10..7d9e9d8 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 "qemu/winapi.h"
 #else
 #include <sys/types.h>
 #include <sys/mman.h>
diff --git a/ui/sdl.c b/ui/sdl.c
index 4e7f920..e0bdebf 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>
 
 #if SDL_MAJOR_VERSION == 1
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 93f7d35..3fbe72a 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 "qemu/winapi.h"
 #include <glib.h>
 #include <stdlib.h>
 #include "config-host.h"
-- 
1.7.10.4

  parent reply	other threads:[~2014-03-20  6:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20  6:25 [Qemu-devel] [PULL for 2.0 0/5] MinGW related patches Stefan Weil
2014-03-20  6:25 ` [Qemu-devel] [PULL for 2.0 1/5] gtk: Support GTK without VTE Stefan Weil
2014-03-20  6:25 ` Stefan Weil [this message]
2014-03-20  6:25 ` [Qemu-devel] [PULL for 2.0 3/5] w32: Move inline function from header file to C source Stefan Weil
2014-03-20  6:25 ` [Qemu-devel] [PULL for 2.0 4/5] w32: Reduce dependencies in sysemu/os-win32.h Stefan Weil
2014-03-20  6:25 ` [Qemu-devel] [PULL for 2.0 5/5] w32: Replace Windows specific data types in common header files Stefan Weil
2014-03-20 14:00   ` Andreas Färber
2014-03-20  6:29 ` [Qemu-devel] [PULL for 2.0 0/5] MinGW related patches Stefan Weil
2014-03-20 12:45   ` Peter Maydell
2014-03-20 19:12     ` Stefan Weil
2014-03-20 19:16       ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395296712-25274-3-git-send-email-sw@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=aliguori@amazon.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).