f9f0c41762d72c03cfd57c2f4b2b420e1d242462
[c11tester.git] / action.h
1 #ifndef __ACTION_H__
2 #define __ACTION_H__
3
4 #include <list>
5
6 #include "libthreads.h"
7 #include "libatomic.h"
8 #include "threads.h"
9
10 #define VALUE_NONE -1
11
12 typedef enum action_type {
13         THREAD_CREATE,
14         THREAD_YIELD,
15         THREAD_JOIN,
16         ATOMIC_READ,
17         ATOMIC_WRITE
18 } action_type_t;
19
20 /* Forward declaration (tree.h) */
21 class TreeNode;
22
23 class ModelAction {
24 public:
25         ModelAction(action_type_t type, memory_order order, void *loc, int value);
26         void print(void);
27
28         thread_id_t get_tid() { return tid; }
29         action_type get_type() { return type; }
30         memory_order get_mo() { return order; }
31         void * get_location() { return location; }
32
33         TreeNode * get_node() { return node; }
34         void set_node(TreeNode *n) { node = n; }
35
36         bool is_read();
37         bool is_write();
38         bool is_acquire();
39         bool is_release();
40         bool same_var(ModelAction *act);
41         bool same_thread(ModelAction *act);
42         bool is_dependent(ModelAction *act);
43 private:
44         action_type type;
45         memory_order order;
46         void *location;
47         thread_id_t tid;
48         int value;
49         TreeNode *node;
50 };
51
52 typedef std::list<class ModelAction *> action_list_t;
53
54 #endif /* __ACTION_H__ */