WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [patch] pagetable cleanups

To: Mark Williamson <maw48@xxxxxxxxxxxx>
Subject: Re: [Xen-devel] [patch] pagetable cleanups
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Thu, 14 Apr 2005 13:27:33 -0500
Cc: Michael A Fetterman <Michael.Fetterman@xxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, Gerd Knorr <kraxel@xxxxxxxxxxx>
Delivery-date: Thu, 14 Apr 2005 18:29:49 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <200504141548.12400.maw48@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM Linux Technology Center
References: <20050412185856.GA5832@bytesex> <E1DM3Pa-0002e4-00@xxxxxxxxxxxxxxxxx> <20050414150150.GA28071@bytesex> <200504141548.12400.maw48@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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