change func_atomics and work_list to vectors
[c11tester.git] / history.h
1 #include "stl-model.h"
2 #include "common.h"
3 #include "hashtable.h"
4 #include "threads-model.h"
5
6 /* forward declaration */
7 class ModelAction;
8
9 typedef ModelList<const ModelAction *> action_mlist_t;
10 typedef SnapList<uint32_t> func_id_list_t;
11
12 class HistoryNode {
13 public: 
14         HistoryNode(ModelAction *act);
15         ~HistoryNode();
16
17         ModelAction * get_action() const { return action; }
18         const char * get_position() const { return position; }
19 private:
20         ModelAction * const action;
21         const char * position;
22 };
23
24 class ModelHistory {
25 public:
26         ModelHistory();
27         ~ModelHistory();
28
29         void enter_function(const uint32_t func_id, thread_id_t tid);
30         void exit_function(const uint32_t func_id, thread_id_t tid);
31
32         uint32_t get_func_counter() { return func_counter; }
33         void incr_func_counter() { func_counter++; }
34
35         void add_func_atomic(ModelAction *act, thread_id_t tid);
36
37         HashTable<const char *, uint32_t, uintptr_t, 4> * getFuncMap() { return &func_map; }
38         ModelVector< action_mlist_t * > * getFuncAtomics() { return &func_atomics; }
39
40         void print();
41 private:
42         uint32_t func_counter;
43
44         /* map function names to integer ids */ 
45         HashTable<const char *, uint32_t, uintptr_t, 4> func_map;
46
47         ModelVector< action_mlist_t * > func_atomics;
48
49         /* Work_list stores a list of function ids for each thread. 
50          * Each element in work_list is intended to be used as a stack storing
51          * the functions that thread i has entered and yet to exit from 
52          */
53         SnapVector< func_id_list_t * > work_list;
54 };