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:
Dirk Ziegelmeier
2016-07-07 21:55:51 +02:00
parent dcd52510ce
commit 212eacd9d6
5 changed files with 57 additions and 48 deletions

View File

@@ -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, \

View File

@@ -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;

View File

@@ -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