From d88196987e572dcb561e8b1eabb3409c4491d460 Mon Sep 17 00:00:00 2001 From: Brian Demsky Date: Thu, 24 May 2012 11:40:14 -0700 Subject: [PATCH] fix page alignment issue... --- mymemory.cc | 2 ++ mymemory.h | 1 + snapshot.cc | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mymemory.cc b/mymemory.cc index 9d598af..a825bb9 100644 --- a/mymemory.cc +++ b/mymemory.cc @@ -52,6 +52,8 @@ void MYFREE(void *ptr) { #endif } mspace mySpace = NULL; +void * basemySpace = NULL; + void *malloc( size_t size ) { return mspace_malloc( mySpace, size ); } diff --git a/mymemory.h b/mymemory.h index afaffa4..90b2784 100644 --- a/mymemory.h +++ b/mymemory.h @@ -122,6 +122,7 @@ extern void mspace_free(mspace msp, void* mem); extern mspace create_mspace_with_base(void* base, size_t capacity, int locked); extern mspace create_mspace(size_t capacity, int locked); extern mspace mySpace; +extern void * basemySpace; #ifdef __cplusplus }; /* end of extern "C" */ #endif diff --git a/snapshot.cc b/snapshot.cc index f5cefe6..83d22b4 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -137,8 +137,11 @@ void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots exit(-1); } initSnapShotRecord(numbackingpages, numsnapshots, nummemoryregions); - mySpace = create_mspace( numheappages*PAGESIZE, 1 ); - addMemoryRegionToSnapShot(mySpace, numheappages); + + basemySpace=MYMALLOC((numheappages+1)*PAGESIZE); + void * pagealignedbase=(void *)((((uintptr_t)basemySpace)+PAGESIZE-1)&~(PAGESIZE-1)); + mySpace = create_mspace_with_base(pagealignedbase, numheappages*PAGESIZE, 1 ); + addMemoryRegionToSnapShot(pagealignedbase, numheappages); entryPoint(); #else //add a signal to indicate that the process is going to terminate. -- 2.34.1