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

Side by Side Diff: src/cpu.cc

Issue 145593003: v8config.h: set V8_CC_MSVC when building with clang-cl (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Introduce V8_LIBC_MSVCRT Created 6 years, 10 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 | « include/v8config.h ('k') | src/globals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "cpu.h" 28 #include "cpu.h"
29 29
30 #if V8_CC_MSVC 30 #if V8_LIBC_MSVCRT
31 #include <intrin.h> // __cpuid() 31 #include <intrin.h> // __cpuid()
32 #endif 32 #endif
33 #if V8_OS_POSIX 33 #if V8_OS_POSIX
34 #include <unistd.h> // sysconf() 34 #include <unistd.h> // sysconf()
35 #endif 35 #endif
36 #if V8_OS_QNX 36 #if V8_OS_QNX
37 #include <sys/syspage.h> // cpuinfo 37 #include <sys/syspage.h> // cpuinfo
38 #endif 38 #endif
39 39
40 #include <ctype.h> 40 #include <ctype.h>
41 #include <limits.h> 41 #include <limits.h>
42 #include <stdio.h> 42 #include <stdio.h>
43 #include <stdlib.h> 43 #include <stdlib.h>
44 #include <string.h> 44 #include <string.h>
45 #include <algorithm> 45 #include <algorithm>
46 46
47 #include "checks.h" 47 #include "checks.h"
48 #if V8_OS_WIN 48 #if V8_OS_WIN
49 #include "win32-headers.h" 49 #include "win32-headers.h"
50 #endif 50 #endif
51 51
52 namespace v8 { 52 namespace v8 {
53 namespace internal { 53 namespace internal {
54 54
55 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 55 #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
56 56
57 // Define __cpuid() for non-MSVC compilers. 57 // Define __cpuid() for non-MSVC libraries.
58 #if !V8_CC_MSVC 58 #if !V8_LIBC_MSVCRT
59 59
60 static V8_INLINE void __cpuid(int cpu_info[4], int info_type) { 60 static V8_INLINE void __cpuid(int cpu_info[4], int info_type) {
61 #if defined(__i386__) && defined(__pic__) 61 #if defined(__i386__) && defined(__pic__)
62 // Make sure to preserve ebx, which contains the pointer 62 // Make sure to preserve ebx, which contains the pointer
63 // to the GOT in case we're generating PIC. 63 // to the GOT in case we're generating PIC.
64 __asm__ volatile ( 64 __asm__ volatile (
65 "mov %%ebx, %%edi\n\t" 65 "mov %%ebx, %%edi\n\t"
66 "cpuid\n\t" 66 "cpuid\n\t"
67 "xchg %%edi, %%ebx\n\t" 67 "xchg %%edi, %%ebx\n\t"
68 : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 68 : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
69 : "a"(info_type) 69 : "a"(info_type)
70 ); 70 );
71 #else 71 #else
72 __asm__ volatile ( 72 __asm__ volatile (
73 "cpuid \n\t" 73 "cpuid \n\t"
74 : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 74 : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
75 : "a"(info_type) 75 : "a"(info_type)
76 ); 76 );
77 #endif // defined(__i386__) && defined(__pic__) 77 #endif // defined(__i386__) && defined(__pic__)
78 } 78 }
79 79
80 #endif // !V8_CC_MSVC 80 #endif // !V8_LIBC_MSVCRT
81 81
82 #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS 82 #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS
83 83
84 #if V8_OS_LINUX 84 #if V8_OS_LINUX
85 85
86 #if V8_HOST_ARCH_ARM 86 #if V8_HOST_ARCH_ARM
87 87
88 // See <uapi/asm/hwcap.h> kernel header. 88 // See <uapi/asm/hwcap.h> kernel header.
89 /* 89 /*
90 * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP 90 * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 #if V8_OS_WIN 496 #if V8_OS_WIN
497 SYSTEM_INFO info; 497 SYSTEM_INFO info;
498 GetSystemInfo(&info); 498 GetSystemInfo(&info);
499 return info.dwNumberOfProcessors; 499 return info.dwNumberOfProcessors;
500 #else 500 #else
501 return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); 501 return static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
502 #endif 502 #endif
503 } 503 }
504 504
505 } } // namespace v8::internal 505 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8config.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698