
Dear Wolfgang,
2009/1/28 Wolfgang Denk wd@denx.de:
Dear Luigi Mantellini,
In message b73e93990901281416k766b2bf3qc6429f77545f9191@mail.gmail.com you wrote:
I think that an audit of the code is important to understand if we have a problem (or not) and how large is the problem.
We (i. e. all of us except you) do not have a problem.
my question is: how can you be sure on this? I haven't used strange compilers or strange CFLAGS.. I just do "make" on a supported target (qemu_mips). I haven't any problem to correct my local source tree. I ask myself why gcc offers a packed atribute, ms-vc offers pragma packed, ...
My compiler is not broken...
Well, YMMV...
the behavior is clear: in my environment, the default choice is to align fields on 32bit for speed reasons... and I like this by default for my applications. I can ignore the problem using options like -Os (I will try tomorrow) or -fpack-struct or other global mechanisms or, pay attention on structures definitions to be sure that the structure size is compiler and cflags independent.
cassini linux # find -name *.c -o -name *.h |xargs grep attribute | grep packed | wc -l 3153
I see a lot of packed structs...
Here is for example a copy of /usr/include/netinet/ip.h :
...
This doesn't say anything regarding how kernel guys have resolved the problem (if they are solved...). Checking the kernel headers a lot
This is not a kernel header. This is one of the standard user space network headers, and a pretty central one. Feel free to check any others.
I see. I would like to understand why this structure is optimization-prof. I will study tomorrow...
I think that "struct packing" needs to be understood and a global
I agree on this. This definitely needs to be understood.
Hm... I think I understand it, and it works for me :-)
iso C doensn't require packing by default of the structures. To assume that a structure is packed by default is not a good assumption. All compilers offer directives to control the behavior of packing... I believe that there is a reason...
mechanism should be used (like -fpack-struct option always defined or a style guideline that requires a tag for each structs). From my point
I think this is not needed. Please read the docuemntation about alignment and padding. It is pretty clear.
which documentation should I read? iso c documents? gcc manuals? I haven't found anything that opposes my affirmations. I want underline that the structures (IP_t, ... ) don't have field across the word-machine boundary... but this doesn't exclude an "memory-access" optimization. Kindly, can you give me any good links?
Anyway, I don't want to talk about philosophy. I just noticed an anomaly and I wanted to share with the ML.
my 2LireItaliane
best regards,
luigi
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "And it should be the law: If you use the word `paradigm' without knowing what the dictionary says it means, you go to jail. No exceptions." - David Jones @ Megatest Corporation