X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=datarace.h;h=78903d336832bb7439d4a8ab61799dd48f2ceed5;hb=4240d2152b14f8d5305ee524280cbb9a3a54e5ef;hp=b2f709911ecff2274596ed11f7c5338365ee57e7;hpb=620c53f1b91d3f9b51424ff57c652d247f6fbaac;p=c11tester.git diff --git a/datarace.h b/datarace.h index b2f70991..78903d33 100644 --- a/datarace.h +++ b/datarace.h @@ -5,8 +5,12 @@ #ifndef DATARACE_H #include "config.h" #include -#include "clockvector.h" -#include +#include "modeltypes.h" +#include "stl-model.h" + +/* Forward declaration */ +class ClockVector; +class ModelAction; struct ShadowTable { void * array[65536]; @@ -32,28 +36,22 @@ struct DataRace { bool isnewwrite; /* Address of data race. */ - void *address; + const void *address; }; #define MASK16BIT 0xffff void initRaceDetector(); -void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock); -void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock); -void checkDataRaces(); -void printRace(struct DataRace *race); - -extern std::vector unrealizedraces; - -/** Basic encoding idea: - * (void *) Either: - * (1) points to a full record or - * - * (2) encodes the information in a 64 bit word. Encoding is as - * follows: lowest bit set to 1, next 8 bits are read thread id, next - * 23 bits are read clock vector, next 8 bites are write thread id, - * next 23 bits are write clock vector. */ +void raceCheckWrite(thread_id_t thread, void *location); +void raceCheckRead(thread_id_t thread, const void *location); +bool checkDataRaces(); +void assert_race(struct DataRace *race); + +extern SnapVector unrealizedraces; +/** + * @brief A record of information for detecting data races + */ struct RaceRecord { modelclock_t *readClock; thread_id_t *thread; @@ -77,6 +75,17 @@ struct RaceRecord { #define WRITEMASK READMASK #define WRITEVECTOR(x) (((x)>>40)&WRITEMASK) +/** + * The basic encoding idea is that (void *) either: + * -# points to a full record (RaceRecord) or + * -# encodes the information in a 64 bit word. Encoding is as + * follows: + * - lowest bit set to 1 + * - next 8 bits are read thread id + * - next 23 bits are read clock vector + * - next 8 bits are write thread id + * - next 23 bits are write clock vector + */ #define ENCODEOP(rdthread, rdtime, wrthread, wrtime) (0x1ULL | ((rdthread)<<1) | ((rdtime) << 9) | (((uint64_t)wrthread)<<32) | (((uint64_t)wrtime)<<40)) #define MAXTHREADID (THREADMASK-1)