diff --git a/README.chromium b/README.chromium index 660a3b088..6e57f3fdd 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 256 +Version: 258 License: BSD License File: LICENSE diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index 81bc84414..9f00fc692 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.h @@ -11,6 +11,29 @@ #ifndef INCLUDE_LIBYUV_CPU_ID_H_ #define INCLUDE_LIBYUV_CPU_ID_H_ +#ifdef _MSC_VER +#include // For __cpuid() +#endif + +// TODO(fbarchard): Use cpuid.h when gcc 4.4 is used on OSX and Linux. +#if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__) +static __inline void __cpuid(int cpu_info[4], int info_type) { + asm volatile ( + "mov %%ebx, %%edi \n" + "cpuid \n" + "xchg %%edi, %%ebx \n" + : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) + : "a"(info_type)); +} +#elif defined(__i386__) || defined(__x86_64__) +static __inline void __cpuid(int cpu_info[4], int info_type) { + asm volatile ( + "cpuid \n" + : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) + : "a"(info_type)); +} +#endif + #ifdef __cplusplus namespace libyuv { extern "C" { @@ -51,3 +74,4 @@ void MaskCpuFlags(int enable_flags); #endif #endif // INCLUDE_LIBYUV_CPU_ID_H_ + diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 95d57ddb6..ce7a81d9f 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,7 +11,7 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 256 +#define LIBYUV_VERSION 258 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/cpu_id.cc b/source/cpu_id.cc index d83a88a55..a2f6c9b51 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -11,9 +11,6 @@ #include "libyuv/cpu_id.h" #include // For getenv() -#ifdef _MSC_VER -#include // For __cpuid() -#endif // For ArmCpuCaps() but unittested on all platforms #include @@ -21,25 +18,6 @@ #include "libyuv/basic_types.h" // For CPU_X86 -// TODO(fbarchard): Use cpuid.h when gcc 4.4 is used on OSX and Linux. -#if (defined(__pic__) || defined(__APPLE__)) && defined(__i386__) -static __inline void __cpuid(int cpu_info[4], int info_type) { - asm volatile ( - "mov %%ebx, %%edi \n" - "cpuid \n" - "xchg %%edi, %%ebx \n" - : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) - : "a"(info_type)); -} -#elif defined(__i386__) || defined(__x86_64__) -static __inline void __cpuid(int cpu_info[4], int info_type) { - asm volatile ( - "cpuid \n" - : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) - : "a"(info_type)); -} -#endif - #ifdef __cplusplus namespace libyuv { extern "C" { diff --git a/unit_test/cpu_test.cc b/unit_test/cpu_test.cc index e350561cd..7def0b375 100644 --- a/unit_test/cpu_test.cc +++ b/unit_test/cpu_test.cc @@ -23,26 +23,48 @@ TEST_F(libyuvTest, TestVersion) { } TEST_F(libyuvTest, TestCpuHas) { -#if LIBYUV_VERSION >= 236 int has_x86 = TestCpuFlag(kCpuHasX86); printf("Has X86 %d\n", has_x86); -#endif int has_sse2 = TestCpuFlag(kCpuHasSSE2); printf("Has SSE2 %d\n", has_sse2); int has_ssse3 = TestCpuFlag(kCpuHasSSSE3); printf("Has SSSE3 %d\n", has_ssse3); -#if LIBYUV_VERSION >= 236 int has_sse41 = TestCpuFlag(kCpuHasSSE41); printf("Has SSE4.1 %d\n", has_sse41); -#endif -#if LIBYUV_VERSION >= 238 int has_arm = TestCpuFlag(kCpuHasARM); printf("Has ARM %d\n", has_arm); -#endif int has_neon = TestCpuFlag(kCpuHasNEON); printf("Has NEON %d\n", has_neon); } +// Known Vendor IDs are: +// AuthenticAMD AMD processor +// CentaurHauls Centaur processor +// CyrixInstead Cyrix processor +// GenuineIntel Intel processor +// GenuineTMx86 Transmeta processor +// Geode by NSC National Semiconductor processor +// NexGenDriven NexGen processor +// RiseRiseRise Rise Technology processor +// SiS SiS SiS SiS processor +// UMC UMC UMC UMC processor +#if defined(__i386__) || defined(__x86_64__) || \ + defined(_M_IX86) || defined(_M_X64) +TEST_F(libyuvTest, TestCpuId) { + int has_x86 = TestCpuFlag(kCpuHasX86); + if (has_x86) { + int cpu_info[4]; + __cpuid(cpu_info, 0); + cpu_info[0] = cpu_info[1]; // Reorder output + cpu_info[1] = cpu_info[3]; + cpu_info[2] = cpu_info[2]; + cpu_info[3] = 0; + printf("Cpu Vendor: %s\n", reinterpret_cast(&cpu_info[0])); + EXPECT_EQ(12, strlen(reinterpret_cast(&cpu_info[0]))); + } +} +#endif + // For testing purposes call the proc/cpuinfo parser directly extern "C" int ArmCpuCaps(const char* cpuinfoname);