Re: Returning values from objc_msgSend etc
Re: Returning values from objc_msgSend etc
- Subject: Re: Returning values from objc_msgSend etc
- From: "Duncan McGregor" <email@hidden>
- Date: Mon, 3 Mar 2008 10:52:34 +0000
Thanks for all the help on this.
Rococoa uses JNA, which in turns uses libffi, so I'm also spared most
of the heavy lifting, but like Sherm, I do have to make all the
decisions at runtime. Greg's post is the most definitive thing I've
seen on the subject - thank you.
>> * Should I call objc_msgSend_stret when returning longs on PPC?
> No. On ppc, longs are 32-bit and returned in a single register. 64-bit integers are returned in two registers. Both cases use objc_msgSend.
Ah, I had meant Java long, and therefore 64 bits. That is interesting,
as I have a failing unit test for returning Java long using
objc_msgSend on PPC, which I would have expected libffi to just make
work for me. Looks like I'll have to repossess the old PowerBook from
my eldest son.
> Both PyObjC and RubyCocoa (and F-Script Anywhere, for that matter), use FFI to call objc_msgSend(). Both have extensive unit tests and, thus, the logic seems to be correct.
I had gone looking in the source for RubyCocoa, but not hard enough! I
have a similar unit test policy, but the rule seems to be, if the
tests all pass, I don't have enough of them, or I'm not testing on
enough platforms.
> I can simply check the calculated size after calling ffi_prep_cif(), and compare that to sizeof(void*) to see if the return value will fit in a register.
Is that right? 8 byte structs are returned in EAX and EDX on IA-32, so
I'd expect to call objc_msgSend.
Thanks again
Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden