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: K.J. Mansley
Subject: RE: [lwip-users] Struct packing/alignment problems
Date: 05 May 2004 13:49:33 +0100

On Wed, 2004-05-05 at 12:49, Chris Jones wrote:
> >This would seem to be a much more serious, and difficult problem to
> >solve than the "packed" debate.  Systems with non-8-bit-bytes (they
> >still have byte addressing by definition btw: it's just the byte is not
> >8 bits) have been largely ignored in development as it's hard to find a
> >solution that is pleasing to both.
> 
> Actually, a 'byte' is always 8 bits.

Standard (historical) definition is the smallest addressable quantity
(not necessarily 8 bits), but it is commonly used to describe 8 bits, as
8-bit-byte architectures are so common:

http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?query=byte&action=Search

> It is the 'char' type that can be defined to be multiple bytes on a 
> particular platform.
>
> Relying on char to have a size equal to one byte is poor design.

Agreed!

> A better approach is to manage memory using the default word size.
> 
> Many DSPs do NOT have byte addressing. Incrementing an address on these 
> platforms will advace to the next word.

The word is the size of the data bus, and sounds like these platforms
have bytes and words defined to be the same size.  They still have byte
addressing, but the byte is not 8 bits.  As a byte is the smallest
addressable quantity, you should always have byte addressing by
definition.  As word sizes can vary too, relying on a default word size
is not much better.

I agree that assuming a byte or a char is 8 bits is bad practice, and we
should avoid it where ever possible; I was just being overly pedantic
about the use of the word byte.  I think your definition is much more
common now, but so I should probably give it up as a lost cause.  More
important is getting lwIP fixed to not make these assumptions!

Kieran





reply via email to

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