Mercurial > cpython-lru_cache-weakref
annotate Include/dynamic_annotations.h @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | 05979ae431fb |
| children |
| rev | line source |
|---|---|
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
1 /* Copyright (c) 2008-2009, Google Inc. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
2 * All rights reserved. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
3 * |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
4 * Redistribution and use in source and binary forms, with or without |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
5 * modification, are permitted provided that the following conditions are |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
6 * met: |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
7 * |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
8 * * Redistributions of source code must retain the above copyright |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
9 * notice, this list of conditions and the following disclaimer. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
10 * * Neither the name of Google Inc. nor the names of its |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
11 * contributors may be used to endorse or promote products derived from |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
12 * this software without specific prior written permission. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
13 * |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
25 * |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
26 * --- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
27 * Author: Kostya Serebryany |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
28 * Copied to CPython by Jeffrey Yasskin, with all macros renamed to |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
29 * start with _Py_ to avoid colliding with users embedding Python, and |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
30 * with deprecated macros removed. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
31 */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
32 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
33 /* This file defines dynamic annotations for use with dynamic analysis |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
34 tool such as valgrind, PIN, etc. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
35 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
36 Dynamic annotation is a source code annotation that affects |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
37 the generated code (that is, the annotation is not a comment). |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
38 Each such annotation is attached to a particular |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
39 instruction and/or to a particular object (address) in the program. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
40 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
41 The annotations that should be used by users are macros in all upper-case |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
42 (e.g., _Py_ANNOTATE_NEW_MEMORY). |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
43 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
44 Actual implementation of these macros may differ depending on the |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
45 dynamic analysis tool being used. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
46 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
47 See http://code.google.com/p/data-race-test/ for more information. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
48 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
49 This file supports the following dynamic analysis tools: |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
50 - None (DYNAMIC_ANNOTATIONS_ENABLED is not defined or zero). |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
51 Macros are defined empty. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
52 - ThreadSanitizer, Helgrind, DRD (DYNAMIC_ANNOTATIONS_ENABLED is 1). |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
53 Macros are defined as calls to non-inlinable empty functions |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
54 that are intercepted by Valgrind. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
55 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
56 #ifndef __DYNAMIC_ANNOTATIONS_H__ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
57 #define __DYNAMIC_ANNOTATIONS_H__ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
58 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
59 #ifndef DYNAMIC_ANNOTATIONS_ENABLED |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
60 # define DYNAMIC_ANNOTATIONS_ENABLED 0 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
61 #endif |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
62 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
63 #if DYNAMIC_ANNOTATIONS_ENABLED != 0 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
64 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
65 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
66 Annotations useful when implementing condition variables such as CondVar, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
67 using conditional critical sections (Await/LockWhen) and when constructing |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
68 user-defined synchronization mechanisms. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
69 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
70 The annotations _Py_ANNOTATE_HAPPENS_BEFORE() and |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
71 _Py_ANNOTATE_HAPPENS_AFTER() can be used to define happens-before arcs in |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
72 user-defined synchronization mechanisms: the race detector will infer an |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
73 arc from the former to the latter when they share the same argument |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
74 pointer. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
75 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
76 Example 1 (reference counting): |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
77 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
78 void Unref() { |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
79 _Py_ANNOTATE_HAPPENS_BEFORE(&refcount_); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
80 if (AtomicDecrementByOne(&refcount_) == 0) { |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
81 _Py_ANNOTATE_HAPPENS_AFTER(&refcount_); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
82 delete this; |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
83 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
84 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
85 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
86 Example 2 (message queue): |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
87 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
88 void MyQueue::Put(Type *e) { |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
89 MutexLock lock(&mu_); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
90 _Py_ANNOTATE_HAPPENS_BEFORE(e); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
91 PutElementIntoMyQueue(e); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
92 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
93 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
94 Type *MyQueue::Get() { |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
95 MutexLock lock(&mu_); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
96 Type *e = GetElementFromMyQueue(); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
97 _Py_ANNOTATE_HAPPENS_AFTER(e); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
98 return e; |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
99 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
100 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
101 Note: when possible, please use the existing reference counting and message |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
102 queue implementations instead of inventing new ones. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
103 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
104 /* Report that wait on the condition variable at address "cv" has succeeded |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
105 and the lock at address "lock" is held. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
106 #define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
107 AnnotateCondVarWait(__FILE__, __LINE__, cv, lock) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
108 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
109 /* Report that wait on the condition variable at "cv" has succeeded. Variant |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
110 w/o lock. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
111 #define _Py_ANNOTATE_CONDVAR_WAIT(cv) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
112 AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
113 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
114 /* Report that we are about to signal on the condition variable at address |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
115 "cv". */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
116 #define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
117 AnnotateCondVarSignal(__FILE__, __LINE__, cv) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
118 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
119 /* Report that we are about to signal_all on the condition variable at "cv". */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
120 #define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
121 AnnotateCondVarSignalAll(__FILE__, __LINE__, cv) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
122 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
123 /* Annotations for user-defined synchronization mechanisms. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
124 #define _Py_ANNOTATE_HAPPENS_BEFORE(obj) _Py_ANNOTATE_CONDVAR_SIGNAL(obj) |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
125 #define _Py_ANNOTATE_HAPPENS_AFTER(obj) _Py_ANNOTATE_CONDVAR_WAIT(obj) |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
126 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
127 /* Report that the bytes in the range [pointer, pointer+size) are about |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
128 to be published safely. The race checker will create a happens-before |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
129 arc from the call _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) to |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
130 subsequent accesses to this memory. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
131 Note: this annotation may not work properly if the race detector uses |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
132 sampling, i.e. does not observe all memory accesses. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
133 */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
134 #define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
135 AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
136 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
137 /* Instruct the tool to create a happens-before arc between mu->Unlock() and |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
138 mu->Lock(). This annotation may slow down the race detector and hide real |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
139 races. Normally it is used only when it would be difficult to annotate each |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
140 of the mutex's critical sections individually using the annotations above. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
141 This annotation makes sense only for hybrid race detectors. For pure |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
142 happens-before detectors this is a no-op. For more details see |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
143 http://code.google.com/p/data-race-test/wiki/PureHappensBeforeVsHybrid . */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
144 #define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
145 AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
146 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
147 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
148 Annotations useful when defining memory allocators, or when memory that |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
149 was protected in one way starts to be protected in another. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
150 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
151 /* Report that a new memory at "address" of size "size" has been allocated. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
152 This might be used when the memory has been retrieved from a free list and |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
153 is about to be reused, or when a the locking discipline for a variable |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
154 changes. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
155 #define _Py_ANNOTATE_NEW_MEMORY(address, size) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
156 AnnotateNewMemory(__FILE__, __LINE__, address, size) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
157 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
158 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
159 Annotations useful when defining FIFO queues that transfer data between |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
160 threads. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
161 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
162 /* Report that the producer-consumer queue (such as ProducerConsumerQueue) at |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
163 address "pcq" has been created. The _Py_ANNOTATE_PCQ_* annotations should |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
164 be used only for FIFO queues. For non-FIFO queues use |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
165 _Py_ANNOTATE_HAPPENS_BEFORE (for put) and _Py_ANNOTATE_HAPPENS_AFTER (for |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
166 get). */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
167 #define _Py_ANNOTATE_PCQ_CREATE(pcq) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
168 AnnotatePCQCreate(__FILE__, __LINE__, pcq) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
169 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
170 /* Report that the queue at address "pcq" is about to be destroyed. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
171 #define _Py_ANNOTATE_PCQ_DESTROY(pcq) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
172 AnnotatePCQDestroy(__FILE__, __LINE__, pcq) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
173 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
174 /* Report that we are about to put an element into a FIFO queue at address |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
175 "pcq". */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
176 #define _Py_ANNOTATE_PCQ_PUT(pcq) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
177 AnnotatePCQPut(__FILE__, __LINE__, pcq) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
178 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
179 /* Report that we've just got an element from a FIFO queue at address "pcq". */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
180 #define _Py_ANNOTATE_PCQ_GET(pcq) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
181 AnnotatePCQGet(__FILE__, __LINE__, pcq) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
182 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
183 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
184 Annotations that suppress errors. It is usually better to express the |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
185 program's synchronization using the other annotations, but these can |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
186 be used when all else fails. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
187 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
188 /* Report that we may have a benign race at "pointer", with size |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
189 "sizeof(*(pointer))". "pointer" must be a non-void* pointer. Insert at the |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
190 point where "pointer" has been allocated, preferably close to the point |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
191 where the race happens. See also _Py_ANNOTATE_BENIGN_RACE_STATIC. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
192 #define _Py_ANNOTATE_BENIGN_RACE(pointer, description) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
193 AnnotateBenignRaceSized(__FILE__, __LINE__, pointer, \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
194 sizeof(*(pointer)), description) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
195 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
196 /* Same as _Py_ANNOTATE_BENIGN_RACE(address, description), but applies to |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
197 the memory range [address, address+size). */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
198 #define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
199 AnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
200 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
201 /* Request the analysis tool to ignore all reads in the current thread |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
202 until _Py_ANNOTATE_IGNORE_READS_END is called. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
203 Useful to ignore intentional racey reads, while still checking |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
204 other reads and all writes. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
205 See also _Py_ANNOTATE_UNPROTECTED_READ. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
206 #define _Py_ANNOTATE_IGNORE_READS_BEGIN() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
207 AnnotateIgnoreReadsBegin(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
208 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
209 /* Stop ignoring reads. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
210 #define _Py_ANNOTATE_IGNORE_READS_END() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
211 AnnotateIgnoreReadsEnd(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
212 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
213 /* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore writes. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
214 #define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
215 AnnotateIgnoreWritesBegin(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
216 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
217 /* Stop ignoring writes. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
218 #define _Py_ANNOTATE_IGNORE_WRITES_END() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
219 AnnotateIgnoreWritesEnd(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
220 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
221 /* Start ignoring all memory accesses (reads and writes). */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
222 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
223 do {\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
224 _Py_ANNOTATE_IGNORE_READS_BEGIN();\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
225 _Py_ANNOTATE_IGNORE_WRITES_BEGIN();\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
226 }while(0)\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
227 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
228 /* Stop ignoring all memory accesses. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
229 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
230 do {\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
231 _Py_ANNOTATE_IGNORE_WRITES_END();\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
232 _Py_ANNOTATE_IGNORE_READS_END();\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
233 }while(0)\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
234 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
235 /* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore synchronization events: |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
236 RWLOCK* and CONDVAR*. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
237 #define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
238 AnnotateIgnoreSyncBegin(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
239 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
240 /* Stop ignoring sync events. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
241 #define _Py_ANNOTATE_IGNORE_SYNC_END() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
242 AnnotateIgnoreSyncEnd(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
243 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
244 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
245 /* Enable (enable!=0) or disable (enable==0) race detection for all threads. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
246 This annotation could be useful if you want to skip expensive race analysis |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
247 during some period of program execution, e.g. during initialization. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
248 #define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
249 AnnotateEnableRaceDetection(__FILE__, __LINE__, enable) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
250 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
251 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
252 Annotations useful for debugging. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
253 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
254 /* Request to trace every access to "address". */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
255 #define _Py_ANNOTATE_TRACE_MEMORY(address) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
256 AnnotateTraceMemory(__FILE__, __LINE__, address) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
257 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
258 /* Report the current thread name to a race detector. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
259 #define _Py_ANNOTATE_THREAD_NAME(name) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
260 AnnotateThreadName(__FILE__, __LINE__, name) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
261 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
262 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
263 Annotations useful when implementing locks. They are not |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
264 normally needed by modules that merely use locks. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
265 The "lock" argument is a pointer to the lock object. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
266 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
267 /* Report that a lock has been created at address "lock". */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
268 #define _Py_ANNOTATE_RWLOCK_CREATE(lock) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
269 AnnotateRWLockCreate(__FILE__, __LINE__, lock) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
270 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
271 /* Report that the lock at address "lock" is about to be destroyed. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
272 #define _Py_ANNOTATE_RWLOCK_DESTROY(lock) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
273 AnnotateRWLockDestroy(__FILE__, __LINE__, lock) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
274 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
275 /* Report that the lock at address "lock" has been acquired. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
276 is_w=1 for writer lock, is_w=0 for reader lock. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
277 #define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
278 AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
279 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
280 /* Report that the lock at address "lock" is about to be released. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
281 #define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
282 AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
283 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
284 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
285 Annotations useful when implementing barriers. They are not |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
286 normally needed by modules that merely use barriers. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
287 The "barrier" argument is a pointer to the barrier object. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
288 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
289 /* Report that the "barrier" has been initialized with initial "count". |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
290 If 'reinitialization_allowed' is true, initialization is allowed to happen |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
291 multiple times w/o calling barrier_destroy() */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
292 #define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
293 AnnotateBarrierInit(__FILE__, __LINE__, barrier, count, \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
294 reinitialization_allowed) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
295 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
296 /* Report that we are about to enter barrier_wait("barrier"). */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
297 #define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
298 AnnotateBarrierWaitBefore(__FILE__, __LINE__, barrier) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
299 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
300 /* Report that we just exited barrier_wait("barrier"). */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
301 #define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
302 AnnotateBarrierWaitAfter(__FILE__, __LINE__, barrier) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
303 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
304 /* Report that the "barrier" has been destroyed. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
305 #define _Py_ANNOTATE_BARRIER_DESTROY(barrier) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
306 AnnotateBarrierDestroy(__FILE__, __LINE__, barrier) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
307 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
308 /* ------------------------------------------------------------- |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
309 Annotations useful for testing race detectors. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
310 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
311 /* Report that we expect a race on the variable at "address". |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
312 Use only in unit tests for a race detector. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
313 #define _Py_ANNOTATE_EXPECT_RACE(address, description) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
314 AnnotateExpectRace(__FILE__, __LINE__, address, description) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
315 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
316 /* A no-op. Insert where you like to test the interceptors. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
317 #define _Py_ANNOTATE_NO_OP(arg) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
318 AnnotateNoOp(__FILE__, __LINE__, arg) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
319 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
320 /* Force the race detector to flush its state. The actual effect depends on |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
321 * the implementation of the detector. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
322 #define _Py_ANNOTATE_FLUSH_STATE() \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
323 AnnotateFlushState(__FILE__, __LINE__) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
324 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
325 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
326 #else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
327 |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
328 #define _Py_ANNOTATE_RWLOCK_CREATE(lock) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
329 #define _Py_ANNOTATE_RWLOCK_DESTROY(lock) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
330 #define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
331 #define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
332 #define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) /* */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
333 #define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
334 #define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
335 #define _Py_ANNOTATE_BARRIER_DESTROY(barrier) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
336 #define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
337 #define _Py_ANNOTATE_CONDVAR_WAIT(cv) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
338 #define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
339 #define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
340 #define _Py_ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
341 #define _Py_ANNOTATE_HAPPENS_AFTER(obj) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
342 #define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
343 #define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
344 #define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
345 #define _Py_ANNOTATE_PCQ_CREATE(pcq) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
346 #define _Py_ANNOTATE_PCQ_DESTROY(pcq) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
347 #define _Py_ANNOTATE_PCQ_PUT(pcq) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
348 #define _Py_ANNOTATE_PCQ_GET(pcq) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
349 #define _Py_ANNOTATE_NEW_MEMORY(address, size) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
350 #define _Py_ANNOTATE_EXPECT_RACE(address, description) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
351 #define _Py_ANNOTATE_BENIGN_RACE(address, description) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
352 #define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
353 #define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
354 #define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
355 #define _Py_ANNOTATE_TRACE_MEMORY(arg) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
356 #define _Py_ANNOTATE_THREAD_NAME(name) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
357 #define _Py_ANNOTATE_IGNORE_READS_BEGIN() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
358 #define _Py_ANNOTATE_IGNORE_READS_END() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
359 #define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
360 #define _Py_ANNOTATE_IGNORE_WRITES_END() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
361 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
362 #define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
363 #define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
364 #define _Py_ANNOTATE_IGNORE_SYNC_END() /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
365 #define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
366 #define _Py_ANNOTATE_NO_OP(arg) /* empty */ |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
367 #define _Py_ANNOTATE_FLUSH_STATE() /* empty */ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
368 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
369 #endif /* DYNAMIC_ANNOTATIONS_ENABLED */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
370 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
371 /* Use the macros above rather than using these functions directly. */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
372 #ifdef __cplusplus |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
373 extern "C" { |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
374 #endif |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
375 void AnnotateRWLockCreate(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
376 const volatile void *lock); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
377 void AnnotateRWLockDestroy(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
378 const volatile void *lock); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
379 void AnnotateRWLockAcquired(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
380 const volatile void *lock, long is_w); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
381 void AnnotateRWLockReleased(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
382 const volatile void *lock, long is_w); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
383 void AnnotateBarrierInit(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
384 const volatile void *barrier, long count, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
385 long reinitialization_allowed); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
386 void AnnotateBarrierWaitBefore(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
387 const volatile void *barrier); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
388 void AnnotateBarrierWaitAfter(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
389 const volatile void *barrier); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
390 void AnnotateBarrierDestroy(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
391 const volatile void *barrier); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
392 void AnnotateCondVarWait(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
393 const volatile void *cv, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
394 const volatile void *lock); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
395 void AnnotateCondVarSignal(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
396 const volatile void *cv); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
397 void AnnotateCondVarSignalAll(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
398 const volatile void *cv); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
399 void AnnotatePublishMemoryRange(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
400 const volatile void *address, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
401 long size); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
402 void AnnotateUnpublishMemoryRange(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
403 const volatile void *address, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
404 long size); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
405 void AnnotatePCQCreate(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
406 const volatile void *pcq); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
407 void AnnotatePCQDestroy(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
408 const volatile void *pcq); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
409 void AnnotatePCQPut(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
410 const volatile void *pcq); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
411 void AnnotatePCQGet(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
412 const volatile void *pcq); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
413 void AnnotateNewMemory(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
414 const volatile void *address, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
415 long size); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
416 void AnnotateExpectRace(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
417 const volatile void *address, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
418 const char *description); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
419 void AnnotateBenignRace(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
420 const volatile void *address, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
421 const char *description); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
422 void AnnotateBenignRaceSized(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
423 const volatile void *address, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
424 long size, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
425 const char *description); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
426 void AnnotateMutexIsUsedAsCondVar(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
427 const volatile void *mu); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
428 void AnnotateTraceMemory(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
429 const volatile void *arg); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
430 void AnnotateThreadName(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
431 const char *name); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
432 void AnnotateIgnoreReadsBegin(const char *file, int line); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
433 void AnnotateIgnoreReadsEnd(const char *file, int line); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
434 void AnnotateIgnoreWritesBegin(const char *file, int line); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
435 void AnnotateIgnoreWritesEnd(const char *file, int line); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
436 void AnnotateEnableRaceDetection(const char *file, int line, int enable); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
437 void AnnotateNoOp(const char *file, int line, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
438 const volatile void *arg); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
439 void AnnotateFlushState(const char *file, int line); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
440 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
441 /* Return non-zero value if running under valgrind. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
442 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
443 If "valgrind.h" is included into dynamic_annotations.c, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
444 the regular valgrind mechanism will be used. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
445 See http://valgrind.org/docs/manual/manual-core-adv.html about |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
446 RUNNING_ON_VALGRIND and other valgrind "client requests". |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
447 The file "valgrind.h" may be obtained by doing |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
448 svn co svn://svn.valgrind.org/valgrind/trunk/include |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
449 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
450 If for some reason you can't use "valgrind.h" or want to fake valgrind, |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
451 there are two ways to make this function return non-zero: |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
452 - Use environment variable: export RUNNING_ON_VALGRIND=1 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
453 - Make your tool intercept the function RunningOnValgrind() and |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
454 change its return value. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
455 */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
456 int RunningOnValgrind(void); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
457 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
458 #ifdef __cplusplus |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
459 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
460 #endif |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
461 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
462 #if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus) |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
463 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
464 /* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads. |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
465 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
466 Instead of doing |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
467 _Py_ANNOTATE_IGNORE_READS_BEGIN(); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
468 ... = x; |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
469 _Py_ANNOTATE_IGNORE_READS_END(); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
470 one can use |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
471 ... = _Py_ANNOTATE_UNPROTECTED_READ(x); */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
472 template <class T> |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
473 inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) { |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
474 _Py_ANNOTATE_IGNORE_READS_BEGIN(); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
475 T res = x; |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
476 _Py_ANNOTATE_IGNORE_READS_END(); |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
477 return res; |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
478 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
479 /* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */ |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
480 #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
481 namespace { \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
482 class static_var ## _annotator { \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
483 public: \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
484 static_var ## _annotator() { \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
485 _Py_ANNOTATE_BENIGN_RACE_SIZED(&static_var, \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
486 sizeof(static_var), \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
487 # static_var ": " description); \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
488 } \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
489 }; \ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
490 static static_var ## _annotator the ## static_var ## _annotator;\ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
491 } |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
492 #else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
493 |
|
73764
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
494 #define _Py_ANNOTATE_UNPROTECTED_READ(x) (x) |
|
05979ae431fb
Closes issue #13488: Some old preprocessors have problem with #define not in the first column
Jesus Cea <jcea@jcea.es>
parents:
61184
diff
changeset
|
495 #define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) /* empty */ |
|
61184
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
496 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
497 #endif /* DYNAMIC_ANNOTATIONS_ENABLED */ |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
498 |
|
4fd3ab5fa71d
Make (most of) Python's tests pass under Thread Sanitizer.
Jeffrey Yasskin <jyasskin@gmail.com>
parents:
diff
changeset
|
499 #endif /* __DYNAMIC_ANNOTATIONS_H__ */ |
