lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] wrong statement in lwip wiki page about structurepackin


From: Stephane Lesage
Subject: Re: [lwip-users] wrong statement in lwip wiki page about structurepacking
Date: Wed, 29 Aug 2012 12:31:03 +0200

> > Whoever wrote that (I'm too lazy to check the wiki history right
> > now) thought (or maybe even checked) that inside protocol headers,
> all
> > members are aligned, so when the start of a protocol header is
> > aligned, you wouldn't need packing.
> 
> Structure alignment and packing of internal members are different
> things. Author of those phrase was wrong in last words about packing.
> Structure members may be padded relatively to each other in general
> case.
> This is what I talking about. I don't know what means "packing" with
> respect to whole structure but I'm sure each member must be packed
> separately. I even agree to believe author to not define
> PACK_STRUCT_STRUCT in conditions provided but this is not related to
> PACK_STRUCT_FIELD.
> 
> > However, this is *not* guaranteed to work by lwIP, and we do not
> check
> > for this to work when making changes to the sources. Being like
that,
> > it *might* work (maybe depending on which protocols are used), but I
> > would suggest to test the stack very thoroughly when used like that!
> 
> All the more reason to remove that phrase completely.

Hi,
I am the author.
And somebody (Simon I think) added:
"In any case, make sure the system runs stable when chosing a structure
packing setting different to 1!"

On two platforms that don't handle misaligned memory accesses (ADI
Blackfin and TI C674x) I have:
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END

And I guarantee you it's working, so I hold to my statement for
IP/UDP/TCP.
Of course higher application protocols may need packing (for example
netbios)

Now, maybe I didn't use the exact appropriate vocabulary (alignment /
packing / whatever), but I think I was careful enough by saying "*may*
not need packing"
The intent was to give a hint to enhance performance.

Best regards.

-- 
Stephane Lesage




reply via email to

[Prev in Thread] Current Thread [Next in Thread]