Patchwork [v2,2/3] Cocoa: ppc64 host support

login
register
mail settings
Submitter Andreas Färber
Date Dec. 6, 2009, 1 p.m.
Message ID <1260104426-725-2-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/40420/
State New
Headers show

Comments

Andreas Färber - Dec. 6, 2009, 1 p.m.
Fix integer usage in the Cocoa backend: NSInteger is long on LP64.

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/doc/uid/20000014-BBCFHHCD

This makes the graphical display show up on a ppc64 host.

Signed-off-by: Andreas Faerber <andreas.faerber@web.de>
Cc: Alexander Graf <alex@csgraf.de>
Cc: Mike Kronenberg <mike.kronenberg@kronenberg.org>
---
 cocoa.m |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Alexander Graf - Dec. 6, 2009, 1:02 p.m.
On 06.12.2009, at 14:00, Andreas Faerber wrote:

> Fix integer usage in the Cocoa backend: NSInteger is long on LP64.
> 
> http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/doc/uid/20000014-BBCFHHCD
> 
> This makes the graphical display show up on a ppc64 host.

Interesting! Unfortunately I don't have a PPC64 Apple machine handy, so I can't test it.

Alex
Andreas Färber - Dec. 6, 2009, 1:23 p.m.
Hi Alex,

Am 06.12.2009 um 14:02 schrieb Alexander Graf:

>
> On 06.12.2009, at 14:00, Andreas Faerber wrote:
>
>> Fix integer usage in the Cocoa backend: NSInteger is long on LP64.
>>
>> http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#/ 
>> /apple_ref/doc/uid/20000014-BBCFHHCD
>>
>> This makes the graphical display show up on a ppc64 host.
>
> Interesting! Unfortunately I don't have a PPC64 Apple machine handy,  
> so I can't test it.

I cc'ed you so that you could check your earlier x86_64 Mac patch  
series, if you care. I don't have an x86_64 Mac at hands myself.

Btw I'll be looking into bringing the Cocoa frontend on par with SDL,  
namely closing the app when closing the window and not creating the  
window in -nographic mode. That's awful when debugging!

Andreas
Alexander Graf - Dec. 6, 2009, 1:32 p.m.
On 06.12.2009, at 14:23, Andreas Färber wrote:

> Hi Alex,
> 
> Am 06.12.2009 um 14:02 schrieb Alexander Graf:
> 
>> 
>> On 06.12.2009, at 14:00, Andreas Faerber wrote:
>> 
>>> Fix integer usage in the Cocoa backend: NSInteger is long on LP64.
>>> 
>>> http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/doc/uid/20000014-BBCFHHCD
>>> 
>>> This makes the graphical display show up on a ppc64 host.
>> 
>> Interesting! Unfortunately I don't have a PPC64 Apple machine handy, so I can't test it.
> 
> I cc'ed you so that you could check your earlier x86_64 Mac patch series, if you care. I don't have an x86_64 Mac at hands myself.

Oh I see, I'll test it later today or tomorrow.

> Btw I'll be looking into bringing the Cocoa frontend on par with SDL, namely closing the app when closing the window and not creating the window in -nographic mode. That's awful when debugging!

I agree. I did a patch for that once - might be worth searching the ML for that. Basically it searched the args for a "-nographic" parameter. Pretty hacky, but at least it worked.

Alex
Mike Kronenberg - Dec. 6, 2009, 1:41 p.m.
On 06.12.2009, at 14:00, Andreas Faerber wrote:

> -            int rectCount;
> +            NSInteger rectCount;

I know that this is endorsed by apple since 10.5 but NSInteger will break compiling on Tiger and older. Int on the other hand is only throwing a warning on Leopard if I'm not mistaken.

Especially with qemu, one has to have an eye on the type... NSInteger can be an int or a long, depending on the host...

#if __LP64__ || NS_BUILD_32_LIKE_64
	typedef long NSInteger;
	typedef unsigned long NSUInteger;
#else
	typedef int NSInteger;
	typedef unsigned int NSUInteger;
#endif

I have no G5 at hand to test either.

Mike
Andreas Färber - Dec. 6, 2009, 2:09 p.m.
Am 06.12.2009 um 14:41 schrieb Mike Kronenberg:

> On 06.12.2009, at 14:00, Andreas Faerber wrote:
>
>> -            int rectCount;
>> +            NSInteger rectCount;
>
> I know that this is endorsed by apple since 10.5 but NSInteger will  
> break compiling on Tiger and older.

You appear to be right there... no trace of it in 10.4u SDK.

> Int on the other hand is only throwing a warning on Leopard if I'm  
> not mistaken.

On Leopard ppc it just warns and works because NSInteger == int.
On Leopard ppc64 it warns and fails at runtime because NSInteger != int.

> Especially with qemu, one has to have an eye on the type...  
> NSInteger can be an int or a long, depending on the host...
>
> #if __LP64__ || NS_BUILD_32_LIKE_64
> 	typedef long NSInteger;
> 	typedef unsigned long NSUInteger;
> #else
> 	typedef int NSInteger;
> 	typedef unsigned int NSUInteger;
> #endif

Right, so we do need NSInteger - I'll add a version check. Thanks for  
the feedback!

Andreas

Patch

diff --git a/cocoa.m b/cocoa.m
index 55ff2b4..7062571 100644
--- a/cocoa.m
+++ b/cocoa.m
@@ -337,7 +337,7 @@  int cocoa_keycode_to_qemu(int keycode)
         } else {
             // selective drawing code (draws only dirty rectangles) (OS X >= 10.4)
             const NSRect *rectList;
-            int rectCount;
+            NSInteger rectCount;
             int i;
             CGImageRef clipImageRef;
             CGRect clipRect;