lwip-devel
[Top][All Lists]
Advanced

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

Re: [lwip-devel] Putting memp_memory (in core/memp.c) in its own section


From: David Brown
Subject: Re: [lwip-devel] Putting memp_memory (in core/memp.c) in its own section
Date: Mon, 24 Oct 2011 08:52:39 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1

On 21/10/2011 19:26, address@hidden wrote:
David Brown wrote:
I did notice the MEMP_SEPARATE_POOLS, but I thought then I would need to
have each pool defined separately - with higher risk of forgetting
something, or getting the sizes wrong.
What's true is that you would need to define each pool - although if you
forget a pool it won't go wrong, but it will just stay in .bss.


OK, then it's not too bad - it's easy enough to check the map file and see if something has ended up in the .bss section. My worry was that the space might not be reserved, but might be accidentally used anyway - such problems are always horrible to find and debug. (I do most of my programming on small embedded systems, so I have a natural allergy to dynamic memory. I am very glad that LWIP has its own self-contained and very well tested system for dynamic memory, but it still makes me nervous!)

I do realize though that it would be more convenient to be able to just
move all lwIP data into different sections. Other portable software I've
seen supporting this just had defines like LWIP_MEM_BEFORE and
LWIP_MEM_AFTER to support different ways of section assignment. I wonder
if we should also do it that way...

These macros alone would not be sufficient, since some compilers require a couple of #pragma's here, and that always works badly with #define'd macros.

The code in memp.c at the moment (in the 1.4.0 release) is:

/** This is the actual memory used by the pools (all pools in one big block). */
static u8_t memp_memory[MEM_ALIGNMENT - 1
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
#include "lwip/memp_std.h"
];


You would need something like:

#ifdef LWIP_MEM_USE_INCLUDES
#  include "arch/lwipmembefore.h"
#endif
LWIP_MEM_BEFORE
static u8_t memp_memory[MEM_ALIGNMENT - 1
#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) )
#include "lwip/memp_std.h"
]
LWIP_MEM_AFTER
;
#ifdef LWIP_MEM_USE_INCLUDES
#  include "arch/lwipmemafter.h"
#endif


Then compilers that use a gcc attribute syntax could use
#define LWIP_MEM_AFTER __attribute__((section("bigmemory")))

while compilers that use #pragma's could put them in include files.




I won't change my code at the moment, since it is working fine, but I'll
remember that for next time.
I can understand you there - don't change a running system. However, if
you do the work now, it will be easier for you to switch to a new
version of lwIP in the future.


It is certainly something I will do in future projects using LWIP, or if I update LWIP in this project.

I am /very/ impressed that this was the only change I needed to make in the code for the port - everything else was in the "proper" places (cc.h, sys_arch.*, etc.). Very nice.

Thanks,

David






reply via email to

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