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

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



On Thu, 2005-04-14 at 13:27, Hollis Blanchard wrote:
> So no memcpys at all; the caller fills in the values directly into the
> callee's struct.

Unless you're dealing with struct assignments.  You basically get a
memcpy() when you assign structs.  The standard makes it pretty clear
that the returning a struct is not an lvalue (it's a copy).  Unoptimized
C will have an inlined memcpy() because of the assignment.  Otherwise,
the following:

foo(b, c).a = 3;

Would be valid and this is expressly forbidden by the standard (see
section 6.5.2.3).

A smart compiler will propagate the copy but it has it's limitations. 
Once you have sufficiently complex pointer operations in a function
there's no guarantee copies will be propagated correctly.

Because you cannot rely on the optimization, structs are not typically
returned by value.  Since this is so rarely done, I'd argue it's more
readable to pass a struct as an argument (the fact that some people
don't even realize it's possible should support that). 

Regards,

-- 
Anthony Liguori
Linux Technology Center (LTC) - IBM Austin
E-mail: aliguori@xxxxxxxxxx
Phone: (512) 838-1208



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.