Move some implementation details back to snapshot.cc.
ptr = callocp(count, size);
return ptr;
#else
- if (!snapshotrecord)
- createSharedMemory();
if (!sStaticSpace)
- sStaticSpace = create_mspace_with_base((void *)(snapshotrecord->mSharedMemoryBase), SHARED_MEMORY_DEFAULT - sizeof(struct SnapShot), 1);
+ sStaticSpace = create_shared_mspace();
return mspace_calloc(sStaticSpace, count, size);
#endif
}
ptr = mallocp(size);
return ptr;
#else
- if (!snapshotrecord)
- createSharedMemory();
if (!sStaticSpace)
- sStaticSpace = create_mspace_with_base((void *)(snapshotrecord->mSharedMemoryBase), SHARED_MEMORY_DEFAULT - sizeof(struct SnapShot), 1);
+ sStaticSpace = create_shared_mspace();
return mspace_malloc(sStaticSpace, size);
#endif
}
#endif /* USE_MPROTECT_SNAPSHOT */
#if !USE_MPROTECT_SNAPSHOT
-void createSharedMemory()
+static void createSharedMemory()
{
//step 1. create shared memory.
void *memMapBase = mmap(0, SHARED_MEMORY_DEFAULT + STACK_SIZE_DEFAULT, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
snapshotrecord->mIDToRollback = -1;
snapshotrecord->currSnapShotID = 0;
}
+
+/**
+ * Create a new mspace pointer for the non-snapshotting (i.e., inter-process
+ * shared) memory region. Only for fork-based snapshotting.
+ *
+ * @return The shared memory mspace
+ */
+mspace create_shared_mspace()
+{
+ if (!snapshotrecord)
+ createSharedMemory();
+ return create_mspace_with_base((void *)(snapshotrecord->mSharedMemoryBase), SHARED_MEMORY_DEFAULT - sizeof(struct SnapShot), 1);
+}
#endif
#include "snapshot-interface.h"
#include "config.h"
+#include "mymemory.h"
void addMemoryRegionToSnapShot(void *ptr, unsigned int numPages);
snapshot_id takeSnapshot();
void rollBack(snapshot_id theSnapShot);
#if !USE_MPROTECT_SNAPSHOT
-void createSharedMemory();
+mspace create_shared_mspace();
#endif
#endif