remove libatomic
[c11tester.git] / cyclegraph.h
1 #ifndef CYCLEGRAPH_H
2 #define CYCLEGRAPH_H
3
4 #include "hashtable.h"
5 #include <vector>
6 #include <inttypes.h>
7
8 class CycleNode;
9 class ModelAction;
10
11 /** @brief A graph of Model Actions for tracking cycles. */
12 class CycleGraph {
13  public:
14         CycleGraph();
15         ~CycleGraph();
16         void addEdge(const ModelAction *from, const ModelAction *to);
17         bool checkForCycles();
18         void addRMWEdge(const ModelAction *from, const ModelAction *to);
19
20  private:
21         CycleNode * getNode(const ModelAction *);
22         HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
23         bool checkReachable(CycleNode *from, CycleNode *to);
24         bool hasCycles;
25 };
26
27 class CycleNode {
28  public:
29         CycleNode(const ModelAction *action);
30         void addEdge(CycleNode * node);
31         std::vector<CycleNode *> * getEdges();
32         bool setRMW();
33
34  private:
35         const ModelAction *action;
36         std::vector<CycleNode *> edges;
37         bool hasRMW;
38 };
39
40 #endif