fix mutex_trylock bug
[c11tester.git] / datarace.h
index 7e4e68e22c3d01947ed50e4852242e32d6acdd66..34bfd4067dc99ad591a21d1ca621ca5498f0ff67 100644 (file)
@@ -44,9 +44,30 @@ struct DataRace {
 
 void initRaceDetector();
 void raceCheckWrite(thread_id_t thread, void *location);
+void atomraceCheckWrite(thread_id_t thread, void *location);
 void raceCheckRead(thread_id_t thread, const void *location);
-bool checkDataRaces();
+
+void atomraceCheckRead(thread_id_t thread, const void *location);
+void recordWrite(thread_id_t thread, void *location);
+void recordCalloc(void *location, size_t size);
 void assert_race(struct DataRace *race);
+bool hasNonAtomicStore(const void *location);
+void setAtomicStoreFlag(const void *location);
+void getStoreThreadAndClock(const void *address, thread_id_t * thread, modelclock_t * clock);
+
+void raceCheckRead8(thread_id_t thread, const void *location);
+void raceCheckRead16(thread_id_t thread, const void *location);
+void raceCheckRead32(thread_id_t thread, const void *location);
+void raceCheckRead64(thread_id_t thread, const void *location);
+
+void raceCheckWrite8(thread_id_t thread, const void *location);
+void raceCheckWrite16(thread_id_t thread, const void *location);
+void raceCheckWrite32(thread_id_t thread, const void *location);
+void raceCheckWrite64(thread_id_t thread, const void *location);
+
+#ifdef COLLECT_STAT
+void print_normal_accesses();
+#endif
 
 /**
  * @brief A record of information for detecting data races
@@ -54,8 +75,8 @@ void assert_race(struct DataRace *race);
 struct RaceRecord {
        modelclock_t *readClock;
        thread_id_t *thread;
-       int capacity;
-       int numReads;
+       int numReads : 31;
+       int isAtomic : 1;
        thread_id_t writeThread;
        modelclock_t writeClock;
 };
@@ -77,6 +98,9 @@ bool race_equals(struct DataRace *r1, struct DataRace *r2);
 #define WRITEMASK READMASK
 #define WRITEVECTOR(x) (((x)>>38)&WRITEMASK)
 
+#define ATOMICMASK (0x1ULL << 63)
+#define NONATOMICMASK ~(0x1ULL << 63)
+
 /**
  * The basic encoding idea is that (void *) either:
  *  -# points to a full record (RaceRecord) or
@@ -87,6 +111,7 @@ bool race_equals(struct DataRace *r1, struct DataRace *r2);
  *     - next 25 bits are read clock vector
  *     - next 6 bits are write thread id
  *     - next 25 bits are write clock vector
+ *     - highest bit is 1 if the write is from an atomic
  */
 #define ENCODEOP(rdthread, rdtime, wrthread, wrtime) (0x1ULL | ((rdthread)<<1) | ((rdtime) << 7) | (((uint64_t)wrthread)<<32) | (((uint64_t)wrtime)<<38))
 
@@ -94,6 +119,9 @@ bool race_equals(struct DataRace *r1, struct DataRace *r2);
 #define MAXREADVECTOR (READMASK-1)
 #define MAXWRITEVECTOR (WRITEMASK-1)
 
+#define INVALIDSHADOWVAL 0x2ULL
+#define CHECKBOUNDARY(location, bits) ((((uintptr_t)location & MASK16BIT) + bits) <= MASK16BIT)
+
 typedef HashSet<struct DataRace *, uintptr_t, 0, model_malloc, model_calloc, model_free, race_hash, race_equals> RaceSet;
 
 #endif /* __DATARACE_H__ */