update Makefile
[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 ModelHistory {
13 public:
14         ModelHistory();
15         ~ModelHistory();
16
17         void enter_function(const uint32_t func_id, thread_id_t tid);
18         void exit_function(const uint32_t func_id, thread_id_t tid);
19
20         uint32_t get_func_counter() { return func_counter; }
21         void incr_func_counter() { func_counter++; }
22
23         void add_func_atomic(ModelAction *act, thread_id_t tid);
24
25         HashTable<const char *, uint32_t, uintptr_t, 4> * getFuncMap() { return &func_map; }
26         ModelVector< action_mlist_t * > * getFuncAtomics() { return &func_atomics; }
27
28         void print();
29 private:
30         uint32_t func_counter;
31
32         /* map function names to integer ids */ 
33         HashTable<const char *, uint32_t, uintptr_t, 4> func_map;
34
35         ModelVector< action_mlist_t * > func_atomics;
36
37         /* Work_list stores a list of function ids for each thread. 
38          * Each element in work_list is intended to be used as a stack storing
39          * the functions that thread i has entered and yet to exit from 
40          */
41         SnapVector< func_id_list_t * > work_list;
42 };