fix build with CONFIG_STATS enabled
This commit is contained in:
parent
34b6754f70
commit
84a25ec83e
34
h_malloc.c
34
h_malloc.c
@ -448,43 +448,31 @@ static u64 get_random_canary(struct random_state *rng) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void stats_small_allocate(UNUSED struct size_class *c, UNUSED size_t size) {
|
static inline void stats_small_allocate(UNUSED struct size_class *c, UNUSED size_t size) {
|
||||||
#if STATS
|
#if CONFIG_STATS
|
||||||
c->allocated += size;
|
c->allocated += size;
|
||||||
c->nmalloc++;
|
c->nmalloc++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void stats_small_deallocate(UNUSED struct size_class *c, UNUSED size_t size) {
|
static inline void stats_small_deallocate(UNUSED struct size_class *c, UNUSED size_t size) {
|
||||||
#if STATS
|
#if CONFIG_STATS
|
||||||
c->allocated -= size;
|
c->allocated -= size;
|
||||||
c->ndalloc++;
|
c->ndalloc++;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void stats_slab_allocate(UNUSED struct size_class *c, UNUSED size_t slab_size) {
|
static inline void stats_slab_allocate(UNUSED struct size_class *c, UNUSED size_t slab_size) {
|
||||||
#if STATS
|
#if CONFIG_STATS
|
||||||
c->slab_allocated += slab_size;
|
c->slab_allocated += slab_size;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void stats_slab_deallocate(UNUSED struct size_class *c, UNUSED size_t size) {
|
static inline void stats_slab_deallocate(UNUSED struct size_class *c, UNUSED size_t slab_size) {
|
||||||
#if STATS
|
#if CONFIG_STATS
|
||||||
c->slab_allocated -= slab_size;
|
c->slab_allocated -= slab_size;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void stats_large_allocate(UNUSED struct region_allocator *ra, UNUSED size_t size) {
|
|
||||||
#if STATS
|
|
||||||
ra->allocated += size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void stats_large_deallocate(UNUSED struct region_allocator *ra, UNUSED size_t size) {
|
|
||||||
#if STATS
|
|
||||||
ra->allocated -= size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void *allocate_small(size_t requested_size) {
|
static inline void *allocate_small(size_t requested_size) {
|
||||||
struct size_info info = get_size_info(requested_size);
|
struct size_info info = get_size_info(requested_size);
|
||||||
size_t size = info.size ? info.size : 16;
|
size_t size = info.size ? info.size : 16;
|
||||||
@ -801,6 +789,18 @@ struct region_allocator {
|
|||||||
struct random_state rng;
|
struct random_state rng;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline void stats_large_allocate(UNUSED struct region_allocator *ra, UNUSED size_t size) {
|
||||||
|
#if CONFIG_STATS
|
||||||
|
ra->allocated += size;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void stats_large_deallocate(UNUSED struct region_allocator *ra, UNUSED size_t size) {
|
||||||
|
#if CONFIG_STATS
|
||||||
|
ra->allocated -= size;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
struct __attribute__((aligned(PAGE_SIZE))) slab_info_mapping {
|
struct __attribute__((aligned(PAGE_SIZE))) slab_info_mapping {
|
||||||
struct slab_metadata slab_info[MAX_METADATA_MAX];
|
struct slab_metadata slab_info[MAX_METADATA_MAX];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user