From 451a7541b7fbbcb85199dfbc6faccdb1955ea1d5 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Mon, 14 Jul 2014 17:48:35 +0000 Subject: [PATCH] Check number of functions available to cpuid before fetching function 7 results. BUG=343 TESTED=local test on Windows. R=brettw@chromium.org, tpsiaki@google.com Review URL: https://webrtc-codereview.appspot.com/12969004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@1035 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/cpu_id.cc | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.chromium b/README.chromium index ad2c87647..65936a123 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1032 +Version: 1035 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 1417d84cc..6534a39fa 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1032 +#define LIBYUV_VERSION 1035 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/cpu_id.cc b/source/cpu_id.cc index 41880e504..2e0d61d20 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -188,10 +188,14 @@ LIBYUV_API SAFEBUFFERS int InitCpuFlags(void) { #if !defined(__pnacl__) && !defined(__CLR_VER) && defined(CPU_X86) + uint32 cpu_info0[4] = { 0, 0, 0, 0 }; uint32 cpu_info1[4] = { 0, 0, 0, 0 }; uint32 cpu_info7[4] = { 0, 0, 0, 0 }; + CpuId(0, 0, cpu_info0); CpuId(1, 0, cpu_info1); - CpuId(7, 0, cpu_info7); + if (cpu_info0[0] >= 7) { + CpuId(7, 0, cpu_info7); + } cpu_info_ = ((cpu_info1[3] & 0x04000000) ? kCpuHasSSE2 : 0) | ((cpu_info1[2] & 0x00000200) ? kCpuHasSSSE3 : 0) | ((cpu_info1[2] & 0x00080000) ? kCpuHasSSE41 : 0) | @@ -199,6 +203,7 @@ int InitCpuFlags(void) { ((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0) | ((cpu_info1[2] & 0x00001000) ? kCpuHasFMA3 : 0) | kCpuHasX86; + #ifdef HAS_XGETBV if ((cpu_info1[2] & 0x18000000) == 0x18000000 && // AVX and OSSave TestOsSaveYmm()) { // Saves YMM.