X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/84183e4f4aa50f6220315835894bc0677c0ea64c..a6b23c846948f7f89277f75e7c42f3942b31b8d3:/src/mc/mc_page_store.h diff --git a/src/mc/mc_page_store.h b/src/mc/mc_page_store.h index 3caa88519e..9b7841876e 100644 --- a/src/mc/mc_page_store.h +++ b/src/mc/mc_page_store.h @@ -6,19 +6,25 @@ #include +#ifdef __cplusplus #include +#include #include #include #include +#endif #include -#include "mc_private.h" #include "mc_mmu.h" -#ifndef MC_PAGE_SNAPSHOT_H -#define MC_PAGE_SNAPSHOT_H +#ifndef MC_PAGE_STORE_H +#define MC_PAGE_STORE_H + +struct s_mc_pages_store; + +#ifdef __cplusplus /** @brief Storage for snapshot memory pages * @@ -73,13 +79,31 @@ * */ struct s_mc_pages_store { -private: // Types +public: // Types +#ifdef MC_PAGE_STORE_MD4 + typedef boost::array hash_type; +#else typedef uint64_t hash_type; - typedef boost ::unordered_set page_set_type; +#endif +private: // Types +#ifdef MC_PAGE_STORE_MD4 + // We are using a secure hash to identify a page. + // We assume there will not be any collision: we need to map a hash + // to a single page index. + typedef boost::unordered_map pages_map_type; +#else + // We are using a cheap hash to index a page. + // We should expect collision and we need to associate multiple page indices + // to the same hash. + typedef boost::unordered_set page_set_type; typedef boost::unordered_map pages_map_type; +#endif private: // Fields: - /** First page */ + /** First page + * + * mc_page_store_get_page expects that this is the first field. + * */ void* memory_; /** Number of available pages in virtual memory */ size_t capacity_; @@ -186,3 +210,22 @@ size_t s_mc_pages_store::capacity() { #endif +SG_BEGIN_DECL() + +typedef struct s_mc_pages_store s_mc_pages_store_t, * mc_pages_store_t; +mc_pages_store_t mc_pages_store_new(); +void mc_pages_store_delete(mc_pages_store_t store); + +/** + */ +static inline __attribute__((always_inline)) +const void* mc_page_store_get_page(mc_pages_store_t page_store, size_t pageno) +{ + // This is page_store->memory_: + void* memory = *(void**)page_store; + return mc_page_from_number(memory, pageno); +} + +SG_END_DECL() + +#endif