fix indentation + spacing, esp. for MEMALLOC macro
[model-checker.git] / model.h
1 #ifndef __MODEL_H__
2 #define __MODEL_H__
3
4 #include <list>
5 #include <map>
6 #include <vector>
7 #include <cstddef>
8 #include <ucontext.h>
9
10 #include "schedule.h"
11 #include "mymemory.h"
12 #include <utility>
13 #include "libthreads.h"
14 #include "libatomic.h"
15 #include "threads.h"
16 #include "action.h"
17
18 /* Forward declaration */
19 class NodeStack;
20
21 class ModelChecker {
22 public:
23         ModelChecker();
24         ~ModelChecker();
25         class Scheduler *scheduler;
26
27         void set_system_context(ucontext_t *ctxt) { system_context = ctxt; }
28         ucontext_t * get_system_context(void) { return system_context; }
29
30         void set_current_action(ModelAction *act) { current_action = act; }
31         void check_current_action(void);
32         void print_summary(void);
33         Thread * schedule_next_thread();
34
35         int add_thread(Thread *t);
36         void remove_thread(Thread *t);
37         Thread * get_thread(thread_id_t tid) { return thread_map[id_to_int(tid)]; }
38
39         thread_id_t get_next_id();
40         int get_next_seq_num();
41
42         int switch_to_master(ModelAction *act);
43
44         bool next_execution();
45
46         MEMALLOC
47 private:
48         int next_thread_id;
49         int used_sequence_numbers;
50         int num_executions;
51
52         ModelAction * get_last_conflict(ModelAction *act);
53         void set_backtracking(ModelAction *act);
54         thread_id_t get_next_replay_thread();
55         ModelAction * get_next_backtrack();
56         void reset_to_initial_state();
57
58         void print_list(action_list_t *list);
59
60         ModelAction *current_action;
61         ModelAction *diverge;
62         thread_id_t nextThread;
63
64         ucontext_t *system_context;
65         action_list_t *action_trace;
66         std::map<int, class Thread *, std::less< int >, MyAlloc< std::pair< const int, class Thread * > > > thread_map;
67         class NodeStack *node_stack;
68         ModelAction *next_backtrack;
69 };
70
71 extern ModelChecker *model;
72
73 #endif /* __MODEL_H__ */