mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-18 20:10:53 +00:00
added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc is otherwise used)
This commit is contained in:
parent
6472e3b35e
commit
c4509e700d
@ -19,6 +19,11 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2009-02-11 Simon Goldschmidt (suggested by Gottfried Spitaler)
|
||||||
|
* opt.h, memp.h/.c: added MEMP_MEM_MALLOC to use mem_malloc/mem_free instead
|
||||||
|
of the pool allocator (can save code size with MEM_LIBC_MALLOC if libc-malloc
|
||||||
|
is otherwise used)
|
||||||
|
|
||||||
2009-01-28 Jonathan Larmour (suggested by Bill Bauerbach)
|
2009-01-28 Jonathan Larmour (suggested by Bill Bauerbach)
|
||||||
* ipv4/inet_chksum.c, ipv4/lwip/inet_chksum.h: inet_chksum_pseudo_partial()
|
* ipv4/inet_chksum.c, ipv4/lwip/inet_chksum.h: inet_chksum_pseudo_partial()
|
||||||
is only used by UDPLITE at present, so conditionalise it.
|
is only used by UDPLITE at present, so conditionalise it.
|
||||||
|
@ -56,6 +56,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
struct memp {
|
struct memp {
|
||||||
struct memp *next;
|
struct memp *next;
|
||||||
#if MEMP_OVERFLOW_CHECK
|
#if MEMP_OVERFLOW_CHECK
|
||||||
@ -109,8 +111,14 @@ struct memp {
|
|||||||
* Elements form a linked list. */
|
* Elements form a linked list. */
|
||||||
static struct memp *memp_tab[MEMP_MAX];
|
static struct memp *memp_tab[MEMP_MAX];
|
||||||
|
|
||||||
|
#else /* MEMP_MEM_MALLOC */
|
||||||
|
|
||||||
|
#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x))
|
||||||
|
|
||||||
|
#endif /* MEMP_MEM_MALLOC */
|
||||||
|
|
||||||
/** This array holds the element sizes of each pool. */
|
/** This array holds the element sizes of each pool. */
|
||||||
#if !MEM_USE_POOLS
|
#if !MEM_USE_POOLS && !MEMP_MEM_MALLOC
|
||||||
static
|
static
|
||||||
#endif
|
#endif
|
||||||
const u16_t memp_sizes[MEMP_MAX] = {
|
const u16_t memp_sizes[MEMP_MAX] = {
|
||||||
@ -118,6 +126,8 @@ const u16_t memp_sizes[MEMP_MAX] = {
|
|||||||
#include "lwip/memp_std.h"
|
#include "lwip/memp_std.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */
|
||||||
|
|
||||||
/** This array holds the number of elements in each pool. */
|
/** This array holds the number of elements in each pool. */
|
||||||
static const u16_t memp_num[MEMP_MAX] = {
|
static const u16_t memp_num[MEMP_MAX] = {
|
||||||
#define LWIP_MEMPOOL(name,num,size,desc) (num),
|
#define LWIP_MEMPOOL(name,num,size,desc) (num),
|
||||||
@ -368,3 +378,5 @@ memp_free(memp_t type, void *mem)
|
|||||||
|
|
||||||
SYS_ARCH_UNPROTECT(old_level);
|
SYS_ARCH_UNPROTECT(old_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* MEMP_MEM_MALLOC */
|
||||||
|
@ -73,10 +73,22 @@ typedef enum {
|
|||||||
We use this helper type and these defines so we can avoid using const memp_t values */
|
We use this helper type and these defines so we can avoid using const memp_t values */
|
||||||
#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
|
#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
|
||||||
#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
|
#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
|
||||||
|
|
||||||
extern const u16_t memp_sizes[MEMP_MAX];
|
|
||||||
#endif /* MEM_USE_POOLS */
|
#endif /* MEM_USE_POOLS */
|
||||||
|
|
||||||
|
#if MEMP_MEM_MALLOC || MEM_USE_POOLS
|
||||||
|
extern const u16_t memp_sizes[MEMP_MAX];
|
||||||
|
#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
|
||||||
|
|
||||||
|
#if MEMP_MEM_MALLOC
|
||||||
|
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
#define memp_init()
|
||||||
|
#define memp_malloc(type) mem_malloc(memp_sizes[type])
|
||||||
|
#define memp_free(type, mem) mem_free(mem)
|
||||||
|
|
||||||
|
#else /* MEMP_MEM_MALLOC */
|
||||||
|
|
||||||
void memp_init(void);
|
void memp_init(void);
|
||||||
|
|
||||||
#if MEMP_OVERFLOW_CHECK
|
#if MEMP_OVERFLOW_CHECK
|
||||||
@ -87,6 +99,8 @@ void *memp_malloc(memp_t type);
|
|||||||
#endif
|
#endif
|
||||||
void memp_free(memp_t type, void *mem);
|
void memp_free(memp_t type, void *mem);
|
||||||
|
|
||||||
|
#endif /* MEMP_MEM_MALLOC */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,6 +98,15 @@
|
|||||||
#define MEM_LIBC_MALLOC 0
|
#define MEM_LIBC_MALLOC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 and usage from interrupts!
|
||||||
|
*/
|
||||||
|
#ifndef MEMP_MEM_MALLOC
|
||||||
|
#define MEMP_MEM_MALLOC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MEM_ALIGNMENT: should be set to the alignment of the CPU
|
* MEM_ALIGNMENT: should be set to the alignment of the CPU
|
||||||
* 4 byte alignment -> #define MEM_ALIGNMENT 4
|
* 4 byte alignment -> #define MEM_ALIGNMENT 4
|
||||||
@ -1120,7 +1129,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef RECV_BUFSIZE_DEFAULT
|
#ifndef RECV_BUFSIZE_DEFAULT
|
||||||
#define RECV_BUFSIZE_DEFAULT INT_MAX
|
#define RECV_BUFSIZE_DEFAULT INT_MAX
|
||||||
#endif /* RECV_BUFSIZE_DEFAULT */
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!
|
* SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!
|
||||||
|
Loading…
Reference in New Issue
Block a user