[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Struct packing/alignment problems
From: |
K.J. Mansley |
Subject: |
Re: [lwip-users] Struct packing/alignment problems |
Date: |
04 May 2004 18:33:35 +0100 |
On Tue, 2004-05-04 at 18:02, Timmy Brolin wrote:
> Jani Monoses wrote:
> >without the PACK directives all those u16s would be put at 4 byte
> >boundaries, not what we want.
> >
> Why would they be put on 4 byte boundaries? The natural boundary of u16s
> is 2 bytes, not 4 bytes. Putting a u16 on a 4 byte boundary changes nothing.
Try this:
http://www.linuxdevices.com/eljonline/issue09/5783l3.html
with the associated explanation (scroll down to "listing 3")
http://www.linuxdevices.com/cgi-bin/printerfriendly.cgi?id=AT5340618290
Compilers can, and will, insert gaps between structure elements in order
to make accessing those fields more efficient. This is particularly
true on RISC processors such as ARMs (I think) where accessing something
on a 32bit boundary can be done more efficiently than an 8bit boundary.
That's what the __attribute__((packed)) directive is for: if it wasn't
necessary, why is it so prevalent? Have a grep through the linux kernel
headers for more examples.
Kieran
- Re: [lwip-users] Struct packing/alignment problems, (continued)
- Re: [lwip-users] Struct packing/alignment problems, d99tibr, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Jani Monoses, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Timmy Brolin, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Leon Woestenberg, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Timmy Brolin, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Leon Woestenberg, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Timmy Brolin, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Jani Monoses, 2004/05/05
- Re: [lwip-users] Struct packing/alignment problems, Jani Monoses, 2004/05/05
- Re: [lwip-users] Struct packing/alignment problems, Timmy Brolin, 2004/05/05
- Re: [lwip-users] Struct packing/alignment problems,
K.J. Mansley <=
- Re: [lwip-users] Struct packing/alignment problems, Timmy Brolin, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Kieran Mansley, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Leon Woestenberg, 2004/05/04
- Re: [lwip-users] Struct packing/alignment problems, Timmy Brolin, 2004/05/04
- RE: [lwip-users] Struct packing/alignment problems, Chris Jones, 2004/05/04
- RE: [lwip-users] Struct packing/alignment problems, K.J. Mansley, 2004/05/05
- RE: [lwip-users] Struct packing/alignment problems, Chris Jones, 2004/05/05
- RE: [lwip-users] Struct packing/alignment problems, K.J. Mansley, 2004/05/05
- Re: [lwip-users] Struct packing/alignment problems, Leon Woestenberg, 2004/05/05
- Re: [lwip-users] Struct packing/alignment problems, K.J. Mansley, 2004/05/05