From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6EDj-0001HV-QN for qemu-devel@nongnu.org; Tue, 08 Dec 2015 04:06:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6EDi-0006ww-BD for qemu-devel@nongnu.org; Tue, 08 Dec 2015 04:06:03 -0500 Date: Tue, 8 Dec 2015 15:54:24 +1100 From: David Gibson Message-ID: <20151208045424.GP20139@voom.fritz.box> References: <1449546921-6378-1-git-send-email-eblake@redhat.com> <1449546921-6378-32-git-send-email-eblake@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PdAWLd+WEPmMbsbx" Content-Disposition: inline In-Reply-To: <1449546921-6378-32-git-send-email-eblake@redhat.com> Subject: Re: [Qemu-devel] [PATCH v7 31/31] RFC: qapi: Adjust layout of FooList types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Michael Roth , Alexander Graf , "open list:sPAPR (pseries)" , qemu-devel@nongnu.org, armbru@redhat.com --PdAWLd+WEPmMbsbx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 07, 2015 at 08:55:21PM -0700, Eric Blake wrote: > By sticking the next pointer first, we don't need a union with > 64-bit padding for smaller types. On 32-bit platforms, this > can reduce the size of uint8List from 16 bytes (or 12, depending > on whether 64-bit ints can tolerate 4-byte alignment) down to 8. > It has no effect on 64-bit platforms (where alignment still > dictates a 16-byte struct); but fewer anonymous unions is still > a win in my book. >=20 > However, this requires visit_start_list() and visit_next_list() > to gain a size parameter, to know what size element to allocate. >=20 > I debated about going one step further, to allow for fewer casts, > by doing: > typedef GenericList GenericList; > struct GenericList { > GenericList *next; > }; > struct FooList { > GenericList base; > Foo value; > }; > so that you convert to 'GenericList *' by '&foolist->base', and > back by 'container_of(generic, GenericList, base)' (as opposed to > the existing '(GenericList *)foolist' and '(FooList *)generic'). > But doing that would require hoisting the declaration of > GenericList prior to inclusion of qapi-types.h, rather than its > current spot in visitor.h; it also makes iteration a bit more > verbose through 'foolist->base.next' instead of 'foolist->next'. >=20 > Signed-off-by: Eric Blake For the spapr change Acked-by: David Gibson --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --PdAWLd+WEPmMbsbx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWZmJ/AAoJEGw4ysog2bOS1LkP/iqRDvyUV20Bmj2kSl3cMjik jfRWfgNYlVFBp0eEgi8KzNXisa/uj7ZiFO2TTIhcnDSM3musXiXU6k3LyVOiqnOW FUyG1cxoQPYlr7O2A1tsNgsxHvsiClZ0YtGM1MjQ7VzI2Y2/IrTdMCXPsokkc6hY f8VEnfGzKZf+WTFoVfHLHc/+9huq+dHIiABF8yMuqbECaZ1s2XzqL4yWd3XaVqlz njZQRA1rs/h2ruvzJMG1P4fSA4JRMXt16sVizH1ArV7H98tmP0aqR8G5n36mM+p9 1F3f9kfEDXFke1KpEG+g/tUjt+3hgrMlPYw+l4UUYx7SRIMsnJEnAQTvPN/CWQfJ kuW8bALYEfLig94cExq1Q7afEadGg/QTMj3PKGFsJS4pXmePn3lrF5PKqoU3yKq1 Wph3Hl7d9D9+/7c1I61s0nVYycj7INETEB1DeCjHQm2lTiHE+fpQBfjro9Kkr0yb 5nlo4jAJ7vQBQmytdXjM0Jh3si9GXIbdgA0/pv6vNmOMcriOXEHYYNGTiEgVlcjT W31wCoHRPVnkzid1xiUBq3PctLKeVhOu3adGVzkArT8V5BTqsfh/gAIamCVUgM5M ucNnr7fixxN78c3RZmOcBZSS3B2FoJlRe22bzxi8Ft1xHQtaah5cLvtsd7498vr3 rUhiAu6ngAboIp/QrD4j =sRvF -----END PGP SIGNATURE----- --PdAWLd+WEPmMbsbx--