Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : fix compilation error
[simgrid.git] / src / mc / mc_memory.c
1 #include <sys/stat.h>
2 #include <fcntl.h>
3 #include "mc/mc.h"
4 #include "private.h"
5 #include "xbt/log.h"
6 #define _GNU_SOURCE
7
8
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_memory, mc,
11                                 "Logging specific to MC (memory)");
12
13 /* Pointers to each of the heap regions to use */
14 void *std_heap = NULL;          /* memory erased each time the MC stuff rollbacks to the beginning. Almost everything goes here */
15 void *raw_heap = NULL;          /* memory persistent over the MC rollbacks. Only MC stuff should go there */
16 /* int raw_heap_fd; */ /* unsued */
17
18 /* Initialize the model-checker memory subsystem */
19 /* It creates the two heap regions: std_heap and raw_heap */
20 void MC_memory_init()
21 {
22 /* Create the first region HEAP_OFFSET bytes after the heap break address */
23   std_heap = mmalloc_get_default_md();
24   xbt_assert(std_heap != NULL);
25
26 /* Create the second region a page after the first one ends + safety gap */
27 /*  raw_heap_fd = shm_open("raw_heap", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);*/
28   raw_heap = mmalloc_attach(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize());
29   xbt_assert(raw_heap != NULL);
30 }
31
32 /* Finish the memory subsystem */
33 #include "xbt_modinter.h"
34 void MC_memory_exit(void)
35 {
36   if (raw_heap)
37     mmalloc_detach(raw_heap);
38 }