test: add "double release sequence" test
[model-checker.git] / cmodelint.cc
1 #include "model.h"
2 #include "cmodelint.h"
3 #include "threads.h"
4
5 /** Performs a read action.*/
6 uint64_t model_read_action(void * obj, memory_order ord) {
7         model->switch_to_master(new ModelAction(ATOMIC_READ, ord, obj));
8         return thread_current()->get_return_value();
9 }
10
11 /** Performs a write action.*/
12 void model_write_action(void * obj, memory_order ord, uint64_t val) {
13         model->switch_to_master(new ModelAction(ATOMIC_WRITE, ord, obj, val));
14 }
15
16 /** Performs an init action. */
17 void model_init_action(void * obj, uint64_t val) {
18         model->switch_to_master(new ModelAction(ATOMIC_INIT, memory_order_relaxed, obj, val));
19 }
20
21 /**
22  * Performs the read part of a RMW action. The next action must either be the
23  * write part of the RMW action or an explicit close out of the RMW action w/o
24  * a write.
25  */
26 uint64_t model_rmwr_action(void *obj, memory_order ord) {
27         model->switch_to_master(new ModelAction(ATOMIC_RMWR, ord, obj));
28         return thread_current()->get_return_value();
29 }
30
31 /** Performs the write part of a RMW action. */
32 void model_rmw_action(void *obj, memory_order ord, uint64_t val) {
33         model->switch_to_master(new ModelAction(ATOMIC_RMW, ord, obj, val));
34 }
35
36 /** Closes out a RMW action without doing a write. */
37 void model_rmwc_action(void *obj, memory_order ord) {
38         model->switch_to_master(new ModelAction(ATOMIC_RMWC, ord, obj));
39 }
40
41 /** Issues a fence operation. */
42 void model_fence_action(memory_order ord) {
43         model->switch_to_master(new ModelAction(ATOMIC_FENCE, ord, NULL));
44 }