|
|
|
|
|
|
|
|
|
|
xen-devel
Re: [Xen-devel] [patch] pagetable cleanups
On Thu, 2005-04-14 at 15:48 +0100, Mark Williamson wrote:
> > Yes, was intentionally. I think that isn't bad, it makes the code more
> > readable. And I think it actually is impossible to return structs in C,
> > you can only return a pointer to a struct, which would't help for the
> > "building entries as expressions" case.
>
> Returning structs by values works with GCC. That said, I've never checked
> whether that's standard or a GCC extension. For big structs I think it
> transparently generates a memcpy, don't know what it generates for little
> ones.
Depends on the ABI.
For ppc64 Linux:
Aggregates or unions of any length, and character strings of
length longer than 8 bytes, will be returned in a storage buffer
allocated by the caller. The caller will pass the address of
this buffer as a hidden first argument in r3, causing the first
explicit argument to be passed in r4.
For ppc32 (System V R4 ABI) it's a little different for small
structures:
A structure or union whose size is less than or equal to 8 bytes
shall be returned in r3 and r4, as if it were first stored in an
8-byte aligned memory area and then the low-addressed word were
loaded into r3 and the high-addressed word into r4.
Values of type long double and structures or unions that do not
meet the requirements for being returned in registers are
returned in a storage buffer allocated by the caller. The
address of this buffer is passed as a hidden argument in r3 as
if it were the first argument, causing gr in the argument
passing algorithm above to be initialized to 4 instead of 3.
x86 (again from SVR4):
If a function returns a structure or union, then the caller
provides space for the return value and places its address on
the stack as argument word zero. In effect, this address becomes
a ``hidden'' first argument.
So no memcpys at all; the caller fills in the values directly into the
callee's struct.
--
Hollis Blanchard
IBM Linux Technology Center
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|
|
|