All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Anthony Liguori" <aliguori@amazon.com>,
	qemu-devel@nongnu.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 9/9] w32: Replace Windows specific data types in common header files
Date: Tue, 25 Feb 2014 00:17:20 +0100	[thread overview]
Message-ID: <530BD300.3070600@weilnetz.de> (raw)
In-Reply-To: <20140224101730.GF3775@dhcp-200-207.str.redhat.com>

Am 24.02.2014 11:17, schrieb Kevin Wolf:
> Am 23.02.2014 um 18:02 hat Stefan Weil geschrieben:
>> These header files are used by most QEMU source files. If they
>> depend on windows.h, all those source files do so, too.
>>
>> All Windows specific data types which are replaced use identical
>> definitions for the 32 and 64 bit Windows APIs. HANDLE and LONG
>> can be directly replaced by void * and long. CRITICAL_SECTION
>> is replaced by a new struct of the same size.
>>
>> Add an explicit dependency on sysemu/os-winapi.h for some files which need it.
>> These sources use the Windows API (see comment after include statement)
>> and no longer get windows.h indirectly from other header files.
>>
>> A workaround which was added in the previous patch is no longer needed.
>>
>> Now 175 *.o files remain which still depend on windows.h.
>>
>> Cc: Anthony Liguori <aliguori@amazon.com>
>> Cc: Stefan Hajnoczi <stefanha@redhat.com>
>> Cc: Kevin Wolf <kwolf@redhat.com>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Not sure if I understand the problem. Why is it bad to depend on
> windows.h?
>
> Kevin

It's not generally bad, but there are some disadvantages if too many
files depend on it.

Let me explain first what windows.h is (I assume you know that, but
maybe others don't): it is the central Windows API header which includes
lots of other files, so we don't talk about a single header file but a
rather large collection of such files. Another header file which QEMU
uses very often is glib.h for the glib-2.0 API. I counted the number of
files which get included by a simple #include of one of these two header
files and also measured their size:

glib.h (Debian wheezy)
  564910 bytes in 86 files, this includes 22 standard header files like
stddef.h, ...

windows.h (Debian wheezy MinGW-w64)
  3659593 bytes in 116 files (macro WIN32_LEAN_AND_MEAN is not defined),
10 of them are standard header files
  1147623 bytes in 46 files (macro WIN32_LEAN_AND_MEAN is defined)

QEMU uses WIN32_LEAN_AND_MEAN, but even then windows.h gets about 1 MB
of header file code whereas glib.h gets more files but only 0.5 MB of
header file code.

This header file code is analysed by the compiler more than 1800 times
for a full build, so the compiler reads and parses about 2 GB of code.
Native builds on Windows are slow. Reading and parsing 2 GB does not
make them faster. I don't know whether caching compilers are available
for Windows and if so whether they work good.

There exist several implementations of the header files for the Windows
API: the original header files from Microsoft (which exist in different
versions, but QEMU does not use them), the MinGW implementation (was
standard for QEMU), the MinGW-w64 implementation (now recommended for
QEMU, supports 32 and 64 bit) and the Cygwin implementation (currently
unsupported and not working with QEMU). All of them differ and need
special handling. By including windows.h we get potential problems and
namespace pollutions . The current QEMU code already contains some hacks
for such problems (which are removed by my patches) and would need one
more hack (which is not needed with my patches). See also a discussion
which I and Peter had nearly a year ago:
http://patchwork.ozlabs.org/patch/244758/. It was the trigger for this
patch series.

All those different implementations of the Windows API header files use
the same definitions for basic types as HANDLE or LONG, so we don't
loose anything by replacing the Windows specific types by standard C
types. Nor would we gain anything if we introduced new types like
QEMU_HANDLE or QEMU_LONG. Everybody is used to files and sockets being
int on UNIX, so why not use void pointers for Windows handles in this
special case if it avoids pulling gigabytes of code?

Regards
Stefan

  parent reply	other threads:[~2014-02-24 23:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-23 17:02 [Qemu-devel] [PATCH 0/9] w32: Reduce dependency on Windows API Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 1/9] util/iov: Use qemu/sockets.h instead of conditional code Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 2/9] exec: Remove unneeded include files Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 3/9] qemu-img: " Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 4/9] qga: Remove unneeded include file Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 5/9] vl: " Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 6/9] w32: Add and use intermediate include file for windows.h Stefan Weil
2014-02-24 10:26   ` Paolo Bonzini
2014-02-24 23:00     ` Stefan Weil
2014-02-25  8:18       ` Paolo Bonzini
2014-02-23 17:02 ` [Qemu-devel] [PATCH 7/9] w32: Move inline function from header file to C source Stefan Weil
2014-02-23 17:02 ` [Qemu-devel] [PATCH 8/9] w32: Reduce dependencies in sysemu/os-win32.h Stefan Weil
2014-02-24  0:45   ` Max Filippov
2014-02-23 17:02 ` [Qemu-devel] [PATCH 9/9] w32: Replace Windows specific data types in common header files Stefan Weil
2014-02-24 10:17   ` Kevin Wolf
2014-02-24 13:24     ` Peter Maydell
2014-02-24 13:44       ` Kevin Wolf
2014-02-24 13:51         ` Peter Maydell
2014-02-24 23:12           ` Stefan Weil
2014-02-24 23:17     ` Stefan Weil [this message]
2014-02-24 13:07   ` Andreas Färber
2014-02-24 23:07     ` Stefan Weil
2014-02-25  8:37       ` Andreas Färber
2014-02-26  6:14         ` Stefan Weil
2014-02-27 15:45   ` Stefan Hajnoczi
2014-02-25  5:32 ` [Qemu-trivial] [Qemu-devel] [PATCH 0/9] w32: Reduce dependency on Windows API Stefan Weil
2014-02-25  5:32   ` Stefan Weil
2014-02-25  8:20   ` [Qemu-trivial] " Paolo Bonzini
2014-02-25  8:20     ` [Qemu-devel] " Paolo Bonzini
2014-02-25  8:40     ` [Qemu-trivial] " Andreas Färber
2014-02-25  8:40       ` Andreas Färber
2014-03-02 13:31 ` Michael Tokarev

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=530BD300.3070600@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.