Eliminated out-of-line copy of vc_lte().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8268 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/drd_vc.h b/exp-drd/drd_vc.h
index 3737880..93ead91 100644
--- a/exp-drd/drd_vc.h
+++ b/exp-drd/drd_vc.h
@@ -71,6 +71,7 @@
const VectorClock* const rhs);
UInt vc_get(VectorClock* const vc, const ThreadId tid);
void vc_increment(VectorClock* const vc, ThreadId const threadid);
+static __inline__
Bool vc_lte(const VectorClock* const vc1,
const VectorClock* const vc2);
Bool vc_ordered(const VectorClock* const vc1,
@@ -89,4 +90,36 @@
void vc_test(void);
+
+/**
+ * @return True if all thread id's that are present in vc1 also exist in
+ * vc2, and if additionally all corresponding counters in v2 are higher or
+ * equal.
+ */
+static __inline__
+Bool vc_lte(const VectorClock* const vc1, const VectorClock* const vc2)
+{
+ unsigned i;
+ unsigned j = 0;
+
+ for (i = 0; i < vc1->size; i++)
+ {
+ while (j < vc2->size && vc2->vc[j].threadid < vc1->vc[i].threadid)
+ {
+ j++;
+ }
+ if (j >= vc2->size || vc2->vc[j].threadid > vc1->vc[i].threadid)
+ return False;
+#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
+ /* This assert statement has been commented out because of performance */
+ /* reasons.*/
+ tl_assert(j < vc2->size && vc2->vc[j].threadid == vc1->vc[i].threadid);
+#endif
+ if (vc1->vc[i].count > vc2->vc[j].count)
+ return False;
+ }
+ return True;
+}
+
+
#endif /* __DRD_VC_H */