From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KYLUP-0000oC-EF for qemu-devel@nongnu.org; Wed, 27 Aug 2008 09:55:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KYLUO-0000nW-1J for qemu-devel@nongnu.org; Wed, 27 Aug 2008 09:55:13 -0400 Received: from [199.232.76.173] (port=59530 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYLUN-0000nN-Mb for qemu-devel@nongnu.org; Wed, 27 Aug 2008 09:55:11 -0400 Received: from mail.codesourcery.com ([65.74.133.4]:59255) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KYLUM-0003Yq-Uw for qemu-devel@nongnu.org; Wed, 27 Aug 2008 09:55:11 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [patch] add byteordered types Date: Wed, 27 Aug 2008 14:55:07 +0100 References: <48B53E23.5040107@redhat.com> <48B550F3.709@redhat.com> <48B5557A.3000901@redhat.com> In-Reply-To: <48B5557A.3000901@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200808271455.08089.paul@codesourcery.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: Gerd Hoffmann On Wednesday 27 August 2008, Gerd Hoffmann wrote: > Gerd Hoffmann wrote: > > Paul Brook wrote: > >> On Wednesday 27 August 2008, Gerd Hoffmann wrote: > >>> +typedef struct { uint16_t le; } le16; > >> > >> This won't do what you expect on some targets. In particular older ARM > >> targets align all structs to a word (4-byte) boundary. > > > > Is this a default which can be changed by adding alignment atttributes? > > ... like this: > > -typedef struct { uint16_t le; } le16; > +typedef struct { uint16_t le; } le16 __attribute__((__aligned__(2))); > > Is the size if the struct padded to 4 bytes too (i.e. do I need packed > too)? RTFM: "When used on a struct, or struct member, the `aligned' attribute can only increase the alignment; in order to decrease it, the `packed' attribute must be specified as well." Paul