Skip to contentSkip to conversation

Cocoa patches for 1.0

PATCH In review Andreas Färber 3 participants 24 messages Oct 31, 2011 – Nov 1, 2011

lore
Share & tools
lore
#0 lore raw

v2 cover Cocoa patches for 1.0

Hello,

Here's an updated series, including a runtime abort fix and a GUI bugfix.

Note: Patch 3/4 touches generic code.

Regards,
Andreas

Andreas Färber (4):
MAINTAINERS: Add Cocoa maintainer
softfloat: Avoid uint16 type conflict on Darwin vl.c: Guard against GThread double-initialization
cocoa: Close sheet after image file selection

 MAINTAINERS     |    5 +++++
 fpu/softfloat.h |    3 +++
 ui/cocoa.m      |    2 ++
 vl.c            |    4 +++-
 4 files changed, 13 insertions(+), 1 deletions(-)
#1 lore raw

PATCH v2 1/4 MAINTAINERS: Add Cocoa maintainer

Degrade cocoa.m from Maintained to Odd Fixes.

---
 MAINTAINERS |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
MAINTAINERS +5 -0
index 2b4c5d7..c08951c 100644
@@ -446,6 +446,11 @@ M: Anthony Liguori <[email protected]>
 S: Maintained
 F: ui/
 
+Cocoa graphics
+M: Andreas Färber <[email protected]>
+S: Odd Fixes
+F: ui/cocoa.m
+
 Main loop
 M: Anthony Liguori <[email protected]>
 S: Supported
Signature · 1 line
1.7.0.3
#2 lore raw

PATCH v2 2/4 softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber

In file included from ./bswap.h:7,

                 from ./qemu-common.h:106,
                 from ./qemu-aio.h:17,
                 from ./Block.h:4,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FSEvents.h:28,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:218,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
                 from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
                 from /System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:17,
                 from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:81,
                 from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from ui/cocoa.m:25:

/Users/andreas/QEMU/qemu/fpu/softfloat.h:60: error: conflicting types for ‘uint16’ /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:73: error: previous declaration of ‘uint16’ was here
make: *** [ui/cocoa.o] Error 1

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Therefore work around the conflict in softfloat.h itself by renaming specifically uint16 on Darwin to qemu_uint16. This fixes the build until we have a more general solution.

Cc Juan Pineda <[email protected]>
Cc Peter Maydell <[email protected]>
---
 fpu/softfloat.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fpu/softfloat.h +3 -0
index 07c2929..5320945 100644
@@ -54,6 +54,9 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
+#ifdef __APPLE__
+#define uint16 qemu_uint16
+#endif
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX
Signature · 1 line
1.7.0.3
#22 lore raw

PATCH v2 3/4 vl.c: Guard against GThread double-initialization

In reply to Andreas Färber

GThread-ERROR **: GThread system may only be initialized once. aborting...

Making the g_thread_init() call in vl.c conditional resolves an abort on Mac OS X, where coroutine-gthread.c seems to call it before vl.c.

---
 vl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
vl.c +3 -1
index 1ddb17b..46b2909 100644
@@ -2185,7 +2185,9 @@ int main(int argc, char **argv, char **envp)
     error_set_progname(argv[0]);
 
     g_mem_set_vtable(&mem_trace);
-    g_thread_init(NULL);
+    if (!g_thread_supported()) {
+        g_thread_init(NULL);
+    }
 
     runstate_init();
 
Signature · 1 line
1.7.0.3
#23 lore raw

PATCH v2 4/4 cocoa: Close sheet after image file selection

In reply to Andreas Färber

If no disk image is specified, the Cocoa frontend displays a modal sheet to let the user select an image file to boot from.

This sheet is never closed and it permanently obscures the emulator window.

Close it after obtaining the file name in case the user did select a file. Otherwise we exit immediately, so no need to close then.

---
 ui/cocoa.m |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
ui/cocoa.m +2 -0
index d9e4e3d..0711205 100644
@@ -811,6 +811,8 @@ QemuCocoaView *cocoaView;
 
         char **argv = (char**)malloc( sizeof(char*)*3 );
 
+        [sheet close];
+
         asprintf(&argv[0], "%s", bin);
         asprintf(&argv[1], "-hda");
         asprintf(&argv[2], "%s", img);
Signature · 1 line
1.7.0.3
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 9 lines · Andreas Färber
fpu/softfloat.h +0 -0
@@ -54,6 +54,9 @@ these four paragraphs for those parts of this code that are retained.

 | to the same as `int'. *----------------------------------------------------------------------------*/ typedef uint8_t flag;

fpu/softfloat.h +3 -0
+#ifdef __APPLE__
+#define uint16 qemu_uint16
+#endif
Quoted 3 lines

 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX

I hate this, but I don't think I quite hate it enough to leave compilation on Macs broken in 1.0...

Ideally we should just make a decision about whether we want option
(1) or (2) from
http://permalink.gmane.org/gmane.comp.emulators.qemu/115848

-- PMM

#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

Am 31.10.2011 20:42, schrieb Peter Maydell:

Quoted 17 lines · Andreas Färber

fpu/softfloat.h these four paragraphs for those parts of this code that are retained. · line 62

Quoted 12 lines
fpu/softfloat.h +3 -0
@@ -54,6 +54,9 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
+#ifdef __APPLE__
+#define uint16 qemu_uint16
+#endif
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX

I hate this, but I don't think I quite hate it enough to leave compilation on Macs broken in 1.0...

Quoted 3 lines

Ideally we should just make a decision about whether we want option
(1) or (2) from
http://permalink.gmane.org/gmane.comp.emulators.qemu/115848

That's what "more general solution" refers to.

At this point in time though I'd much prefer to commit a non-intrusive three-line quickfix (which we can easily remove later on) than no solution at all or than to refactor lots of softfloat code.

Andreas

#5 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 51 lines · Andreas Färber

In file included from ./bswap.h:7,

                from ./qemu-common.h:106,
                from ./qemu-aio.h:17,
                from ./Block.h:4,
                from /System/Library/Frameworks/ 

CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FSEvents.h:28,
from /System/Library/Frameworks/
CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:218,
from /System/Library/Frameworks/
CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
from /System/Library/Frameworks/
CoreServices.framework/Headers/CoreServices.h:21,
from /System/Library/Frameworks/Foundation.framework/
Headers/NSURLError.h:17,
from /System/Library/Frameworks/Foundation.framework/
Headers/Foundation.h:81,
from /System/Library/Frameworks/Cocoa.framework/
Headers/Cocoa.h:12,

                from ui/cocoa.m:25:

/Users/andreas/QEMU/qemu/fpu/softfloat.h:60: error: conflicting types for ‘uint16’ /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:73: error: previous declaration of ‘uint16’ was here
make: *** [ui/cocoa.o] Error 1

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Therefore work around the conflict in softfloat.h itself by renaming specifically uint16 on Darwin to qemu_uint16. This fixes the build until we have a more general solution.

Cc Juan Pineda <[email protected]>
Cc Peter Maydell <[email protected]>

---
fpu/softfloat.h | 3 +++

1 files changed, 3 insertions(+), 0 deletions(-)
fpu/softfloat.h +0 -0
index 07c2929..5320945 100644
@@ -54,6 +54,9 @@ these four paragraphs for those parts of this code  

that are retained.
| to the same as `int'. *----------------------------------------------------------------------------*/ typedef uint8_t flag;

fpu/softfloat.h +3 -0
+#ifdef __APPLE__
+#define uint16 qemu_uint16
+#endif
Quoted 3 lines

typedef uint8_t uint8;
typedef int8_t int8;
#ifndef _AIX

Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition. Additionally, ensure that <Cocoa/Cocoa.h> is included after softfloat.h rather than before since some Cocoa headers expect type uint16 to exist.

---
 ui/cocoa.m |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
ui/cocoa.m +4 -3
index d9e4e3d..ac15418 100644
@@ -22,13 +22,14 @@
  * THE SOFTWARE.
  */
 
-#import <Cocoa/Cocoa.h>
-#include <crt_externs.h>
-
 #include "qemu-common.h"
 #include "console.h"
 #include "sysemu.h"
 
+#define _UINT16
+#import <Cocoa/Cocoa.h>
+#include <crt_externs.h>
+
 #ifndef MAC_OS_X_VERSION_10_4
 #define MAC_OS_X_VERSION_10_4 1040
 #endif
Signature · 1 line
1.7.7.1
#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 6 lines

Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 6 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however softfloat's uint16 is not uint16_t but int, so I'd rather not do it that way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Andreas

#7 lore raw

PATCH v3 2/4 softfloat: Avoid uint16 type conflict on Darwin

On Mac OS X we get:

In file included from ./bswap.h:7,

                 from ./qemu-common.h:106,
                 from ./qemu-aio.h:17,
                 from ./Block.h:4,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FSEvents.h:28,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:218,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
                 from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
                 from /System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:17,
                 from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:81,
                 from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from ui/cocoa.m:25:

/Users/andreas/QEMU/qemu/fpu/softfloat.h:60: error: conflicting types for ‘uint16’ /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:73: error: previous declaration of ‘uint16’ was here
make: *** [ui/cocoa.o] Error 1

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Therefore work around the conflict in softfloat.h itself, by reusing uint16 from Security/cssmconfig.h on Darwin. This fixes the build until we have a more general solution.

Cc Eric Sunshine <[email protected]>
Cc Juan Pineda <[email protected]>
Cc Peter Maydell <[email protected]>
---
 fpu/softfloat.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fpu/softfloat.h +2 -0
index 07c2929..229d834 100644
@@ -57,7 +57,9 @@ typedef uint8_t flag;
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX
+#if !(defined(__APPLE__) && defined(_UINT16))
 typedef int uint16;
+#endif
 typedef int int16;
 #endif
 typedef unsigned int uint32;
Signature · 1 line
1.7.0.3
#8 lore raw

Re: [Qemu-devel] [PATCH v3 2/4] softfloat: Avoid uint16 type conflict on Darwin

Quoted 4 lines · Andreas Färber

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Incidentally, surely you need to fix this anyway (ie fix the include path issue somehow)?

-- PMM

#9 lore raw

Re: [Qemu-devel] [PATCH v3 2/4] softfloat: Avoid uint16 type conflict on Darwin

Am 01.11.2011 19:01, schrieb Peter Maydell:

Quoted 8 lines · Andreas Färber
Quoted 4 lines

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Incidentally, surely you need to fix this anyway (ie fix the include path issue somehow)?

Yes, that's why I'm explicitly documenting it. I have no clue how to fix it though. Experts' opinion welcome!

Andreas

#12 lore raw

Re: [Qemu-devel] [PATCH v3 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber

Am 01.11.2011 18:59, schrieb Andreas Färber:

Quoted 23 lines

On Mac OS X we get:

In file included from ./bswap.h:7,

                 from ./qemu-common.h:106,
                 from ./qemu-aio.h:17,
                 from ./Block.h:4,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/FSEvents.h:28,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:218,
                 from /System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20,
                 from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:21,
                 from /System/Library/Frameworks/Foundation.framework/Headers/NSURLError.h:17,
                 from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:81,
                 from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from ui/cocoa.m:25:

/Users/andreas/QEMU/qemu/fpu/softfloat.h:60: error: conflicting types for ‘uint16’ /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:73: error: previous declaration of ‘uint16’ was here
make: *** [ui/cocoa.o] Error 1

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Quoted 8 lines

Therefore work around the conflict in softfloat.h itself, by reusing uint16 from Security/cssmconfig.h on Darwin. This fixes the build until we have a more general solution.

Cc Eric Sunshine <[email protected]>
Cc Juan Pineda <[email protected]>
Cc Peter Maydell <[email protected]>

v3 series is available from
git://repo.or.cz/qemu/afaerber.git cocoa-for-upstream

If no further protest arises, I'll send a pull request later today.

Andreas

Quoted 18 lines
---
 fpu/softfloat.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fpu/softfloat.h +2 -0
index 07c2929..229d834 100644
@@ -57,7 +57,9 @@ typedef uint8_t flag;
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX
+#if !(defined(__APPLE__) && defined(_UINT16))
 typedef int uint16;
+#endif
 typedef int int16;
 #endif
 typedef unsigned int uint32;
#13 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 18 lines · Andreas Färber

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 6 lines

Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 6 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however softfloat's uint16 is not uint16_t but int, so I'd rather not do it that way around.

Quoted 7 lines

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

-- ES

#14 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

Am 01.11.2011 19:47, schrieb Eric Sunshine:

Quoted 24 lines · Andreas Färber
Quoted 23 lines

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 7 lines

Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 6 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however softfloat's uint16 is not uint16_t but int, so I'd rather not do it that way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Quoted 8 lines
Quoted 3 lines

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

Short-term goal: make Darwin build 1.0 without breaking others Long-term goal: not use uint16 etc. in QEMU at all

Don't see what you mean with "taking as many type definitions". After uint16 I get no further conflicts for --enable-system --disable-user, so what is there to take?

Andreas

#10 lore raw

Re: [Qemu-devel] [PATCH v3 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

Am 01.11.2011 19:01, schrieb Peter Maydell:

Quoted 6 lines · Andreas Färber
Quoted 4 lines

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Quoted 5 lines
Quoted 2 lines

Incidentally, surely you need to fix this anyway (ie fix the include path issue somehow)?

Yes, that's why I'm explicitly documenting it. I have no clue how to fix it though. Experts' opinion welcome!

It probably is not a good idea to emphasize the particular #include stack issued by this one build environment (presumably XCode on Lion?) so loudly in the commit message. The type redefinition error will manifest regardless of #include ordering and regardless of whether or not ./block.h is picked up accidentally instead of <Block.h>. For instance, on Leopard with XCode 3.1.4, the #include stack emitted with the error message is entirely different even though the underlying issue is the same:

OBJC ui/cocoa.o
In file included from ./bswap.h:8,

                 from ./qemu-common.h:107,
                 from ui/cocoa.m:29:

/Users/sunshine/Desktop/qemu/fpu/softfloat.h:60: error: conflicting types for 'uint16' /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:68: error: previous declaration of 'uint16' was here
make: *** [ui/cocoa.o] Error 1

In fact, on Leopard, FSEvents.h does not #include <Block.h>, so focusing on it in the log message is misleading.

-- ES

#15 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 34 lines · Andreas Färber

Am 01.11.2011 19:47, schrieb Eric Sunshine:

Quoted 24 lines · Andreas Färber
Quoted 23 lines

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 7 lines

Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 6 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however softfloat's uint16 is not uint16_t but int, so I'd rather not do it that way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Quoted 8 lines
Quoted 3 lines

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

Quoted 6 lines

Short-term goal: make Darwin build 1.0 without breaking others Long-term goal: not use uint16 etc. in QEMU at all

Don't see what you mean with "taking as many type definitions". After uint16 I get no further conflicts for --enable-system --disable-user, so what is there to take?

Sorry for not being clear. My question was not about build errors but about semantics. What I meant was that, with this patch, you are giving special preference only to Darwin's definition of uint16, but then contrarily preferring softfloat's definition of int16. Likewise, softfloat's uint32, int32, uint64, int64 from softfloat are trusted over the definitions from Darwin.

Other than the fact that only uint16 led to a compilation error, it does not make sense semantically to single out Darwin's definition of only this one type. I would think that we should be trusting either _all_ Darwin type definitions or _none_. Singling out just this one seems anomalous.

-- ES

#11 lore raw

Re: [Qemu-devel] [PATCH v3 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Eric Sunshine

Am 01.11.2011 19:55, schrieb Eric Sunshine:

Quoted 28 lines · Andreas Färber
Quoted 7 lines

Am 01.11.2011 19:01, schrieb Peter Maydell:

Quoted 6 lines · Andreas Färber
Quoted 4 lines

Apple's FSEvents.h has #include <Block.h>, which wants /usr/include/Block.h but due to case-insensitive file system and include path jungle gets QEMU's ./block.h, which in turn includes softfloat.h indirectly.

Quoted 5 lines
Quoted 2 lines

Incidentally, surely you need to fix this anyway (ie fix the include path issue somehow)?

Yes, that's why I'm explicitly documenting it. I have no clue how to fix it though. Experts' opinion welcome!

It probably is not a good idea to emphasize the particular #include stack issued by this one build environment (presumably XCode on Lion?) so loudly in the commit message. The type redefinition error will manifest regardless of #include ordering and regardless of whether or not ./block.h is picked up accidentally instead of <Block.h>. For instance, on Leopard with XCode 3.1.4, the #include stack emitted with the error message is entirely different even though the underlying issue is the same:

OBJC ui/cocoa.o
In file included from ./bswap.h:8,

                 from ./qemu-common.h:107,
                 from ui/cocoa.m:29:
Quoted 8 lines

/Users/sunshine/Desktop/qemu/fpu/softfloat.h:60: error: conflicting types for 'uint16' /System/Library/Frameworks/Security.framework/Headers/cssmconfig.h:68:
error: previous declaration of 'uint16' was here
make: *** [ui/cocoa.o] Error 1

In fact, on Leopard, FSEvents.h does not #include <Block.h>, so focusing on it in the log message is misleading.

My point is, that's the reason it needs to be fixed *this* way and not in cocoa.m like you'd expect. If it doesn't show up in git-blame, people will not understand and "clean up". It's always just an example since it includes user-specific paths - here Snow Leopard. Rewording.

AF

#16 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Eric Sunshine
Quoted 43 lines · Eric Sunshine
Quoted 34 lines · Andreas Färber

Am 01.11.2011 19:47, schrieb Eric Sunshine:

Quoted 24 lines · Andreas Färber
Quoted 23 lines

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 7 lines

Perhaps the following alternative solution would be more palatable? It's still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 6 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>. cssmconfig.h defines type uint16 which unfortunately conflicts with the definition in qemu's softfloat.h, thus resulting in compilation failure. To work around the problem, #define _UINT16, which informs cssmconfig.h that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however softfloat's uint16 is not uint16_t but int, so I'd rather not do it that way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Quoted 8 lines
Quoted 3 lines

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

Quoted 6 lines

Short-term goal: make Darwin build 1.0 without breaking others Long-term goal: not use uint16 etc. in QEMU at all

Don't see what you mean with "taking as many type definitions". After uint16 I get no further conflicts for --enable-system --disable-user, so what is there to take?

Quoted 5 lines

Sorry for not being clear. My question was not about build errors but about semantics. What I meant was that, with this patch, you are giving special preference only to Darwin's definition of uint16, but then contrarily preferring softfloat's definition of int16. Likewise, softfloat's uint32, int32, uint64, int64 from softfloat are trusted over the definitions from Darwin.

Other than the fact that only uint16 led to a compilation error, it does not make sense semantically to single out Darwin's definition of only this one type. I would think that we should be trusting either _all_ Darwin type definitions or _none_. Singling out just this one seems anomalous.

-- ES

I forgot to mention that with your patch, only cocoa.m is seeing Darwin's definition of uint16. The rest of qemu is seeing the definition from softfloat.h. This inconsistency hopefully is not harmful in the short-term, which is why I asked about the goal. If the short-term idea is for cocoa.m to build cleanly but not to worry much that cocoa.m sees a different uint16 from the rest of qemu, then the less intrusive patch involving only cocoa.m may be preferable.

-- ES

#18 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Eric Sunshine

Am 01.11.2011 20:06, schrieb Eric Sunshine:

Quoted 58 lines · Andreas Färber
Quoted 42 lines

Am 01.11.2011 19:47, schrieb Eric Sunshine:

Quoted 31 lines · Andreas Färber
Quoted 30 lines

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 8 lines

Perhaps the following alternative solution would be more palatable? It's
still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 10 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>.
cssmconfig.h defines type uint16 which unfortunately conflicts with the
definition in qemu's softfloat.h, thus resulting in compilation failure.
To work around the problem, #define _UINT16, which informs cssmconfig.h
that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however
softfloat's uint16 is not uint16_t but int, so I'd rather not do it that
way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Quoted 8 lines
Quoted 3 lines

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

Quoted 6 lines

Short-term goal: make Darwin build 1.0 without breaking others Long-term goal: not use uint16 etc. in QEMU at all

Don't see what you mean with "taking as many type definitions". After uint16 I get no further conflicts for --enable-system --disable-user, so what is there to take?

Sorry for not being clear. My question was not about build errors but about semantics. What I meant was that, with this patch, you are giving special preference only to Darwin's definition of uint16, but then contrarily preferring softfloat's definition of int16. Likewise, softfloat's uint32, int32, uint64, int64 from softfloat are trusted over the definitions from Darwin.

Quoted 5 lines

Other than the fact that only uint16 led to a compilation error, it does not make sense semantically to single out Darwin's definition of only this one type. I would think that we should be trusting either _all_ Darwin type definitions or _none_. Singling out just this one seems anomalous.

Listen, I dont have time for this. We have three options:

1) I can say, "I'm the Cocoa maintainer for multiple years now, I don't care if someone pops up day before the deadline and complains" and just push my version of preference.

2) We disagree on the solution, so I'm fair and send a pull request for the three other non-controversial patches only and 1.0 remains broken on Darwin.

3) You send a patch based on this one, detailing what additional changes you suggest and we'll see clearer what exactly you mean.

I'm not preferring any definition of int16, uint32, etc., there simply is no conflict, so why would I clutter softfloat.h with unnecessary workarounds that we want to go away anyway.

Feel free to refactor fpu/* instead to not use uint16 in the first place. I did so once and it was rejected, so I'm not too inclined to do that again unless we decide on how exactly to proceed with that!

Andreas

#17 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Eric Sunshine

Am 01.11.2011 20:25, schrieb Eric Sunshine:

Quoted 7 lines

I forgot to mention that with your patch, only cocoa.m is seeing Darwin's definition of uint16. The rest of qemu is seeing the definition from softfloat.h. This inconsistency hopefully is not harmful in the short-term, which is why I asked about the goal. If the short-term idea is for cocoa.m to build cleanly but not to worry much that cocoa.m sees a different uint16 from the rest of qemu, then the less intrusive patch involving only cocoa.m may be preferable.

Ouch. Meaning both our softfloat patches are wrong, so I'll go with (2). It's evening in Italy and the last day for submaintainer PULLs.

AF

#19 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 3 lines · Andreas Färber

Feel free to refactor fpu/* instead to not use uint16 in the first place. I did so once and it was rejected, so I'm not too inclined to do that again unless we decide on how exactly to proceed with that!

I think we could probably resolve that with a little bit of benchmarking about whether it really makes any difference whether we use an int16_t or an int32_t for the variables where softfloat has int16 currently; but benchmarking is tedious so I've never got round to it :-)

-- PMM

#20 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

In reply to Andreas Färber
Quoted 65 lines · Andreas Färber

Am 01.11.2011 20:06, schrieb Eric Sunshine:

Quoted 58 lines · Andreas Färber
Quoted 42 lines

Am 01.11.2011 19:47, schrieb Eric Sunshine:

Quoted 31 lines · Andreas Färber
Quoted 30 lines

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 8 lines

Perhaps the following alternative solution would be more palatable? It's
still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 10 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>.
cssmconfig.h defines type uint16 which unfortunately conflicts with the
definition in qemu's softfloat.h, thus resulting in compilation failure.
To work around the problem, #define _UINT16, which informs cssmconfig.h
that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however
softfloat's uint16 is not uint16_t but int, so I'd rather not do it that
way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa code.)

Quoted 8 lines
Quoted 3 lines

Do you have any thoughts about the include path issue? If we could keep QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

Quoted 6 lines

Short-term goal: make Darwin build 1.0 without breaking others Long-term goal: not use uint16 etc. in QEMU at all

Don't see what you mean with "taking as many type definitions". After uint16 I get no further conflicts for --enable-system --disable-user, so what is there to take?

Sorry for not being clear. My question was not about build errors but about semantics. What I meant was that, with this patch, you are giving special preference only to Darwin's definition of uint16, but then contrarily preferring softfloat's definition of int16. Likewise, softfloat's uint32, int32, uint64, int64 from softfloat are trusted over the definitions from Darwin.

Quoted 5 lines

Other than the fact that only uint16 led to a compilation error, it does not make sense semantically to single out Darwin's definition of only this one type. I would think that we should be trusting either _all_ Darwin type definitions or _none_. Singling out just this one seems anomalous.

Quoted 5 lines

Listen, I dont have time for this. We have three options:

1) I can say, "I'm the Cocoa maintainer for multiple years now, I don't care if someone pops up day before the deadline and complains" and just push my version of preference.

I hope that you do not interpret my alternate patch as a "complaint before the deadline". My intention only was to be helpful when I saw Peter's response [1], and thought that a less intrusive patch might be more acceptable.

[1]: http://lists.nongnu.org/archive/html/qemu-devel/2011-10/msg03936.html

-- ES

#21 lore raw

Re: [Qemu-devel] [PATCH v2 2/4] softfloat: Avoid uint16 type conflict on Darwin

Am 01.11.2011 20:45, schrieb Eric Sunshine:

Quoted 69 lines · Andreas Färber
Quoted 68 lines

Am 01.11.2011 20:06, schrieb Eric Sunshine:

Quoted 66 lines · Andreas Färber
Quoted 45 lines

Am 01.11.2011 19:47, schrieb Eric Sunshine:

Quoted 37 lines · Andreas Färber
Quoted 31 lines

Am 01.11.2011 09:09, schrieb Eric Sunshine:

Quoted 8 lines

Perhaps the following alternative solution would be more palatable? It's
still tremendously ugly, but is localized to cocoa.m, thus less intrusive.

-- >8 --
Subject: [PATCH] softfloat: Avoid uint16 type conflict on Darwin

Quoted 10 lines

cocoa.m includes <Security/cssmconfig.h> indirectly via <Cocoa/Cocoa.h>.
cssmconfig.h defines type uint16 which unfortunately conflicts with the
definition in qemu's softfloat.h, thus resulting in compilation failure.
To work around the problem, #define _UINT16, which informs cssmconfig.h
that uint16 is already defined and that it should not apply its own definition.

Thanks for the suggestion! _UINT16 is an interesting suggestion, however
softfloat's uint16 is not uint16_t but int, so I'd rather not do it that
way around.

(I had also decided against the AIX path of never defining uint16 and always using system definitions, since that wouldn't work outside Cocoa
code.)

Quoted 4 lines

Do you have any thoughts about the include path issue? If we could keep
QEMU code from getting into #import <Cocoa/Cocoa.h> then we could redefine the system type instead, in cocoa.m.

Quoted 5 lines

Is the intention to trust uint16 from <Security/cssmconfig.h> over the one softfloat.h? If so, shouldn't we be taking as many type definitions
from <Security/cssmconfig.h> as we can rather than just this one? (I'm not recommending it; just trying to understand the goal.)

Quoted 6 lines

Short-term goal: make Darwin build 1.0 without breaking others Long-term goal: not use uint16 etc. in QEMU at all

Don't see what you mean with "taking as many type definitions". After uint16 I get no further conflicts for --enable-system --disable-user, so what is there to take?

Sorry for not being clear. My question was not about build errors but about semantics. What I meant was that, with this patch, you are giving special preference only to Darwin's definition of uint16, but then contrarily preferring softfloat's definition of int16. Likewise, softfloat's uint32, int32, uint64, int64 from softfloat are trusted over the definitions from Darwin.

Other than the fact that only uint16 led to a compilation error, it does not make sense semantically to single out Darwin's definition of only this one type. I would think that we should be trusting either _all_ Darwin type definitions or _none_. Singling out just this one seems anomalous.

Quoted 8 lines
Quoted 5 lines

Listen, I dont have time for this. We have three options:

1) I can say, "I'm the Cocoa maintainer for multiple years now, I don't care if someone pops up day before the deadline and complains" and just push my version of preference.

I hope that you do not interpret my alternate patch as a "complaint before the deadline".

Not your patch, I thanked you for it, but the seemingly nonconstructive complaints about my follow-up. I would've much preferred code. :/

Quoted 5 lines

My intention only was to be helpful when I saw
Peter's response [1], and thought that a less intrusive patch might be more acceptable.

[1]: http://lists.nongnu.org/archive/html/qemu-devel/2011-10/msg03936.html

Then it's not the intention we differ in, I had tried some solutions inside ui/cocoa.m myself before.

Apart from non-intrusiveness further criteria are reversibility of the short-term fix[1] and ABI safety.

I'll happily review new patches from tomorrow on.

Regards,
Andreas

[1] We have similar lurking issues with [u]int* on Haiku/BeOS.