Skip to contentSkip to conversation

Windows compile errors

PATCH In review consul 6 participants 12 messages May 16, 2008 – May 17, 2008

lore
Share & tools
lore

consul

author
#0 lore raw

PATCH 1/1 Windows compile errors

Current svn does not compile under MinGW. The patch below fixes the problem. Should the musicpal part go to a more generic header?

When running
qemu-system-arm -M n800 -m 130 -kernel c:\test\zImage -mtdblock c:\test\n800.img -show-cursor -serial vc -serial vc -serial vc -serial vc -usb -s

I'm getting
omap_l4ta_write: Bad register 0x6800a078
Uncompressing Linux................................................ ........................................ done, booting the kernel. then qemu crashes.

slirp.h (working copy) renamed from slirp.h (revision 4462) +1 -0
Index: slirp/slirp.h
===================================================================
@@ -28,6 +28,7 @@
 typedef uint32_t u_int32_t;
 typedef uint64_t u_int64_t;
 typedef char *caddr_t;
+typedef int socklen_t;
 
 #define WIN32_LEAN_AND_MEAN
 # include <windows.h>
musicpal.c (working copy) renamed from musicpal.c (revision 4462) +3 -1
Index: hw/musicpal.c
===================================================================
@@ -19,7 +19,9 @@
 #include "console.h"
 #include "audio/audio.h"
 #include "i2c.h"
-
+#ifdef _WIN32
+#define sleep Sleep
+#endif
 #define MP_ETH_BASE             0x80008000
 #define MP_ETH_SIZE             0x00001000
#1 lore raw

Hi,

musicpal.c (working copy) line 24

Quoted 3 lines · consul
musicpal.c (working copy) renamed from musicpal.c (revision 4462) +3 -0
+#ifdef _WIN32
+#define sleep Sleep
+#endif

AFAIR sleep() takes seconds, while Sleep() takes milliseconds as an argument.

Ciao,
Dscho

#10 lore raw
In reply to consul
Quoted 2 lines · consul

Current svn does not compile under MinGW. The patch below fixes the problem. Should the musicpal part go to a more generic header?

<snip>

Quoted 1 line

+typedef int socklen_t;

That might be OK on windows, but its probably not a good idea on any other platform. Maybe surround it with "#ifdef _WIN32"?

Erik

Signature · 5 lines
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"The happiness you have demanded is now mandatory."
    -- Jello Biafra
author
#11 lore raw

It's already in #ifdef'ed section

Signature · 5 lines
Alex.


"Erik de Castro Lopo" <[email protected]> wrote in message 
news:[email protected]...
Quoted 23 lines
Quoted 3 lines · consul

Current svn does not compile under MinGW. The patch below fixes the problem.
Should the musicpal part go to a more generic header?

<snip>

Quoted 1 line

+typedef int socklen_t;

That might be OK on windows, but its probably not a good idea on any other platform. Maybe surround it with "#ifdef _WIN32"?

Erik

Signature · 5 lines
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"The happiness you have demanded is now mandatory."
   -- Jello Biafra
author
#2 lore raw
In reply to Johannes Schindelin
Quoted 3 lines

AFAIR sleep() takes seconds, while Sleep() takes milliseconds as an argument.

You are right. Perhaps this is a better patch:

slirp.h (working copy) renamed from slirp.h (revision 4462) +1 -0
Index: slirp/slirp.h
===================================================================
@@ -28,6 +28,7 @@
 typedef uint32_t u_int32_t;
 typedef uint64_t u_int64_t;
 typedef char *caddr_t;
+typedef int socklen_t;
 
 #define WIN32_LEAN_AND_MEAN
 # include <windows.h>
musicpal.c (working copy) renamed from musicpal.c (revision 4462) +3 -0
Index: hw/musicpal.c
===================================================================
@@ -19,6 +19,9 @@
 #include "console.h"
 #include "audio/audio.h"
 #include "i2c.h"
+#ifdef _WIN32
+#define sleep(x) (Sleep(x * 1000))
+#endif
 
 #define MP_ETH_BASE             0x80008000
 #define MP_ETH_SIZE             0x00001000
#3 lore raw

Hi,

musicpal.c (working copy) line 24

Quoted 3 lines · Alex
musicpal.c (working copy) renamed from musicpal.c (revision 4462) +3 -0
+#ifdef _WIN32
+#define sleep(x) (Sleep(x * 1000))
+#endif

It is common to say "Sleep((x) * 1000)" to prevent errors, such as when you write "sleep(1000 + 0);"

Ciao,
Dscho

#9 lore raw
In reply to Alex

2008/5/16 Alex <[email protected]>:

Quoted 12 lines
Quoted 4 lines

AFAIR sleep() takes seconds, while Sleep() takes milliseconds as an argument.

You are right. Perhaps this is a better patch:

Index: slirp/slirp.h
===================================================================

slirp.h (working copy) line 34

Quoted 7 lines
slirp.h (working copy) renamed from slirp.h (revision 4462) +1 -0
@@ -28,6 +28,7 @@
 typedef uint32_t u_int32_t;
 typedef uint64_t u_int64_t;
 typedef char *caddr_t;
+typedef int socklen_t;
 
 #define WIN32_LEAN_AND_MEAN
 # include <windows.h>

There's no need to explicitly typedef socklen_t, it is already done in ws2tcpip.h:

slirp.h +1 -0
@@ -32,6 +32,7 @@
 #define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 # include <winsock2.h>
+# include <ws2tcpip.h>
 # include <sys/timeb.h>
 # include <iphlpapi.h>
 

Regards,
Edu

author
#4 lore raw
In reply to Johannes Schindelin

"Johannes Schindelin" <[email protected]> wrote in message news:alpine.DEB.1.00.0805161043540.30431@racer...

Quoted 3 lines

It is common to say "Sleep((x) * 1000)" to prevent errors, such as when you write "sleep(1000 + 0);"

I think this may be not a right thing to do anyway. How does the sleep help here? does the musicpal_init run in a separate thread?
/*
* Wait a bit to catch menu button during U-Boot start-up
* (to trigger emergency update).
*/
sleep(1);

#5 lore raw
Quoted 8 lines · consul

"Johannes Schindelin" <[email protected]> wrote in message news:alpine.DEB.1.00.0805161043540.30431@racer...

Quoted 3 lines

It is common to say "Sleep((x) * 1000)" to prevent errors, such as when you write "sleep(1000 + 0);"

Quoted 7 lines

I think this may be not a right thing to do anyway. How does the sleep help
here? does the musicpal_init run in a separate thread?
/*
* Wait a bit to catch menu button during U-Boot start-up
* (to trigger emergency update).
*/
sleep(1);

I understand this was meant to give the user time to press a key on the keyboard after realeasing enter when running qemu from command line, and before the emulation starts. Yes, it's hack but I merged it because it was quite obvious and the harm from removing it is minor.

Regarding the n800 breakage, I mentioned earlier that it's broken without a patch posted on this list. I'll try to come with something to make it work out of the box.

Regards

#6 lore raw
In reply to consul
Quoted 6 lines · consul

"Johannes Schindelin" <[email protected]> wrote in message news:alpine.DEB.1.00.0805161043540.30431@racer...

Quoted 3 lines

It is common to say "Sleep((x) * 1000)" to prevent errors, such as when you write "sleep(1000 + 0);"

Quoted 7 lines

I think this may be not a right thing to do anyway. How does the sleep help here? does the musicpal_init run in a separate thread?
/*
* Wait a bit to catch menu button during U-Boot start-up
* (to trigger emergency update).
*/
sleep(1);

This opens a window after the virtual LCD popped up and before the guest starts to boot so that the user can hit a special key. With the real device, you would hold down that button before powering on the hardware, but that won't work with QEMU... :)

Anyway, my bad. I thought Windows understands basic POSIX (at least it was once certified for it ;) ) - no, I didn't thought at all.

Is there no official delay wrapper in QEMU?

Jan

author
#7 lore raw

"Jan Kiszka" <[email protected]> wrote in message
news:[email protected]...

Quoted 4 lines

This opens a window after the virtual LCD popped up and before the guest starts to boot so that the user can hit a special key. With the real device, you would hold down that button before powering on the hardware, but that won't work with QEMU... :)

Sorry for my ignorance, but won't a command line switch better fulfill this purpose?
Then if you really want the popup, you can show it from a launcher script before
even starting qemu...

Alex.

#8 lore raw
Quoted 7 lines · Alex

"Jan Kiszka" <[email protected]> wrote in message
news:[email protected]...

Quoted 4 lines

This opens a window after the virtual LCD popped up and before the guest starts to boot so that the user can hit a special key. With the real device, you would hold down that button before powering on the hardware, but that won't work with QEMU... :)

Quoted 5 lines

Sorry for my ignorance, but won't a command line switch better fulfill this purpose?
Then if you really want the popup, you can show it from a launcher script before
even starting qemu...

That's basically true, and it used to be my first idea as well. But at that time, I didn't like to add yet another special-purpose switch to the long list of existing ones.

I still do not like the idea of patch vl.c with MusicPal specifics. But now I dug out and polished some per-machine-options patch of mine. On top of it, I have written a fix for the MusicPal, see following postings.

Jan