From: Brian Norris <banorris@uci.edu>
Date: Thu, 3 Jan 2013 01:48:28 +0000 (-0800)
Subject: dissolve snapshotimp.h
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f0f7b26d861767e59a07f3542cf810deb7dd52b0;p=cdsspec-compiler.git

dissolve snapshotimp.h

snapshotimp.h was being used as a way to expose some of the snapshotting
implementation to mymemory.cc, just for fork-based snapshotting. I've
removed that exposure, so now I can pull the entire header into
snapshot.cc.
---

diff --git a/mymemory.cc b/mymemory.cc
index 5c11d47..44985fa 100644
--- a/mymemory.cc
+++ b/mymemory.cc
@@ -7,7 +7,6 @@
 
 #include "mymemory.h"
 #include "snapshot.h"
-#include "snapshotimp.h"
 #include "common.h"
 
 #define REQUESTS_BEFORE_ALLOC 1024
diff --git a/snapshot.cc b/snapshot.cc
index e6b38b5..114473d 100644
--- a/snapshot.cc
+++ b/snapshot.cc
@@ -10,7 +10,6 @@
 
 #include "hashtable.h"
 #include "snapshot.h"
-#include "snapshotimp.h"
 #include "mymemory.h"
 #include "common.h"
 
@@ -22,8 +21,63 @@
 #define SSDEBUG(...)	do { } while (0)
 #endif
 
-/* extern declaration definition */
-struct SnapShot *snapshotrecord = NULL;
+#if USE_MPROTECT_SNAPSHOT
+/* Each snapshotrecord lists the firstbackingpage that must be written to
+ * revert to that snapshot */
+struct SnapShotRecord {
+	unsigned int firstBackingPage;
+};
+
+/** @brief Backing store page */
+typedef unsigned char snapshot_page_t[PAGESIZE];
+
+/* List the base address of the corresponding page in the backing store so we
+ * know where to copy it to */
+struct BackingPageRecord {
+	void *basePtrOfPage;
+};
+
+/* Struct for each memory region */
+struct MemoryRegion {
+	void *basePtr; // base of memory region
+	int sizeInPages; // size of memory region in pages
+};
+
+/* Primary struct for snapshotting system */
+struct SnapShot {
+	struct MemoryRegion *regionsToSnapShot; //This pointer references an array of memory regions to snapshot
+	snapshot_page_t *backingStore; //This pointer references an array of snapshotpage's that form the backing store
+	void *backingStoreBasePtr; //This pointer references an array of snapshotpage's that form the backing store
+	struct BackingPageRecord *backingRecords; //This pointer references an array of backingpagerecord's (same number of elements as backingstore
+	struct SnapShotRecord *snapShots; //This pointer references the snapshot array
+
+	unsigned int lastSnapShot; //Stores the next snapshot record we should use
+	unsigned int lastBackingPage; //Stores the next backingpage we should use
+	unsigned int lastRegion; //Stores the next memory region to be used
+
+	unsigned int maxRegions; //Stores the max number of memory regions we support
+	unsigned int maxBackingPages; //Stores the total number of backing pages
+	unsigned int maxSnapShots; //Stores the total number of snapshots we allow
+};
+
+#else
+
+#include <ucontext.h>
+
+#define SHARED_MEMORY_DEFAULT  (100 * ((size_t)1 << 20)) // 100mb for the shared memory
+#define STACK_SIZE_DEFAULT      (((size_t)1 << 20) * 20)  // 20 mb out of the above 100 mb for my stack
+
+struct SnapShot {
+	void *mSharedMemoryBase;
+	void *mStackBase;
+	size_t mStackSize;
+	volatile snapshot_id mIDToRollback;
+	ucontext_t mContextToRollback;
+	snapshot_id currSnapShotID;
+};
+#endif
+
+static struct SnapShot *snapshotrecord = NULL;
 
 /** PageAlignedAdressUpdate return a page aligned address for the
  * address being added as a side effect the numBytes are also changed.
diff --git a/snapshotimp.h b/snapshotimp.h
deleted file mode 100644
index 6efdbd9..0000000
--- a/snapshotimp.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/** @file snapshotimp.h
- *	@brief Snapshotting implementation header file..
- */
-
-#ifndef __SNAPSHOTIMP_H__
-#define __SNAPSHOTIMP_H__
-
-#include <stddef.h>
-
-#include "snapshot.h"
-
-#if USE_MPROTECT_SNAPSHOT
-//Each snapshotrecord lists the firstbackingpage that must be written to revert to that snapshot
-struct SnapShotRecord {
-	unsigned int firstBackingPage;
-};
-
-/** @brief Backing store page */
-typedef unsigned char snapshot_page_t[PAGESIZE];
-
-//List the base address of the corresponding page in the backing store so we know where to copy it to
-struct BackingPageRecord {
-	void *basePtrOfPage;
-};
-
-//Stuct for each memory region
-struct MemoryRegion {
-	void *basePtr; //base of memory region
-	int sizeInPages; //size of memory region in pages
-};
-
-//Primary struct for snapshotting system....
-struct SnapShot {
-	struct MemoryRegion *regionsToSnapShot; //This pointer references an array of memory regions to snapshot
-	snapshot_page_t *backingStore; //This pointer references an array of snapshotpage's that form the backing store
-	void *backingStoreBasePtr; //This pointer references an array of snapshotpage's that form the backing store
-	struct BackingPageRecord *backingRecords; //This pointer references an array of backingpagerecord's (same number of elements as backingstore
-	struct SnapShotRecord *snapShots; //This pointer references the snapshot array
-
-	unsigned int lastSnapShot; //Stores the next snapshot record we should use
-	unsigned int lastBackingPage; //Stores the next backingpage we should use
-	unsigned int lastRegion; //Stores the next memory region to be used
-
-	unsigned int maxRegions; //Stores the max number of memory regions we support
-	unsigned int maxBackingPages; //Stores the total number of backing pages
-	unsigned int maxSnapShots; //Stores the total number of snapshots we allow
-};
-
-#else
-
-#include <ucontext.h>
-
-#define SHARED_MEMORY_DEFAULT  (100 * ((size_t)1 << 20)) // 100mb for the shared memory
-#define STACK_SIZE_DEFAULT      (((size_t)1 << 20) * 20)  // 20 mb out of the above 100 mb for my stack
-
-struct SnapShot {
-	void *mSharedMemoryBase;
-	void *mStackBase;
-	size_t mStackSize;
-	volatile snapshot_id mIDToRollback;
-	ucontext_t mContextToRollback;
-	snapshot_id currSnapShotID;
-};
-#endif
-
-//Global reference to snapshot data structure
-extern struct SnapShot *snapshotrecord;
-
-#endif /* __SNAPSHOTIMP_H__ */