lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Struct packing/alignment problems


From: Timmy Brolin
Subject: Re: [lwip-users] Struct packing/alignment problems
Date: Tue, 04 May 2004 02:04:43 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

Jani Monoses wrote:

I think we should clean up the code to extract the unaligned header fields into the correctly typed temporary variables and use those variables in further protocol code.

The underlying thought is to keep the protocol code clean from solving
the alignment issues.

I have applied your patch blindly to the current CVS tree, just to
make sure it gets developer attention as this is a long standing
important issue.

I made a change to etharp.h so that old behaviour(no padding ) is
restored. If PAD_ETH_SIZE is defined outside the file (lwipopts,
compiler flag) than it gets used else it is 0.
The reason is that with the change it did not work with ecos and
possibly with any gcc target.

Jani

Exactly how did it not work? Correct alignment of header fields will not break anything. I suggest correct alignment is made mandatory in lwip since without it the lwip code does not conform to the ANSI C standard(!). Mandatory alignment would render all thoose STRUCT_PACK macros unnecessary, resulting in cleaner code, and significantly increased portability (ANSI C conformant, no alignment problem, and no need to define architecture specific struct packing macros) As a bonus, correct alignment will increase performance slightly on all 32bit systems. (Probably not very noticeable)
There is really no reason to not make it a mandatory part of lwip.

I suspect the problem you have is in your ethernet driver, the driver must be slightly altered to work with the alignment patch.

Timmy





reply via email to

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