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