From f01c21655bce58ff70b0e8936f2579a7beeafad4 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 1 Oct 2012 18:16:24 -0700 Subject: [PATCH] rename MYMALLOC -> model_malloc --- cyclegraph.cc | 2 +- mymemory.cc | 2 +- mymemory.h | 8 ++++---- nodestack.cc | 2 +- snapshot-interface.cc | 2 +- snapshot.cc | 16 ++++++++-------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cyclegraph.cc b/cyclegraph.cc index 2bfe76a..ae80fcf 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -170,7 +170,7 @@ bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) */ bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) { std::vector > queue; - HashTable discovered; + HashTable discovered; queue.push_back(from); discovered.put(from, from); diff --git a/mymemory.cc b/mymemory.cc index b702d39..4b393cb 100644 --- a/mymemory.cc +++ b/mymemory.cc @@ -41,7 +41,7 @@ void *MYCALLOC(size_t count, size_t size) { } /** Non-snapshotting malloc for our use. */ -void *MYMALLOC(size_t size) { +void *model_malloc(size_t size) { #if USE_MPROTECT_SNAPSHOT static void *(*mallocp)(size_t size)=NULL; char *error; diff --git a/mymemory.h b/mymemory.h index 3059e69..21f636f 100644 --- a/mymemory.h +++ b/mymemory.h @@ -11,13 +11,13 @@ * memory in the non-snapshotting heap. */ #define MEMALLOC \ void * operator new(size_t size) { \ - return MYMALLOC(size);\ + return model_malloc(size);\ }\ void operator delete(void *p, size_t size) { \ MYFREE( p ); \ }\ void * operator new[](size_t size) { \ - return MYMALLOC(size);\ + return model_malloc(size);\ }\ void operator delete[](void *p, size_t size) {\ MYFREE(p);\ @@ -27,7 +27,7 @@ * memory in the snapshotting heap. */ #define SNAPSHOTALLOC -void *MYMALLOC(size_t size); +void *model_malloc(size_t size); void *MYCALLOC(size_t count, size_t size); void MYFREE(void *ptr); @@ -100,7 +100,7 @@ template // allocate but don't initialize num elements of type T pointer allocate (size_type num, const void* = 0) { - pointer p = ( pointer )MYMALLOC( num * sizeof( T ) ); + pointer p = ( pointer )model_malloc( num * sizeof( T ) ); return p; } diff --git a/nodestack.cc b/nodestack.cc index 136e3a2..e59b995 100644 --- a/nodestack.cc +++ b/nodestack.cc @@ -218,7 +218,7 @@ bool Node::read_from_empty() { void Node::explore_child(ModelAction *act, bool * is_enabled) { if ( ! enabled_array ) - enabled_array=(bool *)MYMALLOC(sizeof(bool)*num_threads); + enabled_array=(bool *)model_malloc(sizeof(bool)*num_threads); if (is_enabled != NULL) memcpy(enabled_array, is_enabled, sizeof(bool)*num_threads); else { diff --git a/snapshot-interface.cc b/snapshot-interface.cc index d93e5c2..8d7591b 100644 --- a/snapshot-interface.cc +++ b/snapshot-interface.cc @@ -130,7 +130,7 @@ int SnapshotStack::backTrackBeforeStep(int seqindex) { /** This method takes a snapshot at the given sequence number. */ void SnapshotStack::snapshotStep(int seqindex) { - struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry)); + struct stackEntry *tmp=(struct stackEntry *)model_malloc(sizeof(struct stackEntry)); tmp->next=stack; tmp->index=seqindex; tmp->snapshotid=takeSnapshot(); diff --git a/snapshot.cc b/snapshot.cc index b7e4ec1..642885b 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -67,13 +67,13 @@ static void * ReturnPageAlignedAddress(void * addr) { * structures for the mprotect based snapshot. */ static void initSnapShotRecord(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions) { - snapshotrecord=( struct SnapShot * )MYMALLOC(sizeof(struct SnapShot)); - snapshotrecord->regionsToSnapShot=( struct MemoryRegion * )MYMALLOC(sizeof(struct MemoryRegion)*nummemoryregions); - snapshotrecord->backingStoreBasePtr= ( struct SnapShotPage * )MYMALLOC( sizeof( struct SnapShotPage ) * (numbackingpages + 1) ); + 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) ); //Page align the backingstorepages snapshotrecord->backingStore=( struct SnapShotPage * )PageAlignAddressUpward(snapshotrecord->backingStoreBasePtr); - snapshotrecord->backingRecords=( struct BackingPageRecord * )MYMALLOC(sizeof(struct BackingPageRecord)*numbackingpages); - snapshotrecord->snapShots= ( struct SnapShotRecord * )MYMALLOC(sizeof(struct SnapShotRecord)*numsnapshots); + snapshotrecord->backingRecords=( struct BackingPageRecord * )model_malloc(sizeof(struct BackingPageRecord)*numbackingpages); + snapshotrecord->snapShots= ( struct SnapShotRecord * )model_malloc(sizeof(struct SnapShotRecord)*numsnapshots); snapshotrecord->lastSnapShot=0; snapshotrecord->lastBackingPage=0; snapshotrecord->lastRegion=0; @@ -139,7 +139,7 @@ void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numheappages, VoidFuncPtr entryPoint) { /* Setup a stack for our signal handler.... */ stack_t ss; - ss.ss_sp = MYMALLOC(SIGSTACKSIZE); + ss.ss_sp = model_malloc(SIGSTACKSIZE); ss.ss_size = SIGSTACKSIZE; ss.ss_flags = 0; sigaltstack(&ss, NULL); @@ -171,7 +171,7 @@ void initSnapShotLibrary(unsigned int numbackingpages, HandlePF(SIGSEGV, &si, NULL); snapshotrecord->lastBackingPage--; //remove the fake page we copied - basemySpace=MYMALLOC((numheappages+1)*PAGESIZE); + basemySpace=model_malloc((numheappages+1)*PAGESIZE); void * pagealignedbase=PageAlignAddressUpward(basemySpace); mySpace = create_mspace_with_base(pagealignedbase, numheappages*PAGESIZE, 1 ); addMemoryRegionToSnapShot(pagealignedbase, numheappages); @@ -284,7 +284,7 @@ snapshot_id takeSnapshot( ){ */ void rollBack( snapshot_id theID ){ #if USE_MPROTECT_SNAPSHOT - HashTable< void *, bool, uintptr_t, 4, MYMALLOC, MYCALLOC, MYFREE> duplicateMap; + HashTable< void *, bool, uintptr_t, 4, model_malloc, MYCALLOC, MYFREE> duplicateMap; for(unsigned int region=0; regionlastRegion;region++) { if( mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages*sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE ) == -1 ){ perror("mprotect"); -- 2.34.1