123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- #ifndef __DYNAMIC_ANNOTATIONS_H__
- #define __DYNAMIC_ANNOTATIONS_H__
- #ifndef DYNAMIC_ANNOTATIONS_ENABLED
- # define DYNAMIC_ANNOTATIONS_ENABLED 0
- #endif
- #if DYNAMIC_ANNOTATIONS_ENABLED != 0
-
-
- #define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \
- AnnotateCondVarWait(__FILE__, __LINE__, cv, lock)
-
- #define _Py_ANNOTATE_CONDVAR_WAIT(cv) \
- AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL)
-
- #define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) \
- AnnotateCondVarSignal(__FILE__, __LINE__, cv)
-
- #define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \
- AnnotateCondVarSignalAll(__FILE__, __LINE__, cv)
-
- #define _Py_ANNOTATE_HAPPENS_BEFORE(obj) _Py_ANNOTATE_CONDVAR_SIGNAL(obj)
- #define _Py_ANNOTATE_HAPPENS_AFTER(obj) _Py_ANNOTATE_CONDVAR_WAIT(obj)
-
- #define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \
- AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size)
-
- #define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \
- AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu)
-
-
- #define _Py_ANNOTATE_NEW_MEMORY(address, size) \
- AnnotateNewMemory(__FILE__, __LINE__, address, size)
-
-
- #define _Py_ANNOTATE_PCQ_CREATE(pcq) \
- AnnotatePCQCreate(__FILE__, __LINE__, pcq)
-
- #define _Py_ANNOTATE_PCQ_DESTROY(pcq) \
- AnnotatePCQDestroy(__FILE__, __LINE__, pcq)
-
- #define _Py_ANNOTATE_PCQ_PUT(pcq) \
- AnnotatePCQPut(__FILE__, __LINE__, pcq)
-
- #define _Py_ANNOTATE_PCQ_GET(pcq) \
- AnnotatePCQGet(__FILE__, __LINE__, pcq)
-
-
- #define _Py_ANNOTATE_BENIGN_RACE(pointer, description) \
- AnnotateBenignRaceSized(__FILE__, __LINE__, pointer, \
- sizeof(*(pointer)), description)
-
- #define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \
- AnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description)
-
- #define _Py_ANNOTATE_IGNORE_READS_BEGIN() \
- AnnotateIgnoreReadsBegin(__FILE__, __LINE__)
-
- #define _Py_ANNOTATE_IGNORE_READS_END() \
- AnnotateIgnoreReadsEnd(__FILE__, __LINE__)
-
- #define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() \
- AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
-
- #define _Py_ANNOTATE_IGNORE_WRITES_END() \
- AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
-
- #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \
- do {\
- _Py_ANNOTATE_IGNORE_READS_BEGIN();\
- _Py_ANNOTATE_IGNORE_WRITES_BEGIN();\
- }while(0)\
-
- #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() \
- do {\
- _Py_ANNOTATE_IGNORE_WRITES_END();\
- _Py_ANNOTATE_IGNORE_READS_END();\
- }while(0)\
-
- #define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() \
- AnnotateIgnoreSyncBegin(__FILE__, __LINE__)
-
- #define _Py_ANNOTATE_IGNORE_SYNC_END() \
- AnnotateIgnoreSyncEnd(__FILE__, __LINE__)
-
- #define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) \
- AnnotateEnableRaceDetection(__FILE__, __LINE__, enable)
-
-
- #define _Py_ANNOTATE_TRACE_MEMORY(address) \
- AnnotateTraceMemory(__FILE__, __LINE__, address)
-
- #define _Py_ANNOTATE_THREAD_NAME(name) \
- AnnotateThreadName(__FILE__, __LINE__, name)
-
-
- #define _Py_ANNOTATE_RWLOCK_CREATE(lock) \
- AnnotateRWLockCreate(__FILE__, __LINE__, lock)
-
- #define _Py_ANNOTATE_RWLOCK_DESTROY(lock) \
- AnnotateRWLockDestroy(__FILE__, __LINE__, lock)
-
- #define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \
- AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w)
-
- #define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \
- AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w)
-
-
- #define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) \
- AnnotateBarrierInit(__FILE__, __LINE__, barrier, count, \
- reinitialization_allowed)
-
- #define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) \
- AnnotateBarrierWaitBefore(__FILE__, __LINE__, barrier)
-
- #define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) \
- AnnotateBarrierWaitAfter(__FILE__, __LINE__, barrier)
-
- #define _Py_ANNOTATE_BARRIER_DESTROY(barrier) \
- AnnotateBarrierDestroy(__FILE__, __LINE__, barrier)
-
-
- #define _Py_ANNOTATE_EXPECT_RACE(address, description) \
- AnnotateExpectRace(__FILE__, __LINE__, address, description)
-
- #define _Py_ANNOTATE_NO_OP(arg) \
- AnnotateNoOp(__FILE__, __LINE__, arg)
-
- #define _Py_ANNOTATE_FLUSH_STATE() \
- AnnotateFlushState(__FILE__, __LINE__)
- #else
- #define _Py_ANNOTATE_RWLOCK_CREATE(lock)
- #define _Py_ANNOTATE_RWLOCK_DESTROY(lock)
- #define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w)
- #define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w)
- #define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed)
- #define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier)
- #define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier)
- #define _Py_ANNOTATE_BARRIER_DESTROY(barrier)
- #define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock)
- #define _Py_ANNOTATE_CONDVAR_WAIT(cv)
- #define _Py_ANNOTATE_CONDVAR_SIGNAL(cv)
- #define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv)
- #define _Py_ANNOTATE_HAPPENS_BEFORE(obj)
- #define _Py_ANNOTATE_HAPPENS_AFTER(obj)
- #define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size)
- #define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size)
- #define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size)
- #define _Py_ANNOTATE_PCQ_CREATE(pcq)
- #define _Py_ANNOTATE_PCQ_DESTROY(pcq)
- #define _Py_ANNOTATE_PCQ_PUT(pcq)
- #define _Py_ANNOTATE_PCQ_GET(pcq)
- #define _Py_ANNOTATE_NEW_MEMORY(address, size)
- #define _Py_ANNOTATE_EXPECT_RACE(address, description)
- #define _Py_ANNOTATE_BENIGN_RACE(address, description)
- #define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description)
- #define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu)
- #define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu)
- #define _Py_ANNOTATE_TRACE_MEMORY(arg)
- #define _Py_ANNOTATE_THREAD_NAME(name)
- #define _Py_ANNOTATE_IGNORE_READS_BEGIN()
- #define _Py_ANNOTATE_IGNORE_READS_END()
- #define _Py_ANNOTATE_IGNORE_WRITES_BEGIN()
- #define _Py_ANNOTATE_IGNORE_WRITES_END()
- #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN()
- #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END()
- #define _Py_ANNOTATE_IGNORE_SYNC_BEGIN()
- #define _Py_ANNOTATE_IGNORE_SYNC_END()
- #define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable)
- #define _Py_ANNOTATE_NO_OP(arg)
- #define _Py_ANNOTATE_FLUSH_STATE()
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- void AnnotateRWLockCreate(const char *file, int line,
- const volatile void *lock);
- void AnnotateRWLockDestroy(const char *file, int line,
- const volatile void *lock);
- void AnnotateRWLockAcquired(const char *file, int line,
- const volatile void *lock, long is_w);
- void AnnotateRWLockReleased(const char *file, int line,
- const volatile void *lock, long is_w);
- void AnnotateBarrierInit(const char *file, int line,
- const volatile void *barrier, long count,
- long reinitialization_allowed);
- void AnnotateBarrierWaitBefore(const char *file, int line,
- const volatile void *barrier);
- void AnnotateBarrierWaitAfter(const char *file, int line,
- const volatile void *barrier);
- void AnnotateBarrierDestroy(const char *file, int line,
- const volatile void *barrier);
- void AnnotateCondVarWait(const char *file, int line,
- const volatile void *cv,
- const volatile void *lock);
- void AnnotateCondVarSignal(const char *file, int line,
- const volatile void *cv);
- void AnnotateCondVarSignalAll(const char *file, int line,
- const volatile void *cv);
- void AnnotatePublishMemoryRange(const char *file, int line,
- const volatile void *address,
- long size);
- void AnnotateUnpublishMemoryRange(const char *file, int line,
- const volatile void *address,
- long size);
- void AnnotatePCQCreate(const char *file, int line,
- const volatile void *pcq);
- void AnnotatePCQDestroy(const char *file, int line,
- const volatile void *pcq);
- void AnnotatePCQPut(const char *file, int line,
- const volatile void *pcq);
- void AnnotatePCQGet(const char *file, int line,
- const volatile void *pcq);
- void AnnotateNewMemory(const char *file, int line,
- const volatile void *address,
- long size);
- void AnnotateExpectRace(const char *file, int line,
- const volatile void *address,
- const char *description);
- void AnnotateBenignRace(const char *file, int line,
- const volatile void *address,
- const char *description);
- void AnnotateBenignRaceSized(const char *file, int line,
- const volatile void *address,
- long size,
- const char *description);
- void AnnotateMutexIsUsedAsCondVar(const char *file, int line,
- const volatile void *mu);
- void AnnotateTraceMemory(const char *file, int line,
- const volatile void *arg);
- void AnnotateThreadName(const char *file, int line,
- const char *name);
- void AnnotateIgnoreReadsBegin(const char *file, int line);
- void AnnotateIgnoreReadsEnd(const char *file, int line);
- void AnnotateIgnoreWritesBegin(const char *file, int line);
- void AnnotateIgnoreWritesEnd(const char *file, int line);
- void AnnotateEnableRaceDetection(const char *file, int line, int enable);
- void AnnotateNoOp(const char *file, int line,
- const volatile void *arg);
- void AnnotateFlushState(const char *file, int line);
- int RunningOnValgrind(void);
- #ifdef __cplusplus
- }
- #endif
- #if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus)
-
- template <class T>
- inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) {
- _Py_ANNOTATE_IGNORE_READS_BEGIN();
- T res = x;
- _Py_ANNOTATE_IGNORE_READS_END();
- return res;
- }
-
- #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \
- namespace { \
- class static_var ## _annotator { \
- public: \
- static_var ## _annotator() { \
- _Py_ANNOTATE_BENIGN_RACE_SIZED(&static_var, \
- sizeof(static_var), \
- # static_var ": " description); \
- } \
- }; \
- static static_var ## _annotator the ## static_var ## _annotator;\
- }
- #else
- #define _Py_ANNOTATE_UNPROTECTED_READ(x) (x)
- #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description)
- #endif
- #endif
|