From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KYPc1-0005wl-5y for qemu-devel@nongnu.org; Wed, 27 Aug 2008 14:19:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KYPc0-0005vr-F0 for qemu-devel@nongnu.org; Wed, 27 Aug 2008 14:19:20 -0400 Received: from [199.232.76.173] (port=37697 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYPc0-0005vi-AG for qemu-devel@nongnu.org; Wed, 27 Aug 2008 14:19:20 -0400 Received: from mail2.shareable.org ([80.68.89.115]:33924) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KYPc0-00048M-1v for qemu-devel@nongnu.org; Wed, 27 Aug 2008 14:19:20 -0400 Date: Wed, 27 Aug 2008 19:19:14 +0100 From: Jamie Lokier Subject: Re: [Qemu-devel] [patch] add byteordered types Message-ID: <20080827181914.GC27491@shareable.org> References: <48B53E23.5040107@redhat.com> <200808271456.57273.paul@codesourcery.com> <48B56645.60206@redhat.com> <20080827.084738.-674761106.imp@bsdimp.com> <48B56D8D.7050002@redhat.com> <48B5778E.8000709@codemonkey.ws> <48B57EB9.2050106@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48B57EB9.2050106@redhat.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paul Brook Gerd Hoffmann wrote: > Anthony Liguori wrote: > > Personally, I dislike the whole struct thing. I even further dislike > > having multiple sets of conversion functions that are used in different > > places in the code. > > > > Are we sure that this is something that we want to do? > > As far I know this struct trick is the only way to have gcc check access > to variables with an specific byteorder is done the correct way. Avi > sguuested that and I also think this checking would be useful. I could > live without that though if there is an agreement that we'll just stick > with the current, unchecked cpu_to_ functions. Provided you always use the type, and want access only via the macros, the fact its a struct is pretty much invisible, and modern compilers optimise them quite well like integers. I'm not sure if a "long enum le32 { max = LONG_MAX, min = LONG_MIN }" can be used instead of a struct (same for other "short enum" etc.), to get some warnings instead of errors, and allow bitwise operations. Changing in steps would work: 1. Change all QEMU source to use the new type names (as integers), while continuing to use the cpu_to_XY and XY_to_cpu functions. Doesn't have to be all at once. It's probably not that much work to change all the mainline source, as you can use the type-safe version to catch all places that need changing :-) Let it settle for a while, until contributors start using the new type names in patches. 2. _Then_ change those types to structs and make the functions type-safe. A small patch. 3. Fix the few that got missed. That's less invasive than changing the function names everywhere. -- Jamie