lwIP
2.1.0
Lightweight IP stack
|
Macros | |
#define | MEM_LIBC_MALLOC 0 |
#define | MEMP_MEM_MALLOC 0 |
#define | MEMP_MEM_INIT 0 |
#define | MEM_ALIGNMENT 1 |
#define | MEM_SIZE 1600 |
#define | MEMP_OVERFLOW_CHECK 0 |
#define | MEMP_SANITY_CHECK 0 |
#define | MEM_OVERFLOW_CHECK 0 |
#define | MEM_SANITY_CHECK 0 |
#define | MEM_USE_POOLS 0 |
#define | MEM_USE_POOLS_TRY_BIGGER_POOL 0 |
#define | MEMP_USE_CUSTOM_POOLS 0 |
#define | LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 |
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 |
Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from interrupt context (or another context that doesn't allow waiting for a semaphore). If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs with each loop so that mem_free can run.
ATTENTION: As you can see from the above description, this leads to dis-/ enabling interrupts often, which can be slow! Also, on low memory, mem_malloc can need longer.
If you don't want that, at least for NO_SYS=0, you can still use the following functions to enqueue a deallocation call which then runs in the tcpip_thread context:
#define MEM_ALIGNMENT 1 |
MEM_ALIGNMENT: should be set to the alignment of the CPU 4 byte alignment -> #define MEM_ALIGNMENT 4 2 byte alignment -> #define MEM_ALIGNMENT 2
#define MEM_LIBC_MALLOC 0 |
MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library instead of the lwip internal allocator. Can save code size if you already use it.
#define MEM_OVERFLOW_CHECK 0 |
MEM_OVERFLOW_CHECK: mem overflow protection reserves a configurable amount of bytes before and after each heap allocation chunk and fills it with a prominent default value. MEM_OVERFLOW_CHECK == 0 no checking MEM_OVERFLOW_CHECK == 1 checks each element when it is freed MEM_OVERFLOW_CHECK >= 2 checks all heap elements every time mem_malloc() or mem_free() is called (useful but slow!)
#define MEM_SANITY_CHECK 0 |
MEM_SANITY_CHECK==1: run a sanity check after each mem_free() to make sure that the linked list of heap elements is not corrupted.
#define MEM_SIZE 1600 |
MEM_SIZE: the size of the heap memory. If the application will send a lot of data that needs to be copied, this should be set high.
#define MEM_USE_POOLS 0 |
MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set of memory pools of various sizes. When mem_malloc is called, an element of the smallest pool that can provide the length needed is returned. To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled.
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 |
MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more reliable.
#define MEMP_MEM_INIT 0 |
MEMP_MEM_INIT==1: Force use of memset to initialize pool memory. Useful if pool are moved in uninitialized section of memory. This will ensure default values in pcbs struct are well initialized in all conditions.
#define MEMP_MEM_MALLOC 0 |
MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution speed (heap alloc can be much slower than pool alloc) and usage from interrupts (especially if your netif driver allocates PBUF_POOL pbufs for received frames from interrupt)! ATTENTION: Currently, this uses the heap for ALL pools (also for private pools, not only for internal pools defined in memp_std.h)!
#define MEMP_OVERFLOW_CHECK 0 |
MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable amount of bytes before and after each memp element in every pool and fills it with a prominent default value. MEMP_OVERFLOW_CHECK == 0 no checking MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time memp_malloc() or memp_free() is called (useful but slow!)
#define MEMP_SANITY_CHECK 0 |
MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make sure that there are no cycles in the linked lists.
#define MEMP_USE_CUSTOM_POOLS 0 |
MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h that defines additional pools beyond the "standard" ones required by lwIP. If you set this to 1, you must have lwippools.h in your include path somewhere.