|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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 |
|
|