Commits

Armin Rigo committed fc6429e

Copy PtrEq from stmintf.rst. Untested so far.

  • Participants
  • Parent commits 4144b92

Comments (0)

Files changed (2)

File hack/stm/c2/et.c

 
 /************************************************************/
 
+inline static gcptr GlobalizeForComparison(struct tx_descriptor *d, gcptr P)
+{
+  if (P == NULL)
+    return NULL;
+  else if (P->h_tid & GCFLAG_GLOBAL)
+    return LatestGlobalRevision(d, P, NULL, 0);
+  else if (P->h_revision != REV_INITIAL)
+    return (gcptr)P->h_revision;    // return the original global obj
+  else
+    return P;        // local, allocated during this transaction
+}
+
+_Bool PtrEq(gcptr P1, gcptr P2)
+{
+  struct tx_descriptor *d = thread_descriptor;
+  return GlobalizeForComparison(d, P1) == GlobalizeForComparison(d, P2);
+}
+
+/************************************************************/
+
 revision_t DescriptorInit(void)
 {
   assert(thread_descriptor == NULL);

File hack/stm/c2/et.h

 void DescriptorDone(void);
 
 gcptr Allocate(size_t size, int gctid);
+_Bool PtrEq(gcptr P1, gcptr P2);
 
 gcptr _DirectReadBarrier(gcptr);
 gcptr _DirectReadBarrierFromR(gcptr, gcptr, size_t);