Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: base/third_party/dynamic_annotations/dynamic_annotations.c

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

Powered by Google App Engine
This is Rietveld 408576698