fix code to be 64 bit clean
[c11tester.git] / nodestack.h
1 #ifndef __NODESTACK_H__
2 #define __NODESTACK_H__
3
4 #include <list>
5 #include <vector>
6 #include <cstddef>
7 #include "threads.h"
8
9 class ModelAction;
10
11 class Node {
12 public:
13         Node(ModelAction *act = NULL, Node *parent = NULL);
14         ~Node();
15         /* return true = thread choice has already been explored */
16         bool has_been_explored(thread_id_t tid);
17         /* return true = backtrack set is empty */
18         bool backtrack_empty();
19         void explore_child(ModelAction *act);
20         /* return false = thread was already in backtrack */
21         bool set_backtrack(thread_id_t id);
22         thread_id_t get_next_backtrack();
23         bool is_enabled(Thread *t);
24         ModelAction * get_action() { return action; }
25
26         void print();
27
28         static int get_total_nodes() { return total_nodes; }
29 private:
30         void explore(thread_id_t tid);
31
32         static int total_nodes;
33         ModelAction *action;
34         int num_threads;
35         std::vector<bool> explored_children;
36         std::vector<bool> backtrack;
37 };
38
39 typedef std::list<class Node *> node_list_t;
40
41 class NodeStack {
42 public:
43         NodeStack();
44         ~NodeStack();
45         ModelAction * explore_action(ModelAction *act);
46         Node * get_head();
47         Node * get_next();
48         void reset_execution();
49
50         void print();
51 private:
52         node_list_t node_list;
53         node_list_t::iterator iter;
54 };
55
56 #endif /* __NODESTACK_H__ */