[Top][All Lists]

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

Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned acce

From: Leon Woestenberg
Subject: Re: [lwip-users] [PATCH] fix warning for gcc and possible unaligned access
Date: Sun, 30 Apr 2006 23:41:49 +0200

Hello Derek,

On Thu, 2006-04-27 at 08:30 -0400, Derek Guerdon wrote:
> Timmy Brolin wrote:
> >Well, there was a long discussion about that two years ago. According to 
> >C standards adatatype may not have alignment requirements larger than 
> >its natural alignment, and padding may be introduced into structs to 
> >algin the fields in the struct. This would suggest that as long as we 
> >design the structs to be perfectly aligned, no compiler will add extra 
> >padding.
> I think this is a misinterpretation of the C standard. 


> Given the freedom that the standard allows compilers in using padding
> bytes, there is no real way to design a structure that is guaranteed
> not to have padding bytes. 
Yes, that must be the design constraint for the code. Assume padding
everywhere unless explicitly compile-time-controlled.

It can always be solved run-time, by copying a structure into a packed
structure so that its memory layout can be sent on the wire as-is.

However, in lwIP we tried hard to have the compiler put the bytes in the
right spot by packing directives or otherwise, and have these compiled

As Curt mentions, this will surely be sub-optimal, but worst case is
still doing everything run time, AFAICS.

If we can do better, I would like to hear.



reply via email to

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