| Index: source/libvpx/third_party/libyuv/source/cpu_id.cc
|
| diff --git a/source/libvpx/third_party/libyuv/source/cpu_id.cc b/source/libvpx/third_party/libyuv/source/cpu_id.cc
|
| index 1efa265258107fee002291ff7fab52a78d7b310a..8a10b00835844242d3530fc0958d0c5633693ff4 100644
|
| --- a/source/libvpx/third_party/libyuv/source/cpu_id.cc
|
| +++ b/source/libvpx/third_party/libyuv/source/cpu_id.cc
|
| @@ -10,13 +10,12 @@
|
|
|
| #include "libyuv/cpu_id.h"
|
|
|
| -#if defined(_MSC_VER) && !defined(__clang__)
|
| +#if (defined(_MSC_VER) && !defined(__clang__)) && !defined(__clang__)
|
| #include <intrin.h> // For __cpuidex()
|
| #endif
|
| #if !defined(__pnacl__) && !defined(__CLR_VER) && \
|
| - !defined(__native_client__) && \
|
| - defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219) && \
|
| - (defined(_M_IX86) || defined(_M_X64))
|
| + !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \
|
| + defined(_MSC_VER) && !defined(__clang__) && (_MSC_FULL_VER >= 160040219)
|
| #include <immintrin.h> // For _xgetbv()
|
| #endif
|
|
|
| @@ -37,23 +36,23 @@ extern "C" {
|
|
|
| // For functions that use the stack and have runtime checks for overflow,
|
| // use SAFEBUFFERS to avoid additional check.
|
| -#if defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219)
|
| +#if (defined(_MSC_VER) && !defined(__clang__)) && (_MSC_FULL_VER >= 160040219)
|
| #define SAFEBUFFERS __declspec(safebuffers)
|
| #else
|
| #define SAFEBUFFERS
|
| #endif
|
|
|
| -// Low level cpuid for X86. Returns zeros on other CPUs.
|
| -#if !defined(__pnacl__) && !defined(__CLR_VER) && \
|
| - (defined(_M_IX86) || defined(_M_X64) || \
|
| - defined(__i386__) || defined(__x86_64__))
|
| +// Low level cpuid for X86.
|
| +#if (defined(_M_IX86) || defined(_M_X64) || \
|
| + defined(__i386__) || defined(__x86_64__)) && \
|
| + !defined(__pnacl__) && !defined(__CLR_VER)
|
| LIBYUV_API
|
| void CpuId(uint32 info_eax, uint32 info_ecx, uint32* cpu_info) {
|
| -#if defined(_MSC_VER) && !defined(__clang__)
|
| +#if (defined(_MSC_VER) && !defined(__clang__)) && !defined(__clang__)
|
| +// Visual C version uses intrinsic or inline x86 assembly.
|
| #if (_MSC_FULL_VER >= 160040219)
|
| __cpuidex((int*)(cpu_info), info_eax, info_ecx);
|
| -#endif
|
| -#if defined(_M_IX86)
|
| +#elif defined(_M_IX86)
|
| __asm {
|
| mov eax, info_eax
|
| mov ecx, info_ecx
|
| @@ -71,7 +70,8 @@ void CpuId(uint32 info_eax, uint32 info_ecx, uint32* cpu_info) {
|
| cpu_info[3] = cpu_info[2] = cpu_info[1] = cpu_info[0] = 0;
|
| }
|
| #endif
|
| -#else // defined(_MSC_VER)
|
| +// GCC version uses inline x86 assembly.
|
| +#else // (defined(_MSC_VER) && !defined(__clang__)) && !defined(__clang__)
|
| uint32 info_ebx, info_edx;
|
| asm volatile ( // NOLINT
|
| #if defined( __i386__) && defined(__PIC__)
|
| @@ -89,36 +89,37 @@ void CpuId(uint32 info_eax, uint32 info_ecx, uint32* cpu_info) {
|
| cpu_info[1] = info_ebx;
|
| cpu_info[2] = info_ecx;
|
| cpu_info[3] = info_edx;
|
| -#endif // defined(_MSC_VER)
|
| +#endif // (defined(_MSC_VER) && !defined(__clang__)) && !defined(__clang__)
|
| +}
|
| +#else // (defined(_M_IX86) || defined(_M_X64) ...
|
| +LIBYUV_API
|
| +void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) {
|
| + cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
|
| }
|
| +#endif
|
|
|
| -#if !defined(__native_client__)
|
| +// TODO(fbarchard): Enable xgetbv when validator supports it.
|
| +#if (defined(_M_IX86) || defined(_M_X64) || \
|
| + defined(__i386__) || defined(__x86_64__)) && \
|
| + !defined(__pnacl__) && !defined(__CLR_VER) && !defined(__native_client__)
|
| #define HAS_XGETBV
|
| // X86 CPUs have xgetbv to detect OS saves high parts of ymm registers.
|
| int TestOsSaveYmm() {
|
| uint32 xcr0 = 0u;
|
| -#if defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219)
|
| +#if (defined(_MSC_VER) && !defined(__clang__)) && (_MSC_FULL_VER >= 160040219)
|
| xcr0 = (uint32)(_xgetbv(0)); // VS2010 SP1 required.
|
| -#endif
|
| -#if defined(_M_IX86) && defined(_MSC_VER)
|
| +#elif defined(_M_IX86) && defined(_MSC_VER) && !defined(__clang__)
|
| __asm {
|
| xor ecx, ecx // xcr 0
|
| _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 // For VS2010 and earlier.
|
| mov xcr0, eax
|
| }
|
| -#endif
|
| -#if defined(__i386__) || defined(__x86_64__)
|
| +#elif defined(__i386__) || defined(__x86_64__)
|
| asm(".byte 0x0f, 0x01, 0xd0" : "=a" (xcr0) : "c" (0) : "%edx");
|
| -#endif // defined(_MSC_VER)
|
| +#endif // defined(__i386__) || defined(__x86_64__)
|
| return((xcr0 & 6) == 6); // Is ymm saved?
|
| }
|
| -#endif // !defined(__native_client__)
|
| -#else
|
| -LIBYUV_API
|
| -void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) {
|
| - cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
|
| -}
|
| -#endif
|
| +#endif // defined(_M_IX86) || defined(_M_X64) ..
|
|
|
| // based on libvpx arm_cpudetect.c
|
| // For Arm, but public to allow testing on any CPU
|
|
|