heap.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef HEAP_H
  2. #define HEAP_H
  3. #include <stdint.h>
  4. #include <pthread.h>
  5. #include "LeaHeader.h"
  6. #define NUM_HEAPS 4
  7. /**
  8. * A structure to represent a singly linked list node
  9. */
  10. typedef struct node_s {
  11. void *data; /**< pointer to the actual data */
  12. struct node_s *next; /**< pointer to the next item of the list */
  13. } NODE;
  14. /**
  15. * A structure to represent a maptable node
  16. *
  17. * Heaps contain
  18. */
  19. typedef struct maptable_node_s {
  20. unsigned int size; /**< the size of the blocks of the fixed list */
  21. //NODE *fixed_list_head; /**< pointer to the head node of the fixed list */
  22. leaHdr *fixed_list_head; /**< pointer to the head node of the fixed list */
  23. struct maptable_node_s *next; /**< pointer to the next node of the maptable */
  24. } MAPTABLE_NODE;
  25. typedef struct dmmstats_s {
  26. uint32_t max_mem_allocated; /**< maximum total memory allocated */
  27. uint32_t max_mem_requested; /**< maximum total memory requested */
  28. uint32_t mem_allocated; /**< total memory currently allocated */
  29. uint32_t mem_requested; /**< total memory currently requested */
  30. uint32_t live_objects; /**< number of live objects */
  31. uint32_t read_mem_accesses; /**< number of read accesses */
  32. uint32_t write_mem_accesses; /**< number of write accesses */
  33. uint32_t num_malloc; /**< number of malloc()'s served */
  34. uint32_t num_free; /**< number of free()'s served */
  35. } dmmstats_t;
  36. typedef struct dmmknobs_s {
  37. uint32_t maxCoalesceSize;
  38. uint32_t minSplitSize;
  39. float empty_threshold;
  40. uint32_t percentage;
  41. char frag_state; //FIXME It was in the old code to refresh the frag check
  42. } dmmknobs_t;
  43. typedef struct heap_s {
  44. MAPTABLE_NODE *maptable_head;
  45. //NODE *free_list_head;
  46. leaHdr *free_list_head;
  47. //NODE *rov_ptr;
  48. leaHdr *rov_ptr;
  49. uint64_t num_objects;
  50. dmmstats_t dmm_stats;
  51. dmmknobs_t dmm_knobs;
  52. pthread_mutex_t mutex;
  53. } heap_t;
  54. typedef struct allocator_s {
  55. heap_t heaps[NUM_HEAPS];
  56. char *border_ptr;
  57. } allocator_t;
  58. #endif /* HEAP_H */