Complete the transfer of deletions of some actions
[c11tester.git] / action.cc
index 16dcc5cde20afc4f5f3bf7a27d900fba52c5da0e..ee980b875988b362a2f6c3402be8dc5e795b69d7 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -41,14 +41,17 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
        trace_ref(NULL),
        thrdmap_ref(NULL),
        action_ref(NULL),
+       func_ref_count(0),
        value(value),
        type(type),
+       original_type(ATOMIC_NOP),
+       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
 {
        /* References to NULL atomic variables can end up here */
-       ASSERT(loc || type == ATOMIC_FENCE);
+       ASSERT(loc || type == ATOMIC_FENCE || type == ATOMIC_NOP);
 
        Thread *t = thread ? thread : thread_current();
        this->tid = t!= NULL ? t->get_id() : -1;
@@ -75,8 +78,11 @@ ModelAction::ModelAction(action_type_t type, memory_order order, uint64_t value,
        trace_ref(NULL),
        thrdmap_ref(NULL),
        action_ref(NULL),
+       func_ref_count(0),
        value(value),
        type(type),
+       original_type(ATOMIC_NOP),
+       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -108,8 +114,11 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
        trace_ref(NULL),
        thrdmap_ref(NULL),
        action_ref(NULL),
+       func_ref_count(0),
        value(value),
        type(type),
+       original_type(ATOMIC_NOP),
+       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -145,8 +154,11 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order
        trace_ref(NULL),
        thrdmap_ref(NULL),
        action_ref(NULL),
+       func_ref_count(0),
        value(value),
        type(type),
+       original_type(ATOMIC_NOP),
+       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -183,8 +195,11 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order
        trace_ref(NULL),
        thrdmap_ref(NULL),
        action_ref(NULL),
+       func_ref_count(0),
        value(value),
        type(type),
+       original_type(ATOMIC_NOP),
+       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -772,3 +787,16 @@ cdsc::mutex * ModelAction::get_mutex() const
        else
                return NULL;
 }
+
+/** @brief Swap type with original type */
+void ModelAction::use_original_type()
+{
+       action_type_t tmp = type;
+       type = original_type;
+       original_type = tmp;
+
+       if (swap_flag)
+               swap_flag = false;
+       else
+               swap_flag = true;
+}