* [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
@ 2009-06-18 18:11 Stefan Weil
2009-06-18 18:46 ` Anthony Liguori
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2009-06-18 18:11 UTC (permalink / raw)
To: QEMU Developers
`sdl-config --cflags` defines main = SDL_main
on some platforms. One of these platforms is
Windows with mingw32.
For those platforms, the solution already developed
for __APPLE__ is now applied.
A compiler warning (missing return value) is fixed, too.
Maybe __APPLE__ no longer needs a separate check.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
vl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 3242c23..e688837 100644
--- a/vl.c
+++ b/vl.c
@@ -113,12 +113,12 @@
#endif
#ifdef CONFIG_SDL
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(main)
#include <SDL.h>
int qemu_main(int argc, char **argv, char **envp);
int main(int argc, char **argv)
{
- qemu_main(argc, argv, NULL);
+ return qemu_main(argc, argv, NULL);
}
#undef main
#define main qemu_main
--
1.5.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
2009-06-18 18:11 [Qemu-devel] [PATCH] Win32: Fix compilation with SDL Stefan Weil
@ 2009-06-18 18:46 ` Anthony Liguori
2009-06-18 19:01 ` Stefan Weil
0 siblings, 1 reply; 7+ messages in thread
From: Anthony Liguori @ 2009-06-18 18:46 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developers
Stefan Weil wrote:
> `sdl-config --cflags` defines main = SDL_main
> on some platforms. One of these platforms is
> Windows with mingw32.
>
How about adding -Umain to SDL_CFLAGS on _WIN32 and and __APPLE__?
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
2009-06-18 18:46 ` Anthony Liguori
@ 2009-06-18 19:01 ` Stefan Weil
2009-06-18 19:12 ` Anthony Liguori
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2009-06-18 19:01 UTC (permalink / raw)
To: Anthony Liguori; +Cc: QEMU Developers
Anthony Liguori schrieb:
> Stefan Weil wrote:
>> `sdl-config --cflags` defines main = SDL_main
>> on some platforms. One of these platforms is
>> Windows with mingw32.
>>
>
> How about adding -Umain to SDL_CFLAGS on _WIN32 and and __APPLE__?
>
> Regards,
>
> Anthony Liguori
>
I think -Dmain=SDL_main was added to the SDL CFLAGS because
the SDL implementation needs some special startup code.
Redefining main (or directly using the correct name) is typical
for windows gui applications.
-Umain would destroy this mechanism and create an executable
which won't run in the worst case.
By the way, I just tested the cross compiled i386/qemu.exe
(with my patch) using wine on debian lenny: it works :-)
Regards
Stefan Weil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
2009-06-18 19:01 ` Stefan Weil
@ 2009-06-18 19:12 ` Anthony Liguori
2009-06-18 19:17 ` Stefan Weil
0 siblings, 1 reply; 7+ messages in thread
From: Anthony Liguori @ 2009-06-18 19:12 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developers
Stefan Weil wrote:
> Anthony Liguori schrieb:
>
>> Stefan Weil wrote:
>>
>>> `sdl-config --cflags` defines main = SDL_main
>>> on some platforms. One of these platforms is
>>> Windows with mingw32.
>>>
>>>
>> How about adding -Umain to SDL_CFLAGS on _WIN32 and and __APPLE__?
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>
>
> I think -Dmain=SDL_main was added to the SDL CFLAGS because
> the SDL implementation needs some special startup code.
> Redefining main (or directly using the correct name) is typical
> for windows gui applications.
>
> -Umain would destroy this mechanism and create an executable
> which won't run in the worst case.
>
Why do we need to do anything special then?
I don't understand what the point of the qemu_main stuff is.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
2009-06-18 19:12 ` Anthony Liguori
@ 2009-06-18 19:17 ` Stefan Weil
2009-06-18 20:00 ` Anthony Liguori
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2009-06-18 19:17 UTC (permalink / raw)
To: Anthony Liguori; +Cc: QEMU Developers
Anthony Liguori schrieb:
> Stefan Weil wrote:
>> Anthony Liguori schrieb:
>>
>>> Stefan Weil wrote:
>>>
>>>> `sdl-config --cflags` defines main = SDL_main
>>>> on some platforms. One of these platforms is
>>>> Windows with mingw32.
>>>>
>>> How about adding -Umain to SDL_CFLAGS on _WIN32 and and __APPLE__?
>>>
>>> Regards,
>>>
>>> Anthony Liguori
>>>
>>>
>>
>> I think -Dmain=SDL_main was added to the SDL CFLAGS because
>> the SDL implementation needs some special startup code.
>> Redefining main (or directly using the correct name) is typical
>> for windows gui applications.
>>
>> -Umain would destroy this mechanism and create an executable
>> which won't run in the worst case.
>>
>
> Why do we need to do anything special then?
>
> I don't understand what the point of the qemu_main stuff is.
>
> Regards,
>
> Anthony Liguori
>
Ah, ok: it's simply a bad prototype of SDL_config:
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
QEMU's main does not match:
int main(int argc, char **argv, char **envp)
So just redefining main will result in a wrong SDL_main
with 3 instead of 2 arguments.
Regards,
Stefan Weil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
2009-06-18 19:17 ` Stefan Weil
@ 2009-06-18 20:00 ` Anthony Liguori
2009-06-18 20:49 ` Hollis Blanchard
0 siblings, 1 reply; 7+ messages in thread
From: Anthony Liguori @ 2009-06-18 20:00 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developers, Hollis Blanchard
Stefan Weil wrote:
> Ah, ok: it's simply a bad prototype of SDL_config:
>
> extern C_LINKAGE int SDL_main(int argc, char *argv[]);
>
> QEMU's main does not match:
> int main(int argc, char **argv, char **envp)
>
> So just redefining main will result in a wrong SDL_main
> with 3 instead of 2 arguments.
>
Can we not use getenv() instead of envp in main()? This was introduced
for cache-utils which looks to be PPC specific.
Regards,
Anthony Liguori
> Regards,
> Stefan Weil
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] Win32: Fix compilation with SDL.
2009-06-18 20:00 ` Anthony Liguori
@ 2009-06-18 20:49 ` Hollis Blanchard
0 siblings, 0 replies; 7+ messages in thread
From: Hollis Blanchard @ 2009-06-18 20:49 UTC (permalink / raw)
To: Anthony Liguori; +Cc: QEMU Developers
On Thu, 2009-06-18 at 15:00 -0500, Anthony Liguori wrote:
> Stefan Weil wrote:
> > Ah, ok: it's simply a bad prototype of SDL_config:
> >
> > extern C_LINKAGE int SDL_main(int argc, char *argv[]);
> >
> > QEMU's main does not match:
> > int main(int argc, char **argv, char **envp)
> >
> > So just redefining main will result in a wrong SDL_main
> > with 3 instead of 2 arguments.
> >
>
> Can we not use getenv() instead of envp in main()? This was introduced
> for cache-utils which looks to be PPC specific.
ppc_init_cacheline_sizes() doesn't actually want env; if you look
closely you'll see it walks off the end of that array. What it really
wants is the AUX vector defined in the PowerPC ABI, which is a way for
the kernel to expose capabilities to userland. (IIRC this code should
really be written "main(int argc, char *argv, char **envp, unsigned long
**auxv)", but anyways...)
The only way to access the AUX vector without changing the prototype of
main() is to read /proc/self/auxv. I hear the glibc maintainer has
obstinately refused to add a proper interface to it.
(This issue has come up before because the AUX vector also informs
userspace if Altivec is available. It's typically codec libraries that
want to know, but by the time libraries are loaded, the pointer passed
to main() is long gone.)
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-06-18 20:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-18 18:11 [Qemu-devel] [PATCH] Win32: Fix compilation with SDL Stefan Weil
2009-06-18 18:46 ` Anthony Liguori
2009-06-18 19:01 ` Stefan Weil
2009-06-18 19:12 ` Anthony Liguori
2009-06-18 19:17 ` Stefan Weil
2009-06-18 20:00 ` Anthony Liguori
2009-06-18 20:49 ` Hollis Blanchard
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).