File indexing completed on 2025-01-18 10:06:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 #ifndef __DYNAMIC_ANNOTATIONS_H__
0057 #define __DYNAMIC_ANNOTATIONS_H__
0058
0059 #ifndef DYNAMIC_ANNOTATIONS_ENABLED
0060 # define DYNAMIC_ANNOTATIONS_ENABLED 0
0061 #endif
0062
0063 #if DYNAMIC_ANNOTATIONS_ENABLED != 0
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 #define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \
0107 AnnotateCondVarWait(__FILE__, __LINE__, cv, lock)
0108
0109
0110
0111 #define _Py_ANNOTATE_CONDVAR_WAIT(cv) \
0112 AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL)
0113
0114
0115
0116 #define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) \
0117 AnnotateCondVarSignal(__FILE__, __LINE__, cv)
0118
0119
0120 #define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \
0121 AnnotateCondVarSignalAll(__FILE__, __LINE__, cv)
0122
0123
0124 #define _Py_ANNOTATE_HAPPENS_BEFORE(obj) _Py_ANNOTATE_CONDVAR_SIGNAL(obj)
0125 #define _Py_ANNOTATE_HAPPENS_AFTER(obj) _Py_ANNOTATE_CONDVAR_WAIT(obj)
0126
0127
0128
0129
0130
0131
0132
0133
0134 #define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \
0135 AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size)
0136
0137
0138
0139
0140
0141
0142
0143
0144 #define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \
0145 AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu)
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 #define _Py_ANNOTATE_NEW_MEMORY(address, size) \
0156 AnnotateNewMemory(__FILE__, __LINE__, address, size)
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167 #define _Py_ANNOTATE_PCQ_CREATE(pcq) \
0168 AnnotatePCQCreate(__FILE__, __LINE__, pcq)
0169
0170
0171 #define _Py_ANNOTATE_PCQ_DESTROY(pcq) \
0172 AnnotatePCQDestroy(__FILE__, __LINE__, pcq)
0173
0174
0175
0176 #define _Py_ANNOTATE_PCQ_PUT(pcq) \
0177 AnnotatePCQPut(__FILE__, __LINE__, pcq)
0178
0179
0180 #define _Py_ANNOTATE_PCQ_GET(pcq) \
0181 AnnotatePCQGet(__FILE__, __LINE__, pcq)
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 #define _Py_ANNOTATE_BENIGN_RACE(pointer, description) \
0193 AnnotateBenignRaceSized(__FILE__, __LINE__, pointer, \
0194 sizeof(*(pointer)), description)
0195
0196
0197
0198 #define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \
0199 AnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description)
0200
0201
0202
0203
0204
0205
0206 #define _Py_ANNOTATE_IGNORE_READS_BEGIN() \
0207 AnnotateIgnoreReadsBegin(__FILE__, __LINE__)
0208
0209
0210 #define _Py_ANNOTATE_IGNORE_READS_END() \
0211 AnnotateIgnoreReadsEnd(__FILE__, __LINE__)
0212
0213
0214 #define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() \
0215 AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
0216
0217
0218 #define _Py_ANNOTATE_IGNORE_WRITES_END() \
0219 AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
0220
0221
0222 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \
0223 do {\
0224 _Py_ANNOTATE_IGNORE_READS_BEGIN();\
0225 _Py_ANNOTATE_IGNORE_WRITES_BEGIN();\
0226 }while(0)\
0227
0228
0229 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() \
0230 do {\
0231 _Py_ANNOTATE_IGNORE_WRITES_END();\
0232 _Py_ANNOTATE_IGNORE_READS_END();\
0233 }while(0)\
0234
0235
0236
0237 #define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() \
0238 AnnotateIgnoreSyncBegin(__FILE__, __LINE__)
0239
0240
0241 #define _Py_ANNOTATE_IGNORE_SYNC_END() \
0242 AnnotateIgnoreSyncEnd(__FILE__, __LINE__)
0243
0244
0245
0246
0247
0248 #define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) \
0249 AnnotateEnableRaceDetection(__FILE__, __LINE__, enable)
0250
0251
0252
0253
0254
0255 #define _Py_ANNOTATE_TRACE_MEMORY(address) \
0256 AnnotateTraceMemory(__FILE__, __LINE__, address)
0257
0258
0259 #define _Py_ANNOTATE_THREAD_NAME(name) \
0260 AnnotateThreadName(__FILE__, __LINE__, name)
0261
0262
0263
0264
0265
0266
0267
0268 #define _Py_ANNOTATE_RWLOCK_CREATE(lock) \
0269 AnnotateRWLockCreate(__FILE__, __LINE__, lock)
0270
0271
0272 #define _Py_ANNOTATE_RWLOCK_DESTROY(lock) \
0273 AnnotateRWLockDestroy(__FILE__, __LINE__, lock)
0274
0275
0276
0277 #define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \
0278 AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w)
0279
0280
0281 #define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \
0282 AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w)
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292 #define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) \
0293 AnnotateBarrierInit(__FILE__, __LINE__, barrier, count, \
0294 reinitialization_allowed)
0295
0296
0297 #define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) \
0298 AnnotateBarrierWaitBefore(__FILE__, __LINE__, barrier)
0299
0300
0301 #define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) \
0302 AnnotateBarrierWaitAfter(__FILE__, __LINE__, barrier)
0303
0304
0305 #define _Py_ANNOTATE_BARRIER_DESTROY(barrier) \
0306 AnnotateBarrierDestroy(__FILE__, __LINE__, barrier)
0307
0308
0309
0310
0311
0312
0313 #define _Py_ANNOTATE_EXPECT_RACE(address, description) \
0314 AnnotateExpectRace(__FILE__, __LINE__, address, description)
0315
0316
0317 #define _Py_ANNOTATE_NO_OP(arg) \
0318 AnnotateNoOp(__FILE__, __LINE__, arg)
0319
0320
0321
0322 #define _Py_ANNOTATE_FLUSH_STATE() \
0323 AnnotateFlushState(__FILE__, __LINE__)
0324
0325
0326 #else
0327
0328 #define _Py_ANNOTATE_RWLOCK_CREATE(lock)
0329 #define _Py_ANNOTATE_RWLOCK_DESTROY(lock)
0330 #define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w)
0331 #define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w)
0332 #define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed)
0333 #define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier)
0334 #define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier)
0335 #define _Py_ANNOTATE_BARRIER_DESTROY(barrier)
0336 #define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock)
0337 #define _Py_ANNOTATE_CONDVAR_WAIT(cv)
0338 #define _Py_ANNOTATE_CONDVAR_SIGNAL(cv)
0339 #define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv)
0340 #define _Py_ANNOTATE_HAPPENS_BEFORE(obj)
0341 #define _Py_ANNOTATE_HAPPENS_AFTER(obj)
0342 #define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size)
0343 #define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size)
0344 #define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size)
0345 #define _Py_ANNOTATE_PCQ_CREATE(pcq)
0346 #define _Py_ANNOTATE_PCQ_DESTROY(pcq)
0347 #define _Py_ANNOTATE_PCQ_PUT(pcq)
0348 #define _Py_ANNOTATE_PCQ_GET(pcq)
0349 #define _Py_ANNOTATE_NEW_MEMORY(address, size)
0350 #define _Py_ANNOTATE_EXPECT_RACE(address, description)
0351 #define _Py_ANNOTATE_BENIGN_RACE(address, description)
0352 #define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description)
0353 #define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu)
0354 #define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu)
0355 #define _Py_ANNOTATE_TRACE_MEMORY(arg)
0356 #define _Py_ANNOTATE_THREAD_NAME(name)
0357 #define _Py_ANNOTATE_IGNORE_READS_BEGIN()
0358 #define _Py_ANNOTATE_IGNORE_READS_END()
0359 #define _Py_ANNOTATE_IGNORE_WRITES_BEGIN()
0360 #define _Py_ANNOTATE_IGNORE_WRITES_END()
0361 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN()
0362 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END()
0363 #define _Py_ANNOTATE_IGNORE_SYNC_BEGIN()
0364 #define _Py_ANNOTATE_IGNORE_SYNC_END()
0365 #define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable)
0366 #define _Py_ANNOTATE_NO_OP(arg)
0367 #define _Py_ANNOTATE_FLUSH_STATE()
0368
0369 #endif
0370
0371
0372 #ifdef __cplusplus
0373 extern "C" {
0374 #endif
0375 void AnnotateRWLockCreate(const char *file, int line,
0376 const volatile void *lock);
0377 void AnnotateRWLockDestroy(const char *file, int line,
0378 const volatile void *lock);
0379 void AnnotateRWLockAcquired(const char *file, int line,
0380 const volatile void *lock, long is_w);
0381 void AnnotateRWLockReleased(const char *file, int line,
0382 const volatile void *lock, long is_w);
0383 void AnnotateBarrierInit(const char *file, int line,
0384 const volatile void *barrier, long count,
0385 long reinitialization_allowed);
0386 void AnnotateBarrierWaitBefore(const char *file, int line,
0387 const volatile void *barrier);
0388 void AnnotateBarrierWaitAfter(const char *file, int line,
0389 const volatile void *barrier);
0390 void AnnotateBarrierDestroy(const char *file, int line,
0391 const volatile void *barrier);
0392 void AnnotateCondVarWait(const char *file, int line,
0393 const volatile void *cv,
0394 const volatile void *lock);
0395 void AnnotateCondVarSignal(const char *file, int line,
0396 const volatile void *cv);
0397 void AnnotateCondVarSignalAll(const char *file, int line,
0398 const volatile void *cv);
0399 void AnnotatePublishMemoryRange(const char *file, int line,
0400 const volatile void *address,
0401 long size);
0402 void AnnotateUnpublishMemoryRange(const char *file, int line,
0403 const volatile void *address,
0404 long size);
0405 void AnnotatePCQCreate(const char *file, int line,
0406 const volatile void *pcq);
0407 void AnnotatePCQDestroy(const char *file, int line,
0408 const volatile void *pcq);
0409 void AnnotatePCQPut(const char *file, int line,
0410 const volatile void *pcq);
0411 void AnnotatePCQGet(const char *file, int line,
0412 const volatile void *pcq);
0413 void AnnotateNewMemory(const char *file, int line,
0414 const volatile void *address,
0415 long size);
0416 void AnnotateExpectRace(const char *file, int line,
0417 const volatile void *address,
0418 const char *description);
0419 void AnnotateBenignRace(const char *file, int line,
0420 const volatile void *address,
0421 const char *description);
0422 void AnnotateBenignRaceSized(const char *file, int line,
0423 const volatile void *address,
0424 long size,
0425 const char *description);
0426 void AnnotateMutexIsUsedAsCondVar(const char *file, int line,
0427 const volatile void *mu);
0428 void AnnotateTraceMemory(const char *file, int line,
0429 const volatile void *arg);
0430 void AnnotateThreadName(const char *file, int line,
0431 const char *name);
0432 void AnnotateIgnoreReadsBegin(const char *file, int line);
0433 void AnnotateIgnoreReadsEnd(const char *file, int line);
0434 void AnnotateIgnoreWritesBegin(const char *file, int line);
0435 void AnnotateIgnoreWritesEnd(const char *file, int line);
0436 void AnnotateEnableRaceDetection(const char *file, int line, int enable);
0437 void AnnotateNoOp(const char *file, int line,
0438 const volatile void *arg);
0439 void AnnotateFlushState(const char *file, int line);
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456 int RunningOnValgrind(void);
0457
0458 #ifdef __cplusplus
0459 }
0460 #endif
0461
0462 #if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus)
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472 template <class T>
0473 inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) {
0474 _Py_ANNOTATE_IGNORE_READS_BEGIN();
0475 T res = x;
0476 _Py_ANNOTATE_IGNORE_READS_END();
0477 return res;
0478 }
0479
0480 #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \
0481 namespace { \
0482 class static_var ## _annotator { \
0483 public: \
0484 static_var ## _annotator() { \
0485 _Py_ANNOTATE_BENIGN_RACE_SIZED(&static_var, \
0486 sizeof(static_var), \
0487 # static_var ": " description); \
0488 } \
0489 }; \
0490 static static_var ## _annotator the ## static_var ## _annotator;\
0491 }
0492 #else
0493
0494 #define _Py_ANNOTATE_UNPROTECTED_READ(x) (x)
0495 #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description)
0496
0497 #endif
0498
0499 #endif