ยปCore Development>Code coverage>Python/dynamic_annotations.c

Python code coverage for Python/dynamic_annotations.c

#countcontent
1n/a/* Copyright (c) 2008-2009, Google Inc.
2n/a * All rights reserved.
3n/a *
4n/a * Redistribution and use in source and binary forms, with or without
5n/a * modification, are permitted provided that the following conditions are
6n/a * met:
7n/a *
8n/a * * Redistributions of source code must retain the above copyright
9n/a * notice, this list of conditions and the following disclaimer.
10n/a * * Neither the name of Google Inc. nor the names of its
11n/a * contributors may be used to endorse or promote products derived from
12n/a * this software without specific prior written permission.
13n/a *
14n/a * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15n/a * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16n/a * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17n/a * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18n/a * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19n/a * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20n/a * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21n/a * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22n/a * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23n/a * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24n/a * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25n/a *
26n/a * ---
27n/a * Author: Kostya Serebryany
28n/a */
29n/a
30n/a#ifdef _MSC_VER
31n/a# include <windows.h>
32n/a#endif
33n/a
34n/a#ifdef __cplusplus
35n/a# error "This file should be built as pure C to avoid name mangling"
36n/a#endif
37n/a
38n/a#include <stdlib.h>
39n/a#include <string.h>
40n/a
41n/a#include "dynamic_annotations.h"
42n/a
43n/a/* Each function is empty and called (via a macro) only in debug mode.
44n/a The arguments are captured by dynamic tools at runtime. */
45n/a
46n/a#if DYNAMIC_ANNOTATIONS_ENABLED == 1
47n/a
48n/avoid AnnotateRWLockCreate(const char *file, int line,
49n/a const volatile void *lock){}
50n/avoid AnnotateRWLockDestroy(const char *file, int line,
51n/a const volatile void *lock){}
52n/avoid AnnotateRWLockAcquired(const char *file, int line,
53n/a const volatile void *lock, long is_w){}
54n/avoid AnnotateRWLockReleased(const char *file, int line,
55n/a const volatile void *lock, long is_w){}
56n/avoid AnnotateBarrierInit(const char *file, int line,
57n/a const volatile void *barrier, long count,
58n/a long reinitialization_allowed) {}
59n/avoid AnnotateBarrierWaitBefore(const char *file, int line,
60n/a const volatile void *barrier) {}
61n/avoid AnnotateBarrierWaitAfter(const char *file, int line,
62n/a const volatile void *barrier) {}
63n/avoid AnnotateBarrierDestroy(const char *file, int line,
64n/a const volatile void *barrier) {}
65n/a
66n/avoid AnnotateCondVarWait(const char *file, int line,
67n/a const volatile void *cv,
68n/a const volatile void *lock){}
69n/avoid AnnotateCondVarSignal(const char *file, int line,
70n/a const volatile void *cv){}
71n/avoid AnnotateCondVarSignalAll(const char *file, int line,
72n/a const volatile void *cv){}
73n/avoid AnnotatePublishMemoryRange(const char *file, int line,
74n/a const volatile void *address,
75n/a long size){}
76n/avoid AnnotateUnpublishMemoryRange(const char *file, int line,
77n/a const volatile void *address,
78n/a long size){}
79n/avoid AnnotatePCQCreate(const char *file, int line,
80n/a const volatile void *pcq){}
81n/avoid AnnotatePCQDestroy(const char *file, int line,
82n/a const volatile void *pcq){}
83n/avoid AnnotatePCQPut(const char *file, int line,
84n/a const volatile void *pcq){}
85n/avoid AnnotatePCQGet(const char *file, int line,
86n/a const volatile void *pcq){}
87n/avoid AnnotateNewMemory(const char *file, int line,
88n/a const volatile void *mem,
89n/a long size){}
90n/avoid AnnotateExpectRace(const char *file, int line,
91n/a const volatile void *mem,
92n/a const char *description){}
93n/avoid AnnotateBenignRace(const char *file, int line,
94n/a const volatile void *mem,
95n/a const char *description){}
96n/avoid AnnotateBenignRaceSized(const char *file, int line,
97n/a const volatile void *mem,
98n/a long size,
99n/a const char *description) {}
100n/avoid AnnotateMutexIsUsedAsCondVar(const char *file, int line,
101n/a const volatile void *mu){}
102n/avoid AnnotateTraceMemory(const char *file, int line,
103n/a const volatile void *arg){}
104n/avoid AnnotateThreadName(const char *file, int line,
105n/a const char *name){}
106n/avoid AnnotateIgnoreReadsBegin(const char *file, int line){}
107n/avoid AnnotateIgnoreReadsEnd(const char *file, int line){}
108n/avoid AnnotateIgnoreWritesBegin(const char *file, int line){}
109n/avoid AnnotateIgnoreWritesEnd(const char *file, int line){}
110n/avoid AnnotateIgnoreSyncBegin(const char *file, int line){}
111n/avoid AnnotateIgnoreSyncEnd(const char *file, int line){}
112n/avoid AnnotateEnableRaceDetection(const char *file, int line, int enable){}
113n/avoid AnnotateNoOp(const char *file, int line,
114n/a const volatile void *arg){}
115n/avoid AnnotateFlushState(const char *file, int line){}
116n/a
117n/astatic int GetRunningOnValgrind(void) {
118n/a#ifdef RUNNING_ON_VALGRIND
119n/a if (RUNNING_ON_VALGRIND) return 1;
120n/a#endif
121n/a
122n/a#ifndef _MSC_VER
123n/a char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND");
124n/a if (running_on_valgrind_str) {
125n/a return strcmp(running_on_valgrind_str, "0") != 0;
126n/a }
127n/a#else
128n/a /* Visual Studio issues warnings if we use getenv,
129n/a * so we use GetEnvironmentVariableA instead.
130n/a */
131n/a char value[100] = "1";
132n/a int res = GetEnvironmentVariableA("RUNNING_ON_VALGRIND",
133n/a value, sizeof(value));
134n/a /* value will remain "1" if res == 0 or res >= sizeof(value). The latter
135n/a * can happen only if the given value is long, in this case it can't be "0".
136n/a */
137n/a if (res > 0 && !strcmp(value, "0"))
138n/a return 1;
139n/a#endif
140n/a return 0;
141n/a}
142n/a
143n/a/* See the comments in dynamic_annotations.h */
144n/aint RunningOnValgrind(void) {
145n/a static volatile int running_on_valgrind = -1;
146n/a /* C doesn't have thread-safe initialization of statics, and we
147n/a don't want to depend on pthread_once here, so hack it. */
148n/a int local_running_on_valgrind = running_on_valgrind;
149n/a if (local_running_on_valgrind == -1)
150n/a running_on_valgrind = local_running_on_valgrind = GetRunningOnValgrind();
151n/a return local_running_on_valgrind;
152n/a}
153n/a
154n/a#endif /* DYNAMIC_ANNOTATIONS_ENABLED == 1 */