discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSInvocation return value location


From: David Chisnall
Subject: Re: NSInvocation return value location
Date: Mon, 1 Dec 2008 15:54:19 +0000

I've looked at GSFFCallInvocation and I can't work out why changing the value of _retval does not alter where it stores the return value. av_start_ptr appears to be called with _retval as the argument, but the result is written both to the location specified there and on the original stack location.

Any hints?

David

On 30 Nov 2008, at 02:36, David Chisnall wrote:

Hi,

I have some code which transfers an NSInvocation to another thread to execute. Before doing this, it sets the return value to a proxy. I now have the problem on GNUstep that when I fire the invocation in the second thread that it writes the result to the stack on the original thread.

OS X does something with NSInvocations that deals with the special case that the function constructing the NSInvocation returns before the NSInvocation is fired by having the function that calls forwardInvocation: block until the invocation has fired once and then, when the function returns, setting the invocation to store its result internally in a buffer that can be accessed with getReturnValue:.

With GNUstep it is possible to emulate this behaviour using libffi but not ffcall. The _storeRetval method on NSInvocation appears to work correctly with FFI, ensuring that the return value is stored in the invocation. With ffcall, this method is not implemented, and setting _retval manually results in the return value being stored in both the specified location and in the original location.

David


_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep





reply via email to

[Prev in Thread] Current Thread [Next in Thread]