fixup 'int' vs. 'thread_id_t' usage
[c11tester.git] / nodestack.cc
index 72c8d5cf5e46f7dca4241aa12f26958439ad15c3..7471c744d1a19e5b57c3ebce764fbb754dc79b86 100644 (file)
@@ -4,7 +4,7 @@
 #include "action.h"
 #include "common.h"
 #include "model.h"
-#include "threads.h"
+#include "threads-model.h"
 
 /**
  * @brief Node constructor
@@ -34,7 +34,9 @@ Node::Node(ModelAction *act, Node *par, int nthreads, Node *prevfairness)
        future_values(),
        future_index(-1),
        relseq_break_writes(),
-       relseq_break_index(0)
+       relseq_break_index(0),
+       misc_index(0),
+       misc_max(0)
 {
        if (act) {
                act->set_node(this);
@@ -49,7 +51,7 @@ Node::Node(ModelAction *act, Node *par, int nthreads, Node *prevfairness)
                                if (prevfi) {
                                        *fi=*prevfi;
                                }
-                               if (parent->enabled_array[i]==THREAD_ENABLED) {
+                               if (parent->is_enabled(int_to_id(i))) {
                                        fi->enabled_count++;
                                }
                                if (i==currtid) {
@@ -58,7 +60,7 @@ Node::Node(ModelAction *act, Node *par, int nthreads, Node *prevfairness)
                                }
                                //Do window processing
                                if (prevfairness != NULL) {
-                                       if (prevfairness -> parent->enabled_array[i] == THREAD_ENABLED)
+                                       if (prevfairness -> parent->is_enabled(int_to_id(i)))
                                                fi->enabled_count--;
                                        if (i==prevtid) {
                                                fi->turns--;
@@ -151,6 +153,24 @@ bool Node::promise_empty() {
        return true;
 }
 
+
+void Node::set_misc_max(int i) {
+       misc_max=i;
+}
+
+int Node::get_misc() {
+       return misc_index;
+}
+
+bool Node::increment_misc() {
+       return (misc_index<misc_max)&&((++misc_index)<misc_max);
+}
+
+bool Node::misc_empty() {
+       return (misc_index+1)>=misc_max;
+}
+
+
 /**
  * Adds a value from a weakly ordered future write to backtrack to.
  * @param value is the value to backtrack to.
@@ -267,13 +287,13 @@ thread_id_t Node::get_next_backtrack()
 bool Node::is_enabled(Thread *t)
 {
        int thread_id=id_to_int(t->get_id());
-       return thread_id < num_threads && (enabled_array[thread_id] == THREAD_ENABLED);
+       return thread_id < num_threads && (enabled_array[thread_id] != THREAD_DISABLED);
 }
 
 bool Node::is_enabled(thread_id_t tid)
 {
        int thread_id=id_to_int(tid);
-       return thread_id < num_threads && (enabled_array[thread_id] == THREAD_ENABLED);
+       return thread_id < num_threads && (enabled_array[thread_id] != THREAD_DISABLED);
 }
 
 bool Node::has_priority(thread_id_t tid)