-typedef enum e_mc_region_type_t {
- MC_REGION_TYPE_UNKNOWN = 0,
- MC_REGION_TYPE_HEAP = 1,
- MC_REGION_TYPE_DATA = 2
-} mc_region_type_t;
-
-// TODO, use OO instead of this
-typedef enum e_mc_region_storeage_type_t {
- MC_REGION_STORAGE_TYPE_NONE = 0,
- MC_REGION_STORAGE_TYPE_FLAT = 1,
- MC_REGION_STORAGE_TYPE_CHUNKED = 2,
- MC_REGION_STORAGE_TYPE_PRIVATIZED = 3
-} mc_region_storage_type_t;
-
-/** @brief Copy/snapshot of a given memory region
- *
- * Different types of region snapshot storage types exist:
- * <ul>
- * <li>flat/dense snapshots are a simple copy of the region;</li>
- * <li>sparse/per-page snapshots are snaapshots which shared
- * identical pages.</li>
- * <li>privatized (SMPI global variable privatisation).
- * </ul>
- *
- * This is handled with a variant based approch:
- *
- * * `storage_type` identified the type of storage;
- * * an anonymous enum is used to distinguish the relevant types for
- * each type.
- */
-typedef struct s_mc_mem_region s_mc_mem_region_t, *mc_mem_region_t;
-
-struct s_mc_mem_region {
- mc_region_type_t region_type;
- mc_region_storage_type_t storage_type;
- mc_object_info_t object_info;
-
- /** @brief Virtual address of the region in the simulated process */
- void *start_addr;
-
- /** @brief Size of the data region in bytes */
- size_t size;
-
- /** @brief Permanent virtual address of the region
- *
- * This is usually the same address as the simuilated process address.
- * However, when using SMPI privatization of global variables,
- * each SMPI process has its own set of global variables stored
- * at a different virtual address. The scheduler maps those region
- * on the region of the global variables.
- *
- * */
- void *permanent_addr;
-
- union {
- struct {
- /** @brief Copy of the snapshot for flat snapshots regions (NULL otherwise) */
- void *data;
- } flat;
- struct {
- /** @brief Pages indices in the page store for per-page snapshots (NULL otherwise) */
- size_t* page_numbers;
- } chunked;
- struct {
- size_t regions_count;
- mc_mem_region_t* regions;
- } privatized;
- };
-
-};
-
-mc_mem_region_t mc_region_new_sparse(mc_region_type_t type, void *start_addr, void* data_addr, size_t size, mc_mem_region_t ref_reg);
-void MC_region_destroy(mc_mem_region_t reg);
-void mc_region_restore_sparse(mc_mem_region_t reg, mc_mem_region_t ref_reg);
-
-static inline __attribute__ ((always_inline))
-bool mc_region_contain(mc_mem_region_t region, void* p)
-{
- return p >= region->start_addr &&
- p < (void*)((char*) region->start_addr + region->size);
-}