[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [patch] add byteordered types
From: |
Paul Brook |
Subject: |
Re: [Qemu-devel] [patch] add byteordered types |
Date: |
Wed, 27 Aug 2008 14:55:07 +0100 |
User-agent: |
KMail/1.9.9 |
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
- [Qemu-devel] [patch] add byteordered types, Gerd Hoffmann, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Paul Brook, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Gerd Hoffmann, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, M. Warner Losh, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Gerd Hoffmann, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Anthony Liguori, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Gerd Hoffmann, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Anthony Liguori, 2008/08/27
- Re: [Qemu-devel] [patch] add byteordered types, Gerd Hoffmann, 2008/08/28
- Re: [Qemu-devel] [patch] add byteordered types, Jamie Lokier, 2008/08/27