dataraces: don't print an uninformative "Data race" bug msg
[c11tester.git] / snapshotimp.h
1 /** @file snapshotimp.h
2  *      @brief Snapshotting implementation header file..
3  */
4
5 #ifndef _SNAPSHOTIMP_H
6 #define _SNAPSHOTIMP_H
7 #include "snapshot.h"
8 #include <iostream>
9 #include <inttypes.h>
10 #include <fcntl.h>
11 #include <sys/mman.h>
12 #include <csignal>
13 #define SHARED_MEMORY_DEFAULT  (100 * ((size_t)1 << 20)) // 100mb for the shared memory
14 #define STACK_SIZE_DEFAULT      (((size_t)1 << 20) * 20)  // 20 mb out of the above 100 mb for my stack
15
16 #if USE_MPROTECT_SNAPSHOT
17 //Each snapshotrecord lists the firstbackingpage that must be written to revert to that snapshot
18 struct SnapShotRecord {
19         unsigned int firstBackingPage;
20 };
21
22 //Backing store page struct
23 struct SnapShotPage {
24         char data[PAGESIZE];
25 };
26
27 //List the base address of the corresponding page in the backing store so we know where to copy it to
28 struct BackingPageRecord {
29         void * basePtrOfPage;
30 };
31
32 //Stuct for each memory region
33 struct MemoryRegion {
34         void * basePtr; //base of memory region
35         int sizeInPages; //size of memory region in pages
36 };
37
38 //Primary struct for snapshotting system....
39 struct SnapShot {
40         struct MemoryRegion * regionsToSnapShot; //This pointer references an array of memory regions to snapshot
41         struct SnapShotPage * backingStore; //This pointer references an array of snapshotpage's that form the backing store
42         void * backingStoreBasePtr; //This pointer references an array of snapshotpage's that form the backing store
43         struct BackingPageRecord * backingRecords; //This pointer references an array of backingpagerecord's (same number of elements as backingstore
44         struct SnapShotRecord * snapShots; //This pointer references the snapshot array
45
46         unsigned int lastSnapShot; //Stores the next snapshot record we should use
47         unsigned int lastBackingPage; //Stores the next backingpage we should use
48         unsigned int lastRegion; //Stores the next memory region to be used
49
50         unsigned int maxRegions; //Stores the max number of memory regions we support
51         unsigned int maxBackingPages; //Stores the total number of backing pages
52         unsigned int maxSnapShots; //Stores the total number of snapshots we allow
53 };
54
55 #else
56 struct SnapShot {
57         void *mSharedMemoryBase;
58         void *mStackBase;
59         size_t mStackSize;
60         volatile snapshot_id mIDToRollback;
61         ucontext_t mContextToRollback;
62         snapshot_id currSnapShotID;
63 };
64 #endif
65
66 //Global reference to snapshot data structure
67 extern struct SnapShot * snapshotrecord;
68 #endif