From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] Use QEMU functions to access guest memory for virtio Date: Sat, 29 Mar 2008 16:49:30 -0500 Message-ID: <47EEB96A.40703@codemonkey.ws> References: <1206481168-7185-1-git-send-email-aliguori@us.ibm.com> <47EA4F2D.5050703@qumranet.com> <47EA5C6F.6060201@us.ibm.com> <47EA5E92.5080004@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel@lists.sf.net, Aurelien Jarno To: Avi Kivity Return-path: In-Reply-To: <47EA5E92.5080004@qumranet.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Avi Kivity wrote: > Anthony Liguori wrote: > >>> #define s_ld_u64(phys, field, type) \ >>> ldq_phys(phys + offsetof(field, type)) >>> >>> >>> And now we don't need individual accessors, or to encode the offsets >>> as magic numbers. >>> >> It's a nice thought but it doesn't work out in practice because most >> of these accessor functions are accessing array elements. However, I >> thought about using offsetof() to eliminate the magic constants and I >> don't think that's a bad idea. In the very least, it makes the code >> more readable. It'll be part of the next series. >> >> > > offsetof() should work for array members (i.e. offsetof(struct s, a[8])). > I converted everything to use offsetof but left the accessors. You need a fair number of macros to handle the various data sizes and even then, I think it ends up looking nicer with the macros. See my patch series on qemu-devel and let me know if you agree/disagree. Regards, Anthony Liguori ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace