• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Which flavor of objc_msgSend for NSSize return
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which flavor of objc_msgSend for NSSize return


  • Subject: Re: Which flavor of objc_msgSend for NSSize return
  • From: glenn andreas <email@hidden>
  • Date: Fri, 11 May 2007 15:26:49 -0500


On May 11, 2007, at 3:00 PM, Rosyna wrote:

I actually just ended up doing what people kept telling me to do. Compile some objective-c code that calls the function, disassemble, and see what gcc does.

GCC calls objc_msgSend() on i386 if the type is NSRange or NSSize. Using stret for these is declared as bad/wrong by some people since the handling is very different on i386 for structs <=8 bytes. (But golly, I can't remember where I saw an official document on what small meant).

But either way, I'd like to see an official document dealie describing which to use in which case. I would hate to be depending on an implementation detail. Especially when the entire point of this particular piece of code is to make sure I can adapt if the implementation changes.

From <http://developer.apple.com/documentation/DeveloperTools/ Conceptual/LowLevelABI/Articles/IA32.html#//apple_ref/doc/uid/ TP40002492-SW5> (with added labeling):


Returning Results

This is how functions pass results to their callers:

1) The called function places integral or pointer results in EAX.
2) The called function places floating-point results in ST0. The caller removes the value from this register, even when it doesn’t use the value.
3) The called function returns structures according to their aligned size:
3a) Structures 1 or 2 bytes in size are placed in EAX.
3b) Structures 4 or 8 bytes in size are placed in: EAX and EDX.
3c) Structures or other sizes are placed at the address supplied by the caller. See “Passing Arguments” for more information.
4) The called function places vectors at the address supplied by the caller.



So my understanding is that anything that would be returned in registers (1, 3a, 3b) are objc_msgSend, something returning a float (2) is _fpret, and that leaves 3c (returning a struct via an address supplied by the caller) corresponding to _stret







Glenn Andreas email@hidden <http://www.gandreas.com/> wicked fun! Cardographer | the custom playing card designer


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Which flavor of objc_msgSend for NSSize return (From: Rosyna <email@hidden>)
 >Re: Which flavor of objc_msgSend for NSSize return (From: Sherm Pendley <email@hidden>)
 >Re: Which flavor of objc_msgSend for NSSize return (From: Rosyna <email@hidden>)

  • Prev by Date: Re: Which flavor of objc_msgSend for NSSize return
  • Next by Date: RE: Get the Mac address programmatically
  • Previous by thread: Re: Which flavor of objc_msgSend for NSSize return
  • Next by thread: Re: Which flavor of objc_msgSend for NSSize return
  • Index(es):
    • Date
    • Thread