Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: source/cpu_id.cc

Issue 1780473003: Remove most clang-cl special cases from cpu_id.cc (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "libyuv/cpu_id.h" 11 #include "libyuv/cpu_id.h"
12 12
13 #if defined(_MSC_VER) && !defined(__clang__) 13 #if defined(_MSC_VER)
14 #include <intrin.h> // For __cpuidex() 14 #include <intrin.h> // For __cpuidex()
15 #endif 15 #endif
16 #if !defined(__pnacl__) && !defined(__CLR_VER) && \ 16 #if !defined(__pnacl__) && !defined(__CLR_VER) && \
17 !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \ 17 !defined(__native_client__) && (defined(_M_IX86) || defined(_M_X64)) && \
18 defined(_MSC_VER) && !defined(__clang__) && (_MSC_FULL_VER >= 160040219) 18 defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219)
19 #include <immintrin.h> // For _xgetbv() 19 #include <immintrin.h> // For _xgetbv()
20 #endif 20 #endif
21 21
22 #if !defined(__native_client__) 22 #if !defined(__native_client__)
23 #include <stdlib.h> // For getenv() 23 #include <stdlib.h> // For getenv()
24 #endif 24 #endif
25 25
26 // For ArmCpuCaps() but unittested on all platforms 26 // For ArmCpuCaps() but unittested on all platforms
27 #include <stdio.h> 27 #include <stdio.h>
28 #include <string.h> 28 #include <string.h>
(...skipping 12 matching lines...) Expand all
41 #else 41 #else
42 #define SAFEBUFFERS 42 #define SAFEBUFFERS
43 #endif 43 #endif
44 44
45 // Low level cpuid for X86. 45 // Low level cpuid for X86.
46 #if (defined(_M_IX86) || defined(_M_X64) || \ 46 #if (defined(_M_IX86) || defined(_M_X64) || \
47 defined(__i386__) || defined(__x86_64__)) && \ 47 defined(__i386__) || defined(__x86_64__)) && \
48 !defined(__pnacl__) && !defined(__CLR_VER) 48 !defined(__pnacl__) && !defined(__CLR_VER)
49 LIBYUV_API 49 LIBYUV_API
50 void CpuId(uint32 info_eax, uint32 info_ecx, uint32* cpu_info) { 50 void CpuId(uint32 info_eax, uint32 info_ecx, uint32* cpu_info) {
51 #if defined(_MSC_VER) && !defined(__clang__) 51 #if defined(_MSC_VER)
52 // Visual C version uses intrinsic or inline x86 assembly. 52 // Visual C version uses intrinsic or inline x86 assembly.
53 #if (_MSC_FULL_VER >= 160040219) 53 #if (_MSC_FULL_VER >= 160040219)
54 __cpuidex((int*)(cpu_info), info_eax, info_ecx); 54 __cpuidex((int*)(cpu_info), info_eax, info_ecx);
55 #elif defined(_M_IX86) 55 #elif defined(_M_IX86)
56 __asm { 56 __asm {
57 mov eax, info_eax 57 mov eax, info_eax
58 mov ecx, info_ecx 58 mov ecx, info_ecx
59 mov edi, cpu_info 59 mov edi, cpu_info
60 cpuid 60 cpuid
61 mov [edi], eax 61 mov [edi], eax
62 mov [edi + 4], ebx 62 mov [edi + 4], ebx
63 mov [edi + 8], ecx 63 mov [edi + 8], ecx
64 mov [edi + 12], edx 64 mov [edi + 12], edx
65 } 65 }
66 #else // Visual C but not x86 66 #else // Visual C but not x86
67 if (info_ecx == 0) { 67 if (info_ecx == 0) {
68 __cpuid((int*)(cpu_info), info_eax); 68 __cpuid((int*)(cpu_info), info_eax);
69 } else { 69 } else {
70 cpu_info[3] = cpu_info[2] = cpu_info[1] = cpu_info[0] = 0; 70 cpu_info[3] = cpu_info[2] = cpu_info[1] = cpu_info[0] = 0;
71 } 71 }
72 #endif 72 #endif
73 // GCC version uses inline x86 assembly. 73 // GCC version uses inline x86 assembly.
74 #else // defined(_MSC_VER) && !defined(__clang__) 74 #else // defined(_MSC_VER)
75 uint32 info_ebx, info_edx; 75 uint32 info_ebx, info_edx;
76 asm volatile ( 76 asm volatile (
77 #if defined( __i386__) && defined(__PIC__) 77 #if defined( __i386__) && defined(__PIC__)
78 // Preserve ebx for fpic 32 bit. 78 // Preserve ebx for fpic 32 bit.
79 "mov %%ebx, %%edi \n" 79 "mov %%ebx, %%edi \n"
80 "cpuid \n" 80 "cpuid \n"
81 "xchg %%edi, %%ebx \n" 81 "xchg %%edi, %%ebx \n"
82 : "=D" (info_ebx), 82 : "=D" (info_ebx),
83 #else 83 #else
84 "cpuid \n" 84 "cpuid \n"
85 : "=b" (info_ebx), 85 : "=b" (info_ebx),
86 #endif // defined( __i386__) && defined(__PIC__) 86 #endif // defined( __i386__) && defined(__PIC__)
87 "+a" (info_eax), "+c" (info_ecx), "=d" (info_edx)); 87 "+a" (info_eax), "+c" (info_ecx), "=d" (info_edx));
88 cpu_info[0] = info_eax; 88 cpu_info[0] = info_eax;
89 cpu_info[1] = info_ebx; 89 cpu_info[1] = info_ebx;
90 cpu_info[2] = info_ecx; 90 cpu_info[2] = info_ecx;
91 cpu_info[3] = info_edx; 91 cpu_info[3] = info_edx;
92 #endif // defined(_MSC_VER) && !defined(__clang__) 92 #endif // defined(_MSC_VER)
93 } 93 }
94 #else // (defined(_M_IX86) || defined(_M_X64) ... 94 #else // (defined(_M_IX86) || defined(_M_X64) ...
95 LIBYUV_API 95 LIBYUV_API
96 void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) { 96 void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info) {
97 cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0; 97 cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
98 } 98 }
99 #endif 99 #endif
100 100
101 // For VS2010 and earlier emit can be used: 101 // For VS2010 and earlier emit can be used:
102 // _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 // For VS2010 and earlier. 102 // _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 // For VS2010 and earlier.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // Note that use of this function is not thread safe. 290 // Note that use of this function is not thread safe.
291 LIBYUV_API 291 LIBYUV_API
292 void MaskCpuFlags(int enable_flags) { 292 void MaskCpuFlags(int enable_flags) {
293 cpu_info_ = InitCpuFlags() & enable_flags; 293 cpu_info_ = InitCpuFlags() & enable_flags;
294 } 294 }
295 295
296 #ifdef __cplusplus 296 #ifdef __cplusplus
297 } // extern "C" 297 } // extern "C"
298 } // namespace libyuv 298 } // namespace libyuv
299 #endif 299 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698