Commit 1502832a authored by Frank Barchard's avatar Frank Barchard

switch cpu flags to 0 for unitialized to avoid compare

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

Review URL: https://codereview.chromium.org/1418253002 .
parent ad36ba5c
...@@ -7,7 +7,7 @@ vars = { ...@@ -7,7 +7,7 @@ vars = {
# Roll the Chromium Git hash to pick up newer versions of all the # Roll the Chromium Git hash to pick up newer versions of all the
# dependencies and tools linked to in setup_links.py. # 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 # NOTE: Prefer revision numbers to tags for svn deps. Use http rather than
......
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1521 Version: 1522
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -18,9 +18,8 @@ namespace libyuv { ...@@ -18,9 +18,8 @@ namespace libyuv {
extern "C" { extern "C" {
#endif #endif
// TODO(fbarchard): Consider overlapping bits for different architectures.
// Internal flag to indicate cpuid requires initialization. // Internal flag to indicate cpuid requires initialization.
#define kCpuInit 0x1 static const int kCpuInitialized = 0x1;
// These flags are only valid on ARM processors. // These flags are only valid on ARM processors.
static const int kCpuHasARM = 0x2; static const int kCpuHasARM = 0x2;
...@@ -58,7 +57,7 @@ int ArmCpuCaps(const char* cpuinfo_name); ...@@ -58,7 +57,7 @@ int ArmCpuCaps(const char* cpuinfo_name);
// returns non-zero if instruction set is detected // returns non-zero if instruction set is detected
static __inline int TestCpuFlag(int test_flag) { static __inline int TestCpuFlag(int test_flag) {
LIBYUV_API extern int cpu_info_; 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. // For testing, allow CPU flags to be disabled.
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1521 #define LIBYUV_VERSION 1522
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -174,7 +174,7 @@ static int MipsCpuCaps(const char* search_string) { ...@@ -174,7 +174,7 @@ static int MipsCpuCaps(const char* search_string) {
// CPU detect function for SIMD instruction sets. // CPU detect function for SIMD instruction sets.
LIBYUV_API 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 // 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. // to disable. Zero ignored to make it easy to set the variable on/off.
...@@ -291,8 +291,9 @@ int InitCpuFlags(void) { ...@@ -291,8 +291,9 @@ int InitCpuFlags(void) {
if (TestEnv("LIBYUV_DISABLE_ASM")) { if (TestEnv("LIBYUV_DISABLE_ASM")) {
cpu_info = 0; cpu_info = 0;
} }
cpu_info |= kCpuInitialized;
cpu_info_ = cpu_info; cpu_info_ = cpu_info;
return cpu_info_; return cpu_info;
} }
// Note that use of this function is not thread safe. // Note that use of this function is not thread safe.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment