mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-17 05:36:46 +08:00
Fix bug #48356: private memp pools have no statistic counters
Implement struct stats_mem instance for each pool, let lwip_stats.mem[] point to these instances
This commit is contained in:
@@ -54,6 +54,7 @@ typedef enum {
|
||||
} memp_t;
|
||||
|
||||
#include "lwip/priv/memp_priv.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
/* Private mempools example:
|
||||
* .h: only when pool is used in multiple .c files: LWIP_MEMPOOL_PROTOTYPE(my_private_pool);
|
||||
@@ -71,6 +72,14 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
|
||||
|
||||
#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc memp_ ## name
|
||||
|
||||
#if MEMP_STATS
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name) static struct stats_mem name;
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name) &name,
|
||||
#else
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(name)
|
||||
#define LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(name)
|
||||
#endif
|
||||
|
||||
#if MEMP_MEM_MALLOC
|
||||
|
||||
#include "lwip/mem.h"
|
||||
@@ -93,10 +102,13 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
|
||||
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
|
||||
LWIP_DECLARE_MEMORY_ALIGNED(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \
|
||||
\
|
||||
LWIP_MEMPOOL_DECLARE_STATS_INSTANCE(memp_stats_ ## name) \
|
||||
\
|
||||
static struct memp *memp_tab_ ## name; \
|
||||
\
|
||||
const struct memp_desc memp_ ## name = { \
|
||||
LWIP_MEM_ALIGN_SIZE(size), \
|
||||
LWIP_MEMPOOL_DECLARE_STATS_REFERENCE(memp_stats_ ## name) \
|
||||
(num), \
|
||||
DECLARE_LWIP_MEMPOOL_DESC(desc) \
|
||||
memp_memory_ ## name ## _base, \
|
||||
|
||||
@@ -128,6 +128,10 @@ struct memp_desc {
|
||||
/** Element size */
|
||||
u16_t size;
|
||||
|
||||
#if MEMP_STATS
|
||||
struct stats_mem *stats;
|
||||
#endif
|
||||
|
||||
#if !MEMP_MEM_MALLOC
|
||||
/** Number of elements */
|
||||
u16_t num;
|
||||
|
||||
@@ -247,7 +247,7 @@ struct stats_ {
|
||||
struct stats_mem mem;
|
||||
#endif
|
||||
#if MEMP_STATS
|
||||
struct stats_mem memp[MEMP_MAX];
|
||||
struct stats_mem *memp[MEMP_MAX];
|
||||
#endif
|
||||
#if SYS_STATS
|
||||
struct stats_sys sys;
|
||||
@@ -370,19 +370,9 @@ void stats_init(void);
|
||||
#endif
|
||||
|
||||
#if MEMP_STATS
|
||||
#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y
|
||||
#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x)
|
||||
#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x)
|
||||
#define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1)
|
||||
#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i)
|
||||
#define MEMP_STATS_GET(x, i) STATS_GET(memp[i].x)
|
||||
#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i]->x)
|
||||
#else
|
||||
#define MEMP_STATS_AVAIL(x, i, y)
|
||||
#define MEMP_STATS_INC(x, i)
|
||||
#define MEMP_STATS_DEC(x, i)
|
||||
#define MEMP_STATS_INC_USED(x, i)
|
||||
#define MEMP_STATS_DISPLAY(i)
|
||||
#define MEMP_STATS_GET(x, i) 0
|
||||
#endif
|
||||
|
||||
#if SYS_STATS
|
||||
|
||||
Reference in New Issue
Block a user