switch cpu flags to 0 for unitialized to avoid compare

R=harryjin@google.com
BUG=libyuv:512

Review URL: https://codereview.chromium.org/1418253002 .
This commit is contained in:
Frank Barchard 2015-10-23 10:57:42 -07:00
parent ad36ba5c48
commit 1502832a70
5 changed files with 8 additions and 8 deletions

2
DEPS
View File

@ -7,7 +7,7 @@ vars = {
# Roll the Chromium Git hash to pick up newer versions of all the
# dependencies and tools linked to in setup_links.py.
'chromium_revision': '5979bb6a5e5a298a2625693580925868cdf24ddb',
'chromium_revision': 'ec6107434ebf366554bb2af162d602ff34d480c1',
}
# NOTE: Prefer revision numbers to tags for svn deps. Use http rather than

View File

@ -1,6 +1,6 @@
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 1521
Version: 1522
License: BSD
License File: LICENSE

View File

@ -18,9 +18,8 @@ namespace libyuv {
extern "C" {
#endif
// TODO(fbarchard): Consider overlapping bits for different architectures.
// Internal flag to indicate cpuid requires initialization.
#define kCpuInit 0x1
static const int kCpuInitialized = 0x1;
// These flags are only valid on ARM processors.
static const int kCpuHasARM = 0x2;
@ -58,7 +57,7 @@ int ArmCpuCaps(const char* cpuinfo_name);
// returns non-zero if instruction set is detected
static __inline int TestCpuFlag(int test_flag) {
LIBYUV_API extern int cpu_info_;
return (cpu_info_ == kCpuInit ? InitCpuFlags() : cpu_info_) & test_flag;
return (!cpu_info_ ? InitCpuFlags() : cpu_info_) & test_flag;
}
// For testing, allow CPU flags to be disabled.

View File

@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1521
#define LIBYUV_VERSION 1522
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT

View File

@ -174,7 +174,7 @@ static int MipsCpuCaps(const char* search_string) {
// CPU detect function for SIMD instruction sets.
LIBYUV_API
int cpu_info_ = kCpuInit; // cpu_info is not initialized yet.
int cpu_info_ = 0; // cpu_info is not initialized yet.
// Test environment variable for disabling CPU features. Any non-zero value
// to disable. Zero ignored to make it easy to set the variable on/off.
@ -291,8 +291,9 @@ int InitCpuFlags(void) {
if (TestEnv("LIBYUV_DISABLE_ASM")) {
cpu_info = 0;
}
cpu_info |= kCpuInitialized;
cpu_info_ = cpu_info;
return cpu_info_;
return cpu_info;
}
// Note that use of this function is not thread safe.