Re: [Qemu-devel][Patch] Windows build broken

2007-12-16 Thread Paul Brook
> Typically, gcc provides a built-in function ffs

Actually, not it doesn't.
As with many other standard functions, gcc will sometimes optimize it, maybe 
expanding to inline code. However there's always the possibility of falling 
back to the standard C library implementation.

Paul




Re: [Qemu-devel][Patch] Windows build broken

2007-12-15 Thread Stefan Weil
JonY schrieb:
>
> Ok, this patch works as intended. Thanks for the patch!
>
> Slightly off topic, but still on Windows builds broken.
>
> For some odd reason, dyngen-exec.h is always conflicting with
> stdint.h(?!!) for me. Can somebody explain why the typedefs are in
> dyngen-exec.h?
>
> Mingw does not have ffs, localtime_r, gmtime_r, which breaks when
> compiling some files.
>
> I propose adding the following for *_r functions on mingw hosts.
> #define localtime_r(x, y) memcpy(y, localtime(x), sizeof(y))
> #define gmtime_r(x, y) memcpy(y, gmtime(x), sizeof(y))
>
> There are many implementations of ffs(), but I'm unsure what it does :(

>From the man page: ffs - find first bit set in a word

Typically, gcc provides a built-in function ffs, so there is no need to get
an implementation for Windows. The missing prototype just gives a warning.
I send here a patch which adds the prototype to osdep.h (only for Win32).

gmtime_r is really missing (see hw/omap.c). This was already discussed
in another thread,
but not solved up to now.

Stefan

Index: osdep.h
===
RCS file: /sources/qemu/qemu/osdep.h,v
retrieving revision 1.11
diff -u -r1.11 osdep.h
--- osdep.h	19 Nov 2007 00:38:33 -	1.11
+++ osdep.h	14 Dec 2007 19:03:49 -
@@ -56,6 +56,7 @@
 int qemu_create_pidfile(const char *filename);
 
 #ifdef _WIN32
+int ffs(int i);
 typedef struct {
 long tv_sec;
 long tv_usec;


Re: [Qemu-devel][Patch] Windows build broken

2007-12-13 Thread JonY

Stefan Weil wrote:

Here is a patch using WIN32_LEAN_AND_MEAN which tries not to break
dsound (and vl.c). I could only test it using cross compilation from Linux,
so please send comments.

Patch description:
* add WIN32_LEAN_AND_MEAN to all inclusions of windows.h
* remove windows.h from vl.c (it is already included otherwise)
* add mmsystem.h to vl.c and dsoundaudio.c (they need it and got it from
windows.h)
* fixed indentation in vl.c (wrong indentation was caused by an earlier
patch from me)

It will be difficult to avoid using variable names like "interface" in the
future, so I still think using a minimal set of includes is the better
(and faster) solution.

Anyway, Windows users need a working solution, so it would be nice if one
of these patches could be applied to CVS HEAD.

Thank you.
Stefan

JonY schrieb:

Stefan Weil wrote:

basetyps.h is included by windows.h / rpc.h. QEMU does not need it, so
you can avoid it like this:

#define WIN32_LEAN_AND_MEAN
#include 

WIN32_LEAN_AND_MEAN reduces the number of includes in windows.h
and increases compilation speed. And you don't have to rename
variables like interface :-)

Regards,
Stefan

Hi,

I would prefer Eduardo's patch, defining WIN32_LEAN_AND_MEAN breaks
dsound.

Thanks.







Ok, this patch works as intended. Thanks for the patch!

Slightly off topic, but still on Windows builds broken.

For some odd reason, dyngen-exec.h is always conflicting with 
stdint.h(?!!) for me. Can somebody explain why the typedefs are in 
dyngen-exec.h?


Mingw does not have ffs, localtime_r, gmtime_r, which breaks when 
compiling some files.


I propose adding the following for *_r functions on mingw hosts.
#define localtime_r(x, y) memcpy(y, localtime(x), sizeof(y))
#define gmtime_r(x, y) memcpy(y, gmtime(x), sizeof(y))

There are many implementations of ffs(), but I'm unsure what it does :(




Re: [Qemu-devel][Patch] Windows build broken

2007-12-13 Thread Stefan Weil
Here is a patch using WIN32_LEAN_AND_MEAN which tries not to break
dsound (and vl.c). I could only test it using cross compilation from Linux,
so please send comments.

Patch description:
* add WIN32_LEAN_AND_MEAN to all inclusions of windows.h
* remove windows.h from vl.c (it is already included otherwise)
* add mmsystem.h to vl.c and dsoundaudio.c (they need it and got it from
windows.h)
* fixed indentation in vl.c (wrong indentation was caused by an earlier
patch from me)

It will be difficult to avoid using variable names like "interface" in the
future, so I still think using a minimal set of includes is the better
(and faster) solution.

Anyway, Windows users need a working solution, so it would be nice if one
of these patches could be applied to CVS HEAD.

Thank you.
Stefan

JonY schrieb:
> Stefan Weil wrote:
>> basetyps.h is included by windows.h / rpc.h. QEMU does not need it, so
>> you can avoid it like this:
>>
>> #define WIN32_LEAN_AND_MEAN
>> #include 
>>
>> WIN32_LEAN_AND_MEAN reduces the number of includes in windows.h
>> and increases compilation speed. And you don't have to rename
>> variables like interface :-)
>>
>> Regards,
>> Stefan
>
> Hi,
>
> I would prefer Eduardo's patch, defining WIN32_LEAN_AND_MEAN breaks
> dsound.
>
> Thanks.
>
>
>

Index: qemu_socket.h
===
RCS file: /sources/qemu/qemu/qemu_socket.h,v
retrieving revision 1.2
diff -u -r1.2 qemu_socket.h
--- qemu_socket.h	21 Dec 2006 19:46:43 -	1.2
+++ qemu_socket.h	13 Dec 2007 20:09:04 -
@@ -3,7 +3,7 @@
 #define QEMU_SOCKET_H
 
 #ifdef _WIN32
-
+#define WIN32_LEAN_AND_MEAN
 #include 
 #include 
 #include 
Index: osdep.c
===
RCS file: /sources/qemu/qemu/osdep.c,v
retrieving revision 1.20
diff -u -r1.20 osdep.c
--- osdep.c	18 Nov 2007 01:44:35 -	1.20
+++ osdep.c	13 Dec 2007 20:09:05 -
@@ -37,6 +37,7 @@
 #include "sysemu.h"
 
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
 #include 
 #elif defined(_BSD)
 #include 
Index: vl.c
===
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.379
diff -u -r1.379 vl.c
--- vl.c	11 Dec 2007 23:23:51 -	1.379
+++ vl.c	13 Dec 2007 20:09:07 -
@@ -109,7 +109,7 @@
 #ifdef _WIN32
 #include 
 #include 
-#include 
+#include 
 #define getopt_long_only getopt_long
 #define memalign(align, size) malloc(size)
 #endif
@@ -8937,7 +8937,7 @@
 s->down_script[0])
 launch_script(s->down_script, ifname, s->fd);
 }
-}
+}
 }
 #endif
 return 0;
Index: tap-win32.c
===
RCS file: /sources/qemu/qemu/tap-win32.c,v
retrieving revision 1.7
diff -u -r1.7 tap-win32.c
--- tap-win32.c	17 Nov 2007 17:14:38 -	1.7
+++ tap-win32.c	13 Dec 2007 20:09:07 -
@@ -30,6 +30,7 @@
 #include "net.h"
 #include "sysemu.h"
 #include 
+#define WIN32_LEAN_AND_MEAN
 #include 
 
 /* NOTE: PCIBus is redefined in winddk.h */
Index: qemu-common.h
===
RCS file: /sources/qemu/qemu/qemu-common.h,v
retrieving revision 1.3
diff -u -r1.3 qemu-common.h
--- qemu-common.h	19 Nov 2007 00:38:33 -	1.3
+++ qemu-common.h	13 Dec 2007 20:09:07 -
@@ -28,6 +28,7 @@
 #endif
 
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
 #include 
 #define fsync _commit
 #define lseek _lseeki64
Index: exec.c
===
RCS file: /sources/qemu/qemu/exec.c,v
retrieving revision 1.119
diff -u -r1.119 exec.c
--- exec.c	12 Dec 2007 01:16:22 -	1.119
+++ exec.c	13 Dec 2007 20:09:08 -
@@ -19,6 +19,7 @@
  */
 #include "config.h"
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
 #include 
 #else
 #include 
Index: qemu-img.c
===
RCS file: /sources/qemu/qemu/qemu-img.c,v
retrieving revision 1.25
diff -u -r1.25 qemu-img.c
--- qemu-img.c	11 Nov 2007 03:33:13 -	1.25
+++ qemu-img.c	13 Dec 2007 20:09:09 -
@@ -26,6 +26,7 @@
 #include 
 
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
 #include 
 #endif
 
Index: kqemu.c
===
RCS file: /sources/qemu/qemu/kqemu.c,v
retrieving revision 1.19
diff -u -r1.19 kqemu.c
--- kqemu.c	17 Sep 2007 08:09:44 -	1.19
+++ kqemu.c	13 Dec 2007 20:09:09 -
@@ -19,6 +19,7 @@
  */
 #include "config.h"
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
 #include 
 #include 
 #else
Index: audio/dsoundaudio.c
===
RCS file: /sources/qemu/qemu/audio/dsoundaudio.c,v
retrieving revision 1.4
diff -u -r1.4 dsoundaudio.c
--- audio/dsoundaudio.c	17 Nov 2007 17:35:54 -	1.4
+++ audio/dsoundaudio.c	13 Dec 2007 20:09:09 -
@@ -32,7 +32,9 @@
 #define AUDIO_CAP "dsound"
 #include "audio_int.h"
 
+#define WIN32_LEAN_AN