snapshot: define macros with type size_t
authorBrian Norris <banorris@uci.edu>
Thu, 14 Jun 2012 16:22:31 +0000 (09:22 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 14 Jun 2012 16:22:31 +0000 (09:22 -0700)
The SHARED_MEMORY_DEFAULT and STACK_SIZE_DEFAULT macros need to be of type
size_t, so cast them when they're defined, not when they're used.

snapshot.cc
snapshotimp.h

index af4284361d61f076c16c12675945ec5d364b968c..01811ca862621f616f670ea2a35df7889e746302 100644 (file)
@@ -107,12 +107,12 @@ void createSharedLibrary(){
        if( sTheRecord ) return;
        int fd = shm_open( "/ModelChecker-Snapshotter", O_RDWR | O_CREAT, 0777 ); //universal permissions.
        if( -1 == fd ) FAILURE("shm_open");
-       if( -1 == ftruncate( fd, ( size_t )SHARED_MEMORY_DEFAULT + ( size_t )STACK_SIZE_DEFAULT ) ) FAILURE( "ftruncate" );
-       void * memMapBase = mmap( 0, ( size_t )SHARED_MEMORY_DEFAULT + ( size_t )STACK_SIZE_DEFAULT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
+       if( -1 == ftruncate( fd, SHARED_MEMORY_DEFAULT + STACK_SIZE_DEFAULT ) ) FAILURE( "ftruncate" );
+       void * memMapBase = mmap( 0, SHARED_MEMORY_DEFAULT + STACK_SIZE_DEFAULT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
        if( MAP_FAILED == memMapBase ) FAILURE("mmap");
        sTheRecord = ( struct Snapshot * )memMapBase;
        sTheRecord->mSharedMemoryBase = (void *)((uintptr_t)memMapBase + sizeof(struct Snapshot));
-       sTheRecord->mStackBase = (void *)((uintptr_t)memMapBase + (size_t)SHARED_MEMORY_DEFAULT);
+       sTheRecord->mStackBase = (void *)((uintptr_t)memMapBase + SHARED_MEMORY_DEFAULT);
        sTheRecord->mStackSize = STACK_SIZE_DEFAULT;
        sTheRecord->mIDToRollback = -1;
        sTheRecord->currSnapShotID = 0;
index ce7bb3188872881237da09e705f0b625bdc2744c..656c2c58ec3df3f3acb395efb8058dd3a832c5fb 100644 (file)
@@ -11,8 +11,8 @@
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <csignal>
-#define SHARED_MEMORY_DEFAULT ( 100 * ( 1 << 20 ) ) // 100mb for the shared memory
-#define STACK_SIZE_DEFAULT  ( ( 1 << 20 ) * 20 ) //20 mb out of the above 100 mb for my stack.
+#define SHARED_MEMORY_DEFAULT  (100 * ((size_t)1 << 20)) // 100mb for the shared memory
+#define STACK_SIZE_DEFAULT      (((size_t)1 << 20) * 20)  // 20 mb out of the above 100 mb for my stack
 
 #if USE_MPROTECT_SNAPSHOT
 //Each snapshotrecord lists the firstbackingpage that must be written to revert to that snapshot