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

Side by Side Diff: third_party/zlib/x86.c

Issue 2023703002: Beginning work on GN build (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Really add //build. Add dart_bootstrap rule. Created 4 years, 6 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 | « third_party/zlib/x86.h ('k') | third_party/zlib/zconf.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * x86 feature check
3 *
4 * Copyright (C) 2013 Intel Corporation. All rights reserved.
5 * Author:
6 * Jim Kukunas
7 *
8 * For conditions of distribution and use, see copyright notice in zlib.h
9 */
10
11 #include "x86.h"
12
13 int x86_cpu_enable_simd = 0;
14
15 #ifndef _MSC_VER
16 #include <pthread.h>
17
18 pthread_once_t cpu_check_inited_once = PTHREAD_ONCE_INIT;
19 static void _x86_check_features(void);
20
21 void x86_check_features(void)
22 {
23 pthread_once(&cpu_check_inited_once, _x86_check_features);
24 }
25
26 static void _x86_check_features(void)
27 {
28 int x86_cpu_has_sse2;
29 int x86_cpu_has_sse42;
30 int x86_cpu_has_pclmulqdq;
31 unsigned eax, ebx, ecx, edx;
32
33 eax = 1;
34 #ifdef __i386__
35 __asm__ __volatile__ (
36 "xchg %%ebx, %1\n\t"
37 "cpuid\n\t"
38 "xchg %1, %%ebx\n\t"
39 : "+a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)
40 );
41 #else
42 __asm__ __volatile__ (
43 "cpuid\n\t"
44 : "+a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
45 );
46 #endif /* (__i386__) */
47
48 x86_cpu_has_sse2 = edx & 0x4000000;
49 x86_cpu_has_sse42 = ecx & 0x100000;
50 x86_cpu_has_pclmulqdq = ecx & 0x2;
51
52 x86_cpu_enable_simd = x86_cpu_has_sse2 &&
53 x86_cpu_has_sse42 &&
54 x86_cpu_has_pclmulqdq;
55 }
56 #else
57 #include <intrin.h>
58 #include <windows.h>
59
60 static BOOL CALLBACK _x86_check_features(PINIT_ONCE once,
61 PVOID param,
62 PVOID *context);
63 static INIT_ONCE cpu_check_inited_once = INIT_ONCE_STATIC_INIT;
64
65 void x86_check_features(void)
66 {
67 InitOnceExecuteOnce(&cpu_check_inited_once, _x86_check_features,
68 NULL, NULL);
69 }
70
71 static BOOL CALLBACK _x86_check_features(PINIT_ONCE once,
72 PVOID param,
73 PVOID *context)
74 {
75 int x86_cpu_has_sse2;
76 int x86_cpu_has_sse42;
77 int x86_cpu_has_pclmulqdq;
78 int regs[4];
79
80 __cpuid(regs, 1);
81
82 x86_cpu_has_sse2 = regs[3] & 0x4000000;
83 x86_cpu_has_sse42= regs[2] & 0x100000;
84 x86_cpu_has_pclmulqdq = regs[2] & 0x2;
85
86 x86_cpu_enable_simd = x86_cpu_has_sse2 &&
87 x86_cpu_has_sse42 &&
88 x86_cpu_has_pclmulqdq;
89 return TRUE;
90 }
91 #endif /* _MSC_VER */
OLDNEW
« no previous file with comments | « third_party/zlib/x86.h ('k') | third_party/zlib/zconf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698