Remove unused headers
[c11tester.git] / clockvector.cc
index 2336df2f4720f6bea613891859591ddf47488fc3..ba5d1f4b2e627a76e41a8e40589b833fc00dd584 100644 (file)
@@ -24,7 +24,7 @@ ClockVector::ClockVector(ClockVector *parent, const ModelAction *act)
 
        clock = (modelclock_t *)snapshot_calloc(num_threads, sizeof(int));
        if (parent)
-               std::memcpy(clock, parent->clock, parent->num_threads * sizeof(modelclock_t));
+               real_memcpy(clock, parent->clock, parent->num_threads * sizeof(modelclock_t));
 
        if (act != NULL)
                clock[id_to_int(act->get_tid())] = act->get_seq_number();
@@ -62,6 +62,32 @@ bool ClockVector::merge(const ClockVector *cv)
        return changed;
 }
 
+/**
+ * Merge a clock vector into this vector, using a pairwise comparison. The
+ * resulting vector length will be the maximum length of the two being merged.
+ * @param cv is the ClockVector being merged into this vector.
+ */
+bool ClockVector::minmerge(const ClockVector *cv)
+{
+       ASSERT(cv != NULL);
+       bool changed = false;
+       if (cv->num_threads > num_threads) {
+               clock = (modelclock_t *)snapshot_realloc(clock, cv->num_threads * sizeof(modelclock_t));
+               for (int i = num_threads;i < cv->num_threads;i++)
+                       clock[i] = 0;
+               num_threads = cv->num_threads;
+       }
+
+       /* Element-wise minimum */
+       for (int i = 0;i < cv->num_threads;i++)
+               if (cv->clock[i] < clock[i]) {
+                       clock[i] = cv->clock[i];
+                       changed = true;
+               }
+
+       return changed;
+}
+
 /**
  * Check whether this vector's thread has synchronized with another action's
  * thread. This effectively checks the happens-before relation (or actually,