#ifndef HEAP_H #define HEAP_H #include #ifdef HAVE_LOCKS #include #endif /* HAVE_LOCKS */ #include "block_header.h" #define NUM_HEAPS 4 /** * A structure to represent a maptable node */ typedef struct maptable_node_s { unsigned int size; /**< the size of the blocks of the fixed list */ void *fixed_list_head; /**< pointer to the head node of the fixed list */ struct maptable_node_s *next; /**< pointer to the next node of the maptable */ } maptable_node_t; typedef struct dmmstats_s { uint32_t max_mem_allocated; /**< maximum total memory allocated */ uint32_t max_mem_requested; /**< maximum total memory requested */ uint32_t mem_allocated; /**< total memory currently allocated */ uint32_t mem_requested; /**< total memory currently requested */ uint32_t mem_reserved; /**< total memory currently reserved */ uint32_t live_objects; /**< number of live objects */ uint32_t read_mem_accesses; /**< number of read accesses */ uint32_t write_mem_accesses; /**< number of write accesses */ uint32_t num_malloc; /**< number of malloc()'s served */ uint32_t num_free; /**< number of free()'s served */ } dmmstats_t; /** * A structure to represent tunable parameters of a heap */ typedef struct dmmknobs_s { int32_t max_coalesce_size; /**< maximum coalesce size; -1 if coalescing is not supported */ float frag_threshold; /**< fragmentation threshold to enable coalescing or not */ uint32_t mem_threshold; /**< memory size threshold */ uint32_t min_split_size; // FIXME to be investigated if needed float empty_threshold; // FIXME to be investigated if needed uint32_t percentage; // FIXME to be investigated if needed char frag_state; //FIXME It was in the old code to refresh the frag check } dmmknobs_t; typedef struct heap_s { maptable_node_t *maptable_head; void *free_list_head; void *used_blocks_head; void *rov_ptr; uint64_t num_objects; dmmstats_t dmm_stats; dmmknobs_t dmm_knobs; #ifdef HAVE_LOCKS pthread_mutex_t mutex; #endif /* HAVE_LOCKS */ } heap_t; typedef struct allocator_s { heap_t heaps[NUM_HEAPS]; } allocator_t; #endif /* HEAP_H */