|
From: | Timmy Brolin |
Subject: | Re: [lwip-users] Struct packing/alignment problems |
Date: | Wed, 05 May 2004 02:17:54 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) |
Leon Woestenberg wrote:
Given that TCP/IP header fields use natural alignment (alignment boundary equals field size), I am now quite convinced that the "Ethernet header fix" and proper definition of the uX_t variables will work for all architectures.(I hope the DSP people are reading this and can confirm this).
Well, obviously it works fine on the C6000 series Texas DSPs with Code Composer (the setup I'am using). Code Composer has no pack directives at all, and the C6000 DSPs do not support unaligned memory accesses. The Code Composer environment is the only compiler available for most (all?) Texas DSP families, and since Code Composer does not support any pack directives at all, anyone currently running lwip on a Texas DSP using Code Composer would obviously not have any problem with removed PACK_STRUCTs. I think Texas has a 50% marketshare or so, so this eliminates about half of the DSPs out there.
guarantees to not pad structs in the way I've described? The packed attribute specifies that a variable or structure field should have thesmallest possible alignment, which seems to me to be exactly what we wantPacked tells the compiler not to create padding bytes inbetween fields. Thus, it always uses 1-byte "alignment", i.e. "align on the next byteaddress". (I will leave bit fields out of this, we do not (want) to use these).Your choice of words "smallest possible alignment" may still suggest "smallest possible natural alignment".here. Maybe it's unnecessary, but we should make sure of that before we go breaking things, and if it's not tightly specified to be as you say, I'd rather leave the packed directives in. Given that the packedI would rather remove the pack directives; and have someone come up with a problem report if that breaks stuff. We know how to pack stuff now, even with the #include method (that was for a M$ compiler, am I right??), so we can easily revert to this method might someone find the unusual subject.directives (in lwip) are all macros that can easily be redefined by anyone for whom it causes a problem, I think I've lost sight of what the objection to them was.Messes up the code unnecessarely.
Nice and clean code is the holy grail. Or something. :-) Timmy
Regards, Leon.
[Prev in Thread] | Current Thread | [Next in Thread] |