- /* Semaphore locking the access to the heap */
- sem_t sem;
-
- /* Number of processes that attached the heap */
- unsigned int refcount;
-
- /* Chained lists of mdescs */
- struct mdesc *next_mdesc;
-
- /* The "magic number" for an mmalloc file. */
- char magic[MMALLOC_MAGIC_SIZE];
-
- /* The size in bytes of this structure, used as a sanity check when reusing
- a previously created mapped file. */
- unsigned int headersize;
-
- /* The version number of the mmalloc package that created this file. */
- unsigned char version;
-
- /* Some flag bits to keep track of various internal things. */
- unsigned int flags;
-
- /* Number of info entries. */
- size_t heapsize;
-
- /* Pointer to first block of the heap (base of the first block). */
- void *heapbase;
-
- /* Current search index for the heap table. */
- /* Search index in the info table. */
- size_t heapindex;
-
- /* Limit of valid info table indices. */
- size_t heaplimit;
-
- /* Block information table.
- Allocated with malign/mfree (not mmalloc/mfree). */
- /* Table indexed by block number giving per-block information. */
- malloc_info *heapinfo;
-
- /* List of all blocks containing free fragments of this size. The array indice is the log2 of requested size */
- struct list fraghead[BLOCKLOG];
-
- /* The base address of the memory region for this malloc heap. This
- is the location where the bookkeeping data for mmap and for malloc
- begins. */
+ /** @brief Mutex locking the access to the heap */
+ pthread_mutex_t mutex;
+
+ /** @brief Number of processes that attached the heap */
+ unsigned int refcount;
+
+ /** @brief Chained lists of mdescs */
+ struct mdesc *next_mdesc;
+
+ /** @brief The "magic number" for an mmalloc file. */
+ char magic[MMALLOC_MAGIC_SIZE];
+
+ /** @brief The size in bytes of this structure
+ *
+ * Used as a sanity check when reusing a previously created mapped file.
+ * */
+ unsigned int headersize;
+
+ /** @brief Version number of the mmalloc package that created this file. */
+ unsigned char version;
+
+ unsigned int options;
+
+ /** @brief Some flag bits to keep track of various internal things. */
+ unsigned int flags;
+
+ /** @brief Number of info entries. */
+ size_t heapsize;
+
+ /** @brief Pointer to first block of the heap (base of the first block). */
+ void *heapbase;
+
+ /** @brief Current search index for the heap table.
+ *
+ * Search index in the info table.
+ */
+ size_t heapindex;
+
+ /** @brief Limit of valid info table indices. */
+ size_t heaplimit;
+
+ /** @brief Block information table.
+ *
+ * Table indexed by block number giving per-block information.
+ */
+ malloc_info *heapinfo;
+
+ /* @brief List of all blocks containing free fragments of a given size.
+ *
+ * The array indice is the log2 of requested size.
+ * Actually only the sizes 8->11 seem to be used, but who cares? */
+ s_xbt_swag_t fraghead[BLOCKLOG];
+
+ /* @brief Base address of the memory region for this malloc heap
+ *
+ * This is the location where the bookkeeping data for mmap and
+ * for malloc begins.
+ */
+ void *base;
+
+ /** @brief End of memory in use
+ *
+ * Some memory might be already mapped by the OS but not used
+ * by the heap.
+ * */
+ void *breakval;
+
+ /** @brief End of the current memory region for this malloc heap.
+ *
+ * This is the first location past the end of mapped memory.
+ *
+ * Compared to breakval, this value is rounded to the next memory page.
+ */
+ void *top;
+
+ /** @brief Open file descriptor for the file to which this malloc heap is mapped
+ *
+ * If this value is negative, MAP_ANONYMOUS memory is used.
+ *
+ * Also note that it may change each time the region is mapped and unmapped. */
+ int fd;
+
+ /* @brief Instrumentation */
+ struct mstats heapstats;