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