diff --git a/README.chromium b/README.chromium index afb802c94..18f9071fd 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 89 +Version: 90 License: BSD License File: LICENSE diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index 263cd083c..2c3a9b38e 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.h @@ -24,7 +24,13 @@ static const int kCpuHasNEON = 4; static const int kCpuInitialized = 8; // Detect CPU has SSE2 etc. -bool TestCpuFlag(int flag); +// test_flag parameter should be one of kCpuHas constants above +// returns non-zero if instruction set is detected +static inline int TestCpuFlag(int test_flag) { + extern int cpu_info_; + extern int InitCpuFlags(); + return (cpu_info_ ? cpu_info_ : InitCpuFlags()) & test_flag; +} // For testing, allow CPU flags to be disabled. // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. diff --git a/source/cpu_id.cc b/source/cpu_id.cc index 418cd57b9..e784c2789 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -43,10 +43,9 @@ static inline void __cpuid(int cpu_info[4], int info_type) { namespace libyuv { // CPU detect function for SIMD instruction sets. -static int cpu_info_ = 0; +int cpu_info_ = 0; -// TODO(fbarchard): (cpu_info[2] & 0x10000000 ? kCpuHasAVX : 0) -static void InitCpuFlags() { +int InitCpuFlags() { #ifdef CPU_X86 int cpu_info[4]; __cpuid(cpu_info, 1); @@ -65,6 +64,7 @@ static void InitCpuFlags() { #else cpu_info_ = kCpuInitialized; #endif + return cpu_info_; } void MaskCpuFlags(int enable_flags) { @@ -72,11 +72,4 @@ void MaskCpuFlags(int enable_flags) { cpu_info_ = (cpu_info_ & enable_flags) | kCpuInitialized; } -bool TestCpuFlag(int flag) { - if (0 == cpu_info_) { - InitCpuFlags(); - } - return (cpu_info_ & flag) ? true : false; -} - } // namespace libyuv