lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Missaligned memory buffers


From: Kjell Andersson XW (LM/EAB)
Subject: [lwip-devel] Missaligned memory buffers
Date: Fri, 3 Oct 2003 15:13:11 +0200

The static memory buffers, pbuf_pool_memory and memp_memory, in pbuf.c and 
memp.c causes missaligned data reads on some architectures (in my case a Sparc 
processor). Such reads are not allowed on all architectures.
These buffers are declared as u8_t but the usage of them tries to read u32_t 
pointers (in the form of struct memp pointers) from the buffers. Not all 
compilers align these buffers to a 4 byte alignment as is needed on some 
architectures. There are three solutions that will solve the problem:

1. Create macros for reading missaligned data and use whenever is needed. Not a 
good solution since this will slow down the code!
2. Embedd them in a union with a u32_t dummy variable.
3. Declare them as u32_t and divide the size by 4.

I think (3) is the best. Any thoughs on this?

Are there more buffers in the code that must be aligned but are declared as 
u8_t (for example ram in mem.c)?

 / Kjell





reply via email to

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