From: Stefan Weil <sw@weilnetz.de>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org,
"Anthony Liguori" <aliguori@amazon.com>,
qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v2 4/5] w32: Replace Windows specific data types in common header files
Date: Mon, 10 Mar 2014 19:34:42 +0100 [thread overview]
Message-ID: <531E05C2.8080208@weilnetz.de> (raw)
In-Reply-To: <20140310151713.GD32400@stefanha-thinkpad.redhat.com>
Am 10.03.2014 16:17, schrieb Stefan Hajnoczi:
> On Fri, Mar 07, 2014 at 11:17:46PM +0100, Stefan Weil wrote:
>> diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
>> index 7ade61a..b8b8e61 100644
>> --- a/include/qemu/thread-win32.h
>> +++ b/include/qemu/thread-win32.h
>> @@ -1,24 +1,35 @@
>> #ifndef __QEMU_THREAD_WIN32_H
>> #define __QEMU_THREAD_WIN32_H 1
>> -#include "qemu/winapi.h"
>> +
>> +/* WinCriticalSection is a substitute for CRITICAL_SECTION and
>> + * introduced here to avoid dependencies on windows.h. */
>> +
>> +typedef struct {
>> + WinHandle DebugInfo;
>> + WinLong LockCount;
>> + WinLong RecursionCount;
>> + WinHandle OwningThread;
>> + WinHandle LockSemaphore;
>> + WinULong *SpinCount;
>> +} WinCriticalSection;
>
> This is taking it a bit far. Avoiding includes for the scalar types
> seems okay but duplicating struct definitions makes me wonder how far
> we'll go to reduce compile times. (Plus wouldn't we have the same kind
> of copyright/license issues that mingw and other projects need to be
> very careful about when reimplementing Windows headers?)
I don't think that we have a copyright or license issue here because we
don't use names which were invented by MS. They have a copyright on
win32 (that's why I typically use w32 or wxx), but not on WinXXX AFAIK.
Our existing files with names using win32 might be a problem, although I
doubt that anybody will complain.
Instead of defining a struct, WinCriticalSection could also be an array
which is sufficiently large to store a critical section and which uses
the correct alignment. Do you think that would be a better solution?
> I guess the problem is that qemu-thread.h is included in a lot of places
> and you wish to avoid including <windows.h>. Still, I would leave this
> one out.
>
> Stefan
>
As you noticed, the problem is include/qemu/thread.h which includes
include/qemu/thread-win32.h to define QemuMutex. Unfortunately,
QemuMutex is used by value in include/block/aio.h and in
include/exec/cpu-all.h. Most QEMU files depend on these two files.
Breaking the dependencies of all those files on windows.h is essential
for my patch series. I see only three solutions:
* Leave the code as it is. That implies long compile time for MinGW
builds and name space pollution because nearly every compilation needs
windows.h. This last point is the reason for two existing hacks and one
more hack which is still needed (both Peter and I sent patches for it),
and we have a realistic chance to need future hacks from time to time.
* Break the dependency on windows.h by using QEMU data types instead of
Windows API data types.
* Break the dependency on windows.h by avoiding the use of certain QEMU
data types (especially QemuMutex) by value, because those QEMU data
types use Windows data types.
I must admit that I tried that third solution and gave up after a while.
What do you suggest to do? For me, any of the three alternatives is
fine. I have no personal use for QEMU on Windows, nor do I need it for
my professional work any longer.
Stefan
next prev parent reply other threads:[~2014-03-10 18:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 22:17 [Qemu-devel] [PATCH v2 0/5] w32: Reduce dependency on Windows API Stefan Weil
2014-03-07 22:17 ` [Qemu-devel] [PATCH v2 1/5] w32: Add and use intermediate include file for windows.h Stefan Weil
2014-03-10 8:56 ` Markus Armbruster
2014-03-10 17:38 ` Stefan Weil
2014-03-07 22:17 ` [Qemu-devel] [PATCH v2 2/5] w32: Move inline function from header file to C source Stefan Weil
2014-03-07 22:17 ` [Qemu-devel] [PATCH v2 3/5] w32: Reduce dependencies in sysemu/os-win32.h Stefan Weil
2014-03-07 22:17 ` [Qemu-devel] [PATCH v2 4/5] w32: Replace Windows specific data types in common header files Stefan Weil
2014-03-10 15:17 ` Stefan Hajnoczi
2014-03-10 18:34 ` Stefan Weil [this message]
2014-03-11 7:51 ` Stefan Hajnoczi
2014-03-11 8:06 ` Paolo Bonzini
2014-03-07 22:17 ` [Qemu-devel] [PATCH v2 5/5] block: Review include statements for winioctl.h Stefan Weil
2014-03-10 15:18 ` [Qemu-devel] [PATCH v2 0/5] w32: Reduce dependency on Windows API Stefan Hajnoczi
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=531E05C2.8080208@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@gmail.com \
--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).