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

Side by Side Diff: third_party/tcmalloc/chromium/src/base/dynamic_annotations.c

Issue 9666033: Experiment for updating the tcmalloc chromium branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2008-2009, Google Inc. 1 /* Copyright (c) 2008-2009, Google Inc.
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 #ifdef __GNUC__ 44 #ifdef __GNUC__
45 /* valgrind.h uses gcc extensions so it won't build with other compilers */ 45 /* valgrind.h uses gcc extensions so it won't build with other compilers */
46 # ifdef HAVE_VALGRIND_H /* prefer the user's copy if they have it */ 46 # ifdef HAVE_VALGRIND_H /* prefer the user's copy if they have it */
47 # include <valgrind.h> 47 # include <valgrind.h>
48 # else /* otherwise just use the copy that we have */ 48 # else /* otherwise just use the copy that we have */
49 # include "third_party/valgrind.h" 49 # include "third_party/valgrind.h"
50 # endif 50 # endif
51 #endif 51 #endif
52 52
53 /* Compiler-based ThreadSanitizer defines
54 DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL = 1
55 and provides its own definitions of the functions. */
56
57 #ifndef DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL
58 # define DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL 0
59 #endif
60
53 /* Each function is empty and called (via a macro) only in debug mode. 61 /* Each function is empty and called (via a macro) only in debug mode.
54 The arguments are captured by dynamic tools at runtime. */ 62 The arguments are captured by dynamic tools at runtime. */
55 63
56 #if DYNAMIC_ANNOTATIONS_ENABLED == 1 64 #if DYNAMIC_ANNOTATIONS_ENABLED == 1 \
65 && DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0
57 66
58 void AnnotateRWLockCreate(const char *file, int line, 67 void AnnotateRWLockCreate(const char *file, int line,
59 const volatile void *lock){} 68 const volatile void *lock){}
60 void AnnotateRWLockDestroy(const char *file, int line, 69 void AnnotateRWLockDestroy(const char *file, int line,
61 const volatile void *lock){} 70 const volatile void *lock){}
62 void AnnotateRWLockAcquired(const char *file, int line, 71 void AnnotateRWLockAcquired(const char *file, int line,
63 const volatile void *lock, long is_w){} 72 const volatile void *lock, long is_w){}
64 void AnnotateRWLockReleased(const char *file, int line, 73 void AnnotateRWLockReleased(const char *file, int line,
65 const volatile void *lock, long is_w){} 74 const volatile void *lock, long is_w){}
66 void AnnotateBarrierInit(const char *file, int line, 75 void AnnotateBarrierInit(const char *file, int line,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const char *name){} 124 const char *name){}
116 void AnnotateIgnoreReadsBegin(const char *file, int line){} 125 void AnnotateIgnoreReadsBegin(const char *file, int line){}
117 void AnnotateIgnoreReadsEnd(const char *file, int line){} 126 void AnnotateIgnoreReadsEnd(const char *file, int line){}
118 void AnnotateIgnoreWritesBegin(const char *file, int line){} 127 void AnnotateIgnoreWritesBegin(const char *file, int line){}
119 void AnnotateIgnoreWritesEnd(const char *file, int line){} 128 void AnnotateIgnoreWritesEnd(const char *file, int line){}
120 void AnnotateEnableRaceDetection(const char *file, int line, int enable){} 129 void AnnotateEnableRaceDetection(const char *file, int line, int enable){}
121 void AnnotateNoOp(const char *file, int line, 130 void AnnotateNoOp(const char *file, int line,
122 const volatile void *arg){} 131 const volatile void *arg){}
123 void AnnotateFlushState(const char *file, int line){} 132 void AnnotateFlushState(const char *file, int line){}
124 133
125 #endif /* DYNAMIC_ANNOTATIONS_ENABLED == 1 */ 134 #endif /* DYNAMIC_ANNOTATIONS_ENABLED == 1
135 && DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
136
137 #if DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0
126 138
127 static int GetRunningOnValgrind(void) { 139 static int GetRunningOnValgrind(void) {
128 #ifdef RUNNING_ON_VALGRIND 140 #ifdef RUNNING_ON_VALGRIND
129 if (RUNNING_ON_VALGRIND) return 1; 141 if (RUNNING_ON_VALGRIND) return 1;
130 #endif 142 #endif
131 #ifdef _MSC_VER 143 #ifdef _MSC_VER
132 /* Visual Studio can complain about getenv, so use a windows equivalent. */ 144 /* Visual Studio can complain about getenv, so use a windows equivalent. */
133 char value[100] = "1"; /* something that is not "0" */ 145 char value[100] = "1"; /* something that is not "0" */
134 int res = GetEnvironmentVariableA("RUNNING_ON_VALGRIND", 146 int res = GetEnvironmentVariableA("RUNNING_ON_VALGRIND",
135 value, sizeof(value)); 147 value, sizeof(value));
(...skipping 16 matching lines...) Expand all
152 static volatile int running_on_valgrind = -1; 164 static volatile int running_on_valgrind = -1;
153 int local_running_on_valgrind = running_on_valgrind; 165 int local_running_on_valgrind = running_on_valgrind;
154 /* C doesn't have thread-safe initialization of statics, and we 166 /* C doesn't have thread-safe initialization of statics, and we
155 don't want to depend on pthread_once here, so hack it. */ 167 don't want to depend on pthread_once here, so hack it. */
156 ANNOTATE_BENIGN_RACE(&running_on_valgrind, "safe hack"); 168 ANNOTATE_BENIGN_RACE(&running_on_valgrind, "safe hack");
157 if (local_running_on_valgrind == -1) 169 if (local_running_on_valgrind == -1)
158 running_on_valgrind = local_running_on_valgrind = GetRunningOnValgrind(); 170 running_on_valgrind = local_running_on_valgrind = GetRunningOnValgrind();
159 return local_running_on_valgrind; 171 return local_running_on_valgrind;
160 } 172 }
161 173
174 #endif /* DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL == 0 */
175
162 /* See the comments in dynamic_annotations.h */ 176 /* See the comments in dynamic_annotations.h */
163 double ValgrindSlowdown(void) { 177 double ValgrindSlowdown(void) {
164 /* Same initialization hack as in RunningOnValgrind(). */ 178 /* Same initialization hack as in RunningOnValgrind(). */
165 static volatile double slowdown = 0.0; 179 static volatile double slowdown = 0.0;
166 double local_slowdown = slowdown; 180 double local_slowdown = slowdown;
167 ANNOTATE_BENIGN_RACE(&slowdown, "safe hack"); 181 ANNOTATE_BENIGN_RACE(&slowdown, "safe hack");
168 if (RunningOnValgrind() == 0) { 182 if (RunningOnValgrind() == 0) {
169 return 1.0; 183 return 1.0;
170 } 184 }
171 if (local_slowdown == 0.0) { 185 if (local_slowdown == 0.0) {
172 char *env = getenv("VALGRIND_SLOWDOWN"); 186 char *env = getenv("VALGRIND_SLOWDOWN");
173 slowdown = local_slowdown = env ? atof(env) : 50.0; 187 slowdown = local_slowdown = env ? atof(env) : 50.0;
174 } 188 }
175 return local_slowdown; 189 return local_slowdown;
176 } 190 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/base/dynamic_annotations.h ('k') | third_party/tcmalloc/chromium/src/base/elf_mem_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698