- Inside Macintosh: Mac OS Runtime Architectures /
- Chapter 4 - PowerPC Runtime Conventions / Routine Calling Conventions
Function Return
In the PowerPC runtime environment, floating-point function values are returned in register FPR1 (or FPR1 and FPR2 for long double values). Other values are returned in GPR3 as follows:
- Functions returning simple values smaller than 4 bytes (such as type
SInt8, Boolean, or SInt16) place the return value in the least significant byte or bytes of GPR3. The most significant bytes in GPR3 are undefined.
- Functions returning 4-byte values (such as pointers, including array pointers, or types
SInt32 and UInt32) return them normally in GPR3.
- If a function returns a composite value (for example, a
struct or union data type) or a value larger than 4 bytes, a pointer must be passed as an implicit left-most parameter before passing all the user-visible arguments (that is, the address is passed in GPR3, and the actual parameters begin with GPR4). The address of the pointer must be a memory location large enough to hold the function return value. Since GPR3 is treated as a parameter in this case, its value is not guaranteed on return.
© Apple Computer, Inc.
11 MARCH 1997