{
snapshotrecord = (struct SnapShot *)model_malloc(sizeof(struct SnapShot));
snapshotrecord->regionsToSnapShot = (struct MemoryRegion *)model_malloc(sizeof(struct MemoryRegion) * nummemoryregions);
- snapshotrecord->backingStoreBasePtr = (struct SnapShotPage *)model_malloc(sizeof(struct SnapShotPage) * (numbackingpages + 1));
+ snapshotrecord->backingStoreBasePtr = (void *)model_malloc(sizeof(snapshot_page_t) * (numbackingpages + 1));
//Page align the backingstorepages
- snapshotrecord->backingStore = (struct SnapShotPage *)PageAlignAddressUpward(snapshotrecord->backingStoreBasePtr);
+ snapshotrecord->backingStore = (snapshot_page_t *)PageAlignAddressUpward(snapshotrecord->backingStoreBasePtr);
snapshotrecord->backingRecords = (struct BackingPageRecord *)model_malloc(sizeof(struct BackingPageRecord) * numbackingpages);
snapshotrecord->snapShots = (struct SnapShotRecord *)model_malloc(sizeof(struct SnapShotRecord) * numsnapshots);
snapshotrecord->lastSnapShot = 0;
}
//copy page
- memcpy(&(snapshotrecord->backingStore[backingpage]), addr, sizeof(struct SnapShotPage));
+ memcpy(&(snapshotrecord->backingStore[backingpage]), addr, sizeof(snapshot_page_t));
//remember where to copy page back to
snapshotrecord->backingRecords[backingpage].basePtrOfPage = addr;
//set protection to read/write
- if (mprotect(addr, sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE)) {
+ if (mprotect(addr, sizeof(snapshot_page_t), PROT_READ | PROT_WRITE)) {
perror("mprotect");
// Handle error by quitting?
}
{
#if USE_MPROTECT_SNAPSHOT
for (unsigned int region = 0; region < snapshotrecord->lastRegion; region++) {
- if (mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages * sizeof(struct SnapShotPage), PROT_READ) == -1) {
+ if (mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages * sizeof(snapshot_page_t), PROT_READ) == -1) {
perror("mprotect");
model_print("Failed to mprotect inside of takeSnapShot\n");
exit(EXIT_FAILURE);
#if USE_MPROTECT_SNAPSHOT == 2
if (snapshotrecord->lastSnapShot == (theID + 1)) {
for (unsigned int page = snapshotrecord->snapShots[theID].firstBackingPage; page < snapshotrecord->lastBackingPage; page++) {
- memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage));
+ memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(snapshot_page_t));
}
return;
}
#if USE_MPROTECT_SNAPSHOT
HashTable< void *, bool, uintptr_t, 4, model_malloc, model_calloc, model_free> duplicateMap;
for (unsigned int region = 0; region < snapshotrecord->lastRegion; region++) {
- if (mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages * sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE) == -1) {
+ if (mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages * sizeof(snapshot_page_t), PROT_READ | PROT_WRITE) == -1) {
perror("mprotect");
model_print("Failed to mprotect inside of takeSnapShot\n");
exit(EXIT_FAILURE);
for (unsigned int page = snapshotrecord->snapShots[theID].firstBackingPage; page < snapshotrecord->lastBackingPage; page++) {
if (!duplicateMap.contains(snapshotrecord->backingRecords[page].basePtrOfPage)) {
duplicateMap.put(snapshotrecord->backingRecords[page].basePtrOfPage, true);
- memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage));
+ memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(snapshot_page_t));
}
}
snapshotrecord->lastSnapShot = theID;