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

Side by Side Diff: source/cpu_id.cc

Issue 1418253002: switch cpu flags to 0 for unitialized to avoid compare (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: bump chromium to lkgr Created 5 years, 2 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 | « include/libyuv/version.h ('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 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return kCpuHasMIPS_DSP; 167 return kCpuHasMIPS_DSP;
168 } 168 }
169 } 169 }
170 fclose(f); 170 fclose(f);
171 return 0; 171 return 0;
172 } 172 }
173 #endif 173 #endif
174 174
175 // CPU detect function for SIMD instruction sets. 175 // CPU detect function for SIMD instruction sets.
176 LIBYUV_API 176 LIBYUV_API
177 int cpu_info_ = kCpuInit; // cpu_info is not initialized yet. 177 int cpu_info_ = 0; // cpu_info is not initialized yet.
178 178
179 // Test environment variable for disabling CPU features. Any non-zero value 179 // Test environment variable for disabling CPU features. Any non-zero value
180 // to disable. Zero ignored to make it easy to set the variable on/off. 180 // to disable. Zero ignored to make it easy to set the variable on/off.
181 #if !defined(__native_client__) && !defined(_M_ARM) 181 #if !defined(__native_client__) && !defined(_M_ARM)
182 182
183 static LIBYUV_BOOL TestEnv(const char* name) { 183 static LIBYUV_BOOL TestEnv(const char* name) {
184 const char* var = getenv(name); 184 const char* var = getenv(name);
185 if (var) { 185 if (var) {
186 if (var[0] != '0') { 186 if (var[0] != '0') {
187 return LIBYUV_TRUE; 187 return LIBYUV_TRUE;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 cpu_info = ArmCpuCaps("/proc/cpuinfo"); 284 cpu_info = ArmCpuCaps("/proc/cpuinfo");
285 #endif 285 #endif
286 cpu_info |= kCpuHasARM; 286 cpu_info |= kCpuHasARM;
287 if (TestEnv("LIBYUV_DISABLE_NEON")) { 287 if (TestEnv("LIBYUV_DISABLE_NEON")) {
288 cpu_info &= ~kCpuHasNEON; 288 cpu_info &= ~kCpuHasNEON;
289 } 289 }
290 #endif // __arm__ 290 #endif // __arm__
291 if (TestEnv("LIBYUV_DISABLE_ASM")) { 291 if (TestEnv("LIBYUV_DISABLE_ASM")) {
292 cpu_info = 0; 292 cpu_info = 0;
293 } 293 }
294 cpu_info |= kCpuInitialized;
294 cpu_info_ = cpu_info; 295 cpu_info_ = cpu_info;
295 return cpu_info_; 296 return cpu_info;
296 } 297 }
297 298
298 // Note that use of this function is not thread safe. 299 // Note that use of this function is not thread safe.
299 LIBYUV_API 300 LIBYUV_API
300 void MaskCpuFlags(int enable_flags) { 301 void MaskCpuFlags(int enable_flags) {
301 cpu_info_ = InitCpuFlags() & enable_flags; 302 cpu_info_ = InitCpuFlags() & enable_flags;
302 } 303 }
303 304
304 #ifdef __cplusplus 305 #ifdef __cplusplus
305 } // extern "C" 306 } // extern "C"
306 } // namespace libyuv 307 } // namespace libyuv
307 #endif 308 #endif
OLDNEW
« no previous file with comments | « include/libyuv/version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698