snapshot: use snapshot_space only in mprotect-based
authorBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 19:58:01 +0000 (12:58 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 19:58:01 +0000 (12:58 -0700)
We don't need this heap for fork-based snapshotting, so clearly separate
the functionality here.

This also makes PageAlignedAdressUpdate() available only for
mprotect-based snapshotting.

mymemory.h
snapshot.cc

index 2379b5f6c5deddae1b8fe79cd8eb0ff57be7faa4..0e274d2fa4cacc47c2ecdd557a4ae88f7e17b883 100644 (file)
@@ -7,6 +7,8 @@
 #include <stdlib.h>
 #include <limits>
 
+#include "config.h"
+
 /** MEMALLOC declares the allocators for a class to allocate
  *     memory in the non-snapshotting heap. */
 #define MEMALLOC \
@@ -152,8 +154,11 @@ extern void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);
 extern mspace create_mspace_with_base(void* base, size_t capacity, int locked);
 extern mspace create_mspace(size_t capacity, int locked);
 
+#if USE_MPROTECT_SNAPSHOT
 /** @brief mspace for the snapshotting heap */
 extern mspace snapshot_space;
+#endif
+
 #ifdef __cplusplus
 };  /* end of extern "C" */
 #endif
index a5f292f063e31a7eb45da0e0a8c916dbb6e9674c..0c90da839912c59ff1b5db675efec367796328bc 100644 (file)
@@ -45,7 +45,8 @@ struct SnapShot * snapshotrecord = NULL;
 static ucontext_t savedSnapshotContext;
 static ucontext_t savedUserSnapshotContext;
 static snapshot_id snapshotid = 0;
-#endif
+
+#else /* USE_MPROTECT_SNAPSHOT */
 
 /** PageAlignedAdressUpdate return a page aligned address for the
  * address being added as a side effect the numBytes are also changed.
@@ -54,8 +55,6 @@ static void * PageAlignAddressUpward(void * addr) {
        return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
 }
 
-#if USE_MPROTECT_SNAPSHOT
-
 /** ReturnPageAlignedAddress returns a page aligned address for the
  * address being added as a side effect the numBytes are also changed.
  */
@@ -109,7 +108,7 @@ static void HandlePF( int sig, siginfo_t *si, void * unused){
                // Handle error by quitting?
        }
 }
-#endif //nothing to handle for non snapshotting case.
+#endif /* USE_MPROTECT_SNAPSHOT */
 
 #if !USE_MPROTECT_SNAPSHOT
 void createSharedMemory(){