Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Expand unit test of mc_snapshot.c
[simgrid.git] / src / mc / mc_page_store.h
index 3caa885..8018016 100644 (file)
@@ -6,19 +6,24 @@
 
 #include <stdint.h>
 
+#ifdef __cplusplus
 #include <vector>
 
 #include <boost/utility.hpp>
 #include <boost/unordered_map.hpp>
 #include <boost/unordered_set.hpp>
+#endif
 
 #include <xbt.h>
 
-#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
  *
@@ -79,7 +84,10 @@ private: // Types
   typedef boost::unordered_map<hash_type, page_set_type> pages_map_type;
 
 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 +194,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