Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename sup-mmap.c into mmorecore.c and simplify the code since we want no more than...
[simgrid.git] / src / mc / mc_memory.c
1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved.            */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include "mc/mc.h"
9 #include "mc_private.h"
10 #include "xbt/log.h"
11 #define _GNU_SOURCE
12
13
14
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_memory, mc,
16                                 "Logging specific to MC (memory)");
17
18 /* Pointers to each of the heap regions to use */
19 void *std_heap = NULL;          /* memory erased each time the MC stuff rollbacks to the beginning. Almost everything goes here */
20 void *raw_heap = NULL;          /* memory persistent over the MC rollbacks. Only MC stuff should go there */
21 /* int raw_heap_fd; */ /* unsued */
22
23 /* Initialize the model-checker memory subsystem */
24 /* It creates the two heap regions: std_heap and raw_heap */
25 void MC_memory_init()
26 {
27 /* Create the first region HEAP_OFFSET bytes after the heap break address */
28   std_heap = mmalloc_get_default_md();
29   xbt_assert(std_heap != NULL);
30
31 /* Create the second region a page after the first one ends + safety gap */
32 /*  raw_heap_fd = shm_open("raw_heap", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);*/
33   raw_heap = mmalloc_attach(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize());
34   xbt_assert(raw_heap != NULL);
35 }
36
37 /* Finish the memory subsystem */
38 #include "xbt_modinter.h"
39 void MC_memory_exit(void)
40 {
41   if (raw_heap)
42     mmalloc_detach(raw_heap);
43 }