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