snapshot: remove 'extern "C"' block
authorBrian Norris <banorris@uci.edu>
Thu, 14 Jun 2012 06:28:10 +0000 (23:28 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 14 Jun 2012 06:32:16 +0000 (23:32 -0700)
We do not need to wrap this function in 'extern "C"' for two reasons:

1) It's not actually exported and used in C code
2) You only need this sort of declaration in the header file that may be
   included in both C++ and C compilation. But snapshot.cc should only be
   compiled by the C++ compiler, and snapshot.h is not included in any C
   compilation.

snapshot.cc
snapshot.h

index 51d2a3adbb4842902db2fab53ceda4f61dbb48d9..65a7e213132d894adada96d310919a33f4bebbda 100644 (file)
@@ -106,30 +106,24 @@ void * ReturnPageAlignedAddress(void * addr) {
 void * PageAlignAddressUpward(void * addr) {
        return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
 }
-#ifdef __cplusplus
-extern "C" {
-#endif
-       void createSharedLibrary(){
+void createSharedLibrary(){
 #if !USE_MPROTECT_SNAPSHOT
-               //step 1. create shared memory.
-               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" );
-               char * memMapBase = ( char * ) mmap( 0, ( size_t )SHARED_MEMORY_DEFAULT + ( size_t )STACK_SIZE_DEFAULT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
-               if( MAP_FAILED == memMapBase ) FAILURE("mmap");
-               sTheRecord = ( struct Snapshot_t * )memMapBase;
-               sTheRecord->mSharedMemoryBase = memMapBase + sizeof( struct Snapshot_t );
-               sTheRecord->mStackBase = ( char * )memMapBase + ( size_t )SHARED_MEMORY_DEFAULT;
-               sTheRecord->mStackSize = STACK_SIZE_DEFAULT;
-               sTheRecord->mIDToRollback = -1;
-               sTheRecord->currSnapShotID = 0;
-               sTheRecord->mbFinalize = false;
+       //step 1. create shared memory.
+       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" );
+       char * memMapBase = ( char * ) mmap( 0, ( size_t )SHARED_MEMORY_DEFAULT + ( size_t )STACK_SIZE_DEFAULT, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
+       if( MAP_FAILED == memMapBase ) FAILURE("mmap");
+       sTheRecord = ( struct Snapshot_t * )memMapBase;
+       sTheRecord->mSharedMemoryBase = memMapBase + sizeof( struct Snapshot_t );
+       sTheRecord->mStackBase = ( char * )memMapBase + ( size_t )SHARED_MEMORY_DEFAULT;
+       sTheRecord->mStackSize = STACK_SIZE_DEFAULT;
+       sTheRecord->mIDToRollback = -1;
+       sTheRecord->currSnapShotID = 0;
+       sTheRecord->mbFinalize = false;
 #endif
-       }
-#ifdef __cplusplus
 }
-#endif
 
 /** The initSnapShotLibrary function initializes the Snapshot library.
  *  @param entryPoint the function that should run the program.
index 03e020e801b55e781e2a88d5503b03b23c1a3d1c..cbbe0070fb92328f6690ba604cebbb19f8466fce 100644 (file)
@@ -22,11 +22,6 @@ snapshot_id takeSnapshot( );
 
 void rollBack( snapshot_id theSnapShot );
 
-#ifdef __cplusplus
-extern "C" {
-#endif
 void createSharedLibrary();
-#ifdef __cplusplus
-};  /* end of extern "C" */
-#endif
+
 #endif