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

Side by Side Diff: third_party/tcmalloc/chromium/src/base/commandlineflags.h

Issue 842673002: [tcmalloc]: Remove calls to __system_property_get in tcmalloc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « third_party/tcmalloc/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // elsewhere. 47 // elsewhere.
48 #ifndef BASE_COMMANDLINEFLAGS_H_ 48 #ifndef BASE_COMMANDLINEFLAGS_H_
49 #define BASE_COMMANDLINEFLAGS_H_ 49 #define BASE_COMMANDLINEFLAGS_H_
50 50
51 #include <config.h> 51 #include <config.h>
52 #include <string> 52 #include <string>
53 #include <string.h> // for memchr 53 #include <string.h> // for memchr
54 #include <stdlib.h> // for getenv 54 #include <stdlib.h> // for getenv
55 #include "base/basictypes.h" 55 #include "base/basictypes.h"
56 56
57 #if defined(__ANDROID__) || defined(ANDROID)
58 #include <sys/system_properties.h>
59 #endif
60
61 #define DECLARE_VARIABLE(type, name) \ 57 #define DECLARE_VARIABLE(type, name) \
62 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead {\ 58 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead {\
63 extern PERFTOOLS_DLL_DECL type FLAGS_##name; \ 59 extern PERFTOOLS_DLL_DECL type FLAGS_##name; \
64 } \ 60 } \
65 using FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead::FLAGS_ ##name 61 using FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead::FLAGS_ ##name
66 62
67 #define DEFINE_VARIABLE(type, name, value, meaning) \ 63 #define DEFINE_VARIABLE(type, name, value, meaning) \
68 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead {\ 64 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead {\
69 PERFTOOLS_DLL_DECL type FLAGS_##name(value); \ 65 PERFTOOLS_DLL_DECL type FLAGS_##name(value); \
70 char FLAGS_no##name; \ 66 char FLAGS_no##name; \
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_## name 104 using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_## name
109 #define DEFINE_string(name, value, meaning) \ 105 #define DEFINE_string(name, value, meaning) \
110 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \ 106 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \
111 const char* FLAGS_##name = value; \ 107 const char* FLAGS_##name = value; \
112 char FLAGS_no##name; \ 108 char FLAGS_no##name; \
113 } \ 109 } \
114 using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_## name 110 using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_## name
115 111
116 // These macros (could be functions, but I don't want to bother with a .cc 112 // These macros (could be functions, but I don't want to bother with a .cc
117 // file), make it easier to initialize flags from the environment. 113 // file), make it easier to initialize flags from the environment.
118 // They are functions in Android because __system_property_get() doesn't
119 // return a string.
120 114
121 #if defined(ENABLE_PROFILING) 115 #if defined(ENABLE_PROFILING)
122 116
123 #if defined(__ANDROID__) || defined(ANDROID) 117 #if defined(__ANDROID__) || defined(ANDROID)
124 118 #error TCMalloc does not support profiling on Android
jar (doing other things) 2015/01/07 19:39:57 I'm missing the connection to TCMalloc. You are r
jar (doing other things) 2015/01/07 20:28:20 <DOH!> I misread the file name (I stopped looking
125 // Returns a pointer to a static variable. The string pointed by the returned
126 // pointer must not be modified.
127 inline const char* const EnvToString(const char* envname, const char* dflt) {
128 static char system_property_value[PROP_VALUE_MAX];
129 if (__system_property_get(envname, system_property_value) > 0)
130 return system_property_value;
131 return dflt;
132 }
133
134 inline bool EnvToBool(const char* envname, bool dflt) {
135 static const char kTrueValues[] = "tTyY1";
136 char system_property_value[PROP_VALUE_MAX];
137 if (__system_property_get(envname, system_property_value) > 0)
138 return memchr(kTrueValues, system_property_value[0], sizeof(kTrueValues));
139 return dflt;
140 }
141
142 inline int EnvToInt(const char* envname, int dflt) {
143 char system_property_value[PROP_VALUE_MAX];
144 if (__system_property_get(envname, system_property_value) > 0)
145 return strtol(system_property_value, NULL, 10);
146 return dflt;
147 }
148
149 inline int64 EnvToInt64(const char* envname, int64 dflt) {
150 char system_property_value[PROP_VALUE_MAX];
151 if (__system_property_get(envname, system_property_value) > 0)
152 return strtoll(system_property_value, NULL, 10);
153 return dflt;
154 }
155
156 inline double EnvToDouble(const char* envname, double dflt) {
157 char system_property_value[PROP_VALUE_MAX];
158 if (__system_property_get(envname, system_property_value) > 0)
159 return strtod(system_property_value, NULL);
160 return dflt;
161 }
162
163 #else // defined(__ANDROID__) || defined(ANDROID)
164 119
165 #define EnvToString(envname, dflt) \ 120 #define EnvToString(envname, dflt) \
166 (!getenv(envname) ? (dflt) : getenv(envname)) 121 (!getenv(envname) ? (dflt) : getenv(envname))
167 122
168 #define EnvToBool(envname, dflt) \ 123 #define EnvToBool(envname, dflt) \
169 (!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL) 124 (!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
170 125
171 #define EnvToInt(envname, dflt) \ 126 #define EnvToInt(envname, dflt) \
172 (!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10)) 127 (!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
173 128
174 #define EnvToInt64(envname, dflt) \ 129 #define EnvToInt64(envname, dflt) \
175 (!getenv(envname) ? (dflt) : strtoll(getenv(envname), NULL, 10)) 130 (!getenv(envname) ? (dflt) : strtoll(getenv(envname), NULL, 10))
176 131
177 #define EnvToDouble(envname, dflt) \ 132 #define EnvToDouble(envname, dflt) \
178 (!getenv(envname) ? (dflt) : strtod(getenv(envname), NULL)) 133 (!getenv(envname) ? (dflt) : strtod(getenv(envname), NULL))
179 134
180 #endif // defined(__ANDROID__) || defined(ANDROID) 135 #endif // defined(__ANDROID__) || defined(ANDROID)
181 136
182 #else // defined(ENABLE_PROFILING) 137 #else // defined(ENABLE_PROFILING)
183 138
184 #define EnvToString(envname, dflt) (dflt) 139 #define EnvToString(envname, dflt) (dflt)
185 #define EnvToBool(envname, dflt) (dflt) 140 #define EnvToBool(envname, dflt) (dflt)
186 #define EnvToInt(envname, dflt) (dflt) 141 #define EnvToInt(envname, dflt) (dflt)
187 #define EnvToInt64(envname, dflt) (dflt) 142 #define EnvToInt64(envname, dflt) (dflt)
188 #define EnvToDouble(envname, dflt) (dflt) 143 #define EnvToDouble(envname, dflt) (dflt)
189 144
190 #endif // defined(ENABLE_PROFILING) 145 #endif // defined(ENABLE_PROFILING)
191 146
192 #endif // BASE_COMMANDLINEFLAGS_H_ 147 #endif // BASE_COMMANDLINEFLAGS_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698