Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
when parallel ctests are performed, using the default tracing filename may cause...
[simgrid.git] / src / mc / mc_memory.c
1 /* Copyright (c) 2008-2013. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include "mc/mc.h"
10 #include "mc_private.h"
11 #include "xbt/log.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_memory, mc,
14                                 "Logging specific to MC (memory)");
15
16 /* Pointers to each of the heap regions to use */
17 void *std_heap = NULL;          /* memory erased each time the MC stuff rollbacks to the beginning. Almost everything goes here */
18 void *raw_heap = NULL;          /* memory persistent over the MC rollbacks. Only MC stuff should go there */
19
20 /* Initialize the model-checker memory subsystem */
21 /* It creates the two heap regions: std_heap and raw_heap */
22 void MC_memory_init()
23 {
24   /* Create the first region HEAP_OFFSET bytes after the heap break address */
25   std_heap = mmalloc_get_default_md();
26   xbt_assert(std_heap != NULL);
27
28 #if defined HAVE_GNU_LD && !defined MMALLOC_WANT_OVERRIDE_LEGACY 
29   /* use the system malloc for the model-checker data */
30   raw_heap = NULL;
31 #else
32   /* Create the second region a page after the first one ends + safety gap */
33   raw_heap = xbt_mheap_new(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize());
34   xbt_assert(raw_heap != NULL);
35 #endif
36 }
37
38 /* Finalize the memory subsystem */
39 #include "xbt_modinter.h"
40 void MC_memory_exit(void)
41 {
42   if (raw_heap)
43     xbt_mheap_destroy(raw_heap);
44 }