blob: b40aa04921d0d9dea7258c3507efc64308708943 [file] [log] [blame]
Marat Dukhan547fa362017-03-03 02:47:26 -05001#pragma once
2#ifndef CPUINFO_H
3#define CPUINFO_H
4
5#ifndef __cplusplus
6 #include <stdbool.h>
7#endif
8
Hao Lu3617d5b2017-10-23 15:16:50 -07009#ifdef __APPLE__
10 #include <TargetConditionals.h>
11#endif
12
Marat Dukhan547fa362017-03-03 02:47:26 -050013#include <stdint.h>
14
15/* Identify architecture and define corresponding macro */
16
17#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_IX86)
18 #define CPUINFO_ARCH_X86 1
19#endif
20
21#if defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
22 #define CPUINFO_ARCH_X86_64 1
23#endif
24
25#if defined(__arm__) || defined(_M_ARM)
26 #define CPUINFO_ARCH_ARM 1
27#endif
28
29#if defined(__aarch64__) || defined(_M_ARM64)
30 #define CPUINFO_ARCH_ARM64 1
31#endif
32
33#if defined(__PPC64__) || defined(__powerpc64__) || defined(_ARCH_PPC64)
34 #define CPUINFO_ARCH_PPC64 1
35#endif
36
37#if defined(__pnacl__)
38 #define CPUINFO_ARCH_PNACL 1
39#endif
40
41#if defined(EMSCRIPTEN)
42 #define CPUINFO_ARCH_ASMJS 1
43#endif
44
45#if CPUINFO_ARCH_X86 && defined(_MSC_VER)
46 #define CPUINFO_ABI __cdecl
47#elif CPUINFO_ARCH_X86 && defined(__GNUC__)
48 #define CPUINFO_ABI __attribute__((__cdecl__))
49#else
50 #define CPUINFO_ABI
51#endif
52
53/* Define other architecture-specific macros as 0 */
54
55#ifndef CPUINFO_ARCH_X86
56 #define CPUINFO_ARCH_X86 0
57#endif
58
59#ifndef CPUINFO_ARCH_X86_64
60 #define CPUINFO_ARCH_X86_64 0
61#endif
62
63#ifndef CPUINFO_ARCH_ARM
64 #define CPUINFO_ARCH_ARM 0
65#endif
66
67#ifndef CPUINFO_ARCH_ARM64
68 #define CPUINFO_ARCH_ARM64 0
69#endif
70
71#ifndef CPUINFO_ARCH_PPC64
72 #define CPUINFO_ARCH_PPC64 0
73#endif
74
75#ifndef CPUINFO_ARCH_PNACL
76 #define CPUINFO_ARCH_PNACL 0
77#endif
78
79#ifndef CPUINFO_ARCH_ASMJS
80 #define CPUINFO_ARCH_ASMJS 0
81#endif
82
Marat Dukhan547fa362017-03-03 02:47:26 -050083#define CPUINFO_CACHE_UNIFIED 0x00000001
84#define CPUINFO_CACHE_INCLUSIVE 0x00000002
85#define CPUINFO_CACHE_COMPLEX_INDEXING 0x00000004
86
87struct cpuinfo_cache {
Marat Dukhan3045d4f2017-03-04 01:51:42 -050088 /** Cache size in bytes */
Marat Dukhan547fa362017-03-03 02:47:26 -050089 uint32_t size;
Marat Dukhan3045d4f2017-03-04 01:51:42 -050090 /** Number of ways of associativity */
Marat Dukhan547fa362017-03-03 02:47:26 -050091 uint32_t associativity;
Marat Dukhan3045d4f2017-03-04 01:51:42 -050092 /** Number of sets */
Marat Dukhan547fa362017-03-03 02:47:26 -050093 uint32_t sets;
Marat Dukhan3045d4f2017-03-04 01:51:42 -050094 /** Number of partitions */
Marat Dukhan547fa362017-03-03 02:47:26 -050095 uint32_t partitions;
Marat Dukhan3045d4f2017-03-04 01:51:42 -050096 /** Line size in bytes */
Marat Dukhan547fa362017-03-03 02:47:26 -050097 uint32_t line_size;
Marat Dukhan3045d4f2017-03-04 01:51:42 -050098 /**
99 * Binary characteristics of the cache (unified cache, inclusive cache, cache with complex indexing).
100 *
101 * @see CPUINFO_CACHE_UNIFIED, CPUINFO_CACHE_INCLUSIVE, CPUINFO_CACHE_COMPLEX_INDEXING
102 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500103 uint32_t flags;
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500104 /** Index of the first logical processor that shares this cache */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700105 uint32_t processor_start;
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500106 /** Number of logical processors that share this cache */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700107 uint32_t processor_count;
Marat Dukhan547fa362017-03-03 02:47:26 -0500108};
109
110struct cpuinfo_trace_cache {
111 uint32_t uops;
112 uint32_t associativity;
113};
114
115#define CPUINFO_PAGE_SIZE_4KB 0x1000
116#define CPUINFO_PAGE_SIZE_1MB 0x100000
117#define CPUINFO_PAGE_SIZE_2MB 0x200000
118#define CPUINFO_PAGE_SIZE_4MB 0x400000
119#define CPUINFO_PAGE_SIZE_16MB 0x1000000
120#define CPUINFO_PAGE_SIZE_1GB 0x40000000
121
122struct cpuinfo_tlb {
123 uint32_t entries;
124 uint32_t associativity;
125 uint64_t pages;
126};
127
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500128/** Vendor of processor core design */
Marat Dukhan547fa362017-03-03 02:47:26 -0500129enum cpuinfo_vendor {
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500130 /** Processor vendor is not known to the library, or the library failed to get vendor information from the OS. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500131 cpuinfo_vendor_unknown = 0,
Marat Dukhanb92e2ed2017-09-26 19:26:41 -0700132
Marat Dukhan547fa362017-03-03 02:47:26 -0500133 /* Active vendors of modern CPUs */
134
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500135 /**
136 * Intel Corporation. Vendor of x86, x86-64, IA64, and ARM processor microarchitectures.
137 *
138 * Sold its ARM design subsidiary in 2006. The last ARM processor design was released in 2004.
139 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500140 cpuinfo_vendor_intel = 1,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500141 /** Advanced Micro Devices, Inc. Vendor of x86 and x86-64 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500142 cpuinfo_vendor_amd = 2,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500143 /** ARM Holdings plc. Vendor of ARM and ARM64 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500144 cpuinfo_vendor_arm = 3,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500145 /** Qualcomm Incorporated. Vendor of ARM and ARM64 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500146 cpuinfo_vendor_qualcomm = 4,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500147 /** Apple Inc. Vendor of ARM and ARM64 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500148 cpuinfo_vendor_apple = 5,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500149 /** Samsung Electronics Co., Ltd. Vendir if ARM64 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500150 cpuinfo_vendor_samsung = 6,
Marat Dukhan93982f22017-10-20 13:10:23 -0700151 /** Nvidia Corporation. Vendor of ARM64-compatible processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500152 cpuinfo_vendor_nvidia = 7,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500153 /** MIPS Technologies, Inc. Vendor of MIPS processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500154 cpuinfo_vendor_mips = 8,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500155 /** International Business Machines Corporation. Vendor of PowerPC processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500156 cpuinfo_vendor_ibm = 9,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500157 /** Ingenic Semiconductor. Vendor of MIPS processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500158 cpuinfo_vendor_ingenic = 10,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500159 /**
160 * VIA Technologies, Inc. Vendor of x86 and x86-64 processor microarchitectures.
161 *
162 * Processors are designed by Centaur Technology, a subsidiary of VIA Technologies.
163 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500164 cpuinfo_vendor_via = 11,
Marat Dukhan92dae312017-05-09 14:10:17 +0000165 /** Cavium, Inc. Vendor of ARM64 processor microarchitectures. */
166 cpuinfo_vendor_cavium = 12,
Marat Dukhan547fa362017-03-03 02:47:26 -0500167
168 /* Active vendors of embedded CPUs */
169
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500170 /** Texas Instruments Inc. Vendor of ARM processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500171 cpuinfo_vendor_texas_instruments = 30,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500172 /** Marvell Technology Group Ltd. Vendor of ARM processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500173 cpuinfo_vendor_marvell = 31,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500174 /** RDC Semiconductor Co., Ltd. Vendor of x86 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500175 cpuinfo_vendor_rdc = 32,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500176 /** DM&P Electronics Inc. Vendor of x86 processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500177 cpuinfo_vendor_dmp = 33,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500178 /** Motorola, Inc. Vendor of PowerPC and ARM processor microarchitectures. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500179 cpuinfo_vendor_motorola = 34,
180
181 /* Defunct CPU vendors */
Marat Dukhanb92e2ed2017-09-26 19:26:41 -0700182
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500183 /**
184 * Transmeta Corporation. Vendor of x86 processor microarchitectures.
185 *
186 * Now defunct. The last processor design was released in 2004.
187 * Transmeta processors implemented VLIW ISA and used binary translation to execute x86 code.
188 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500189 cpuinfo_vendor_transmeta = 50,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500190 /**
191 * Cyrix Corporation. Vendor of x86 processor microarchitectures.
192 *
193 * Now defunct. The last processor design was released in 1996.
194 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500195 cpuinfo_vendor_cyrix = 51,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500196 /**
197 * Rise Technology. Vendor of x86 processor microarchitectures.
198 *
199 * Now defunct. The last processor design was released in 1999.
200 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500201 cpuinfo_vendor_rise = 52,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500202 /**
203 * National Semiconductor. Vendor of x86 processor microarchitectures.
204 *
205 * Sold its x86 design subsidiary in 1999. The last processor design was released in 1998.
206 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500207 cpuinfo_vendor_nsc = 53,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500208 /**
209 * Silicon Integrated Systems. Vendor of x86 processor microarchitectures.
210 *
211 * Sold its x86 design subsidiary in 2001. The last processor design was released in 2001.
212 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500213 cpuinfo_vendor_sis = 54,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500214 /**
215 * NexGen. Vendor of x86 processor microarchitectures.
216 *
217 * Now defunct. The last processor design was released in 1994.
218 * NexGen designed the first x86 microarchitecture which decomposed x86 instructions into simple microoperations.
219 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500220 cpuinfo_vendor_nexgen = 55,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500221 /**
222 * United Microelectronics Corporation. Vendor of x86 processor microarchitectures.
223 *
224 * Ceased x86 in the early 1990s. The last processor design was released in 1991.
225 * Designed U5C and U5D processors. Both are 486 level.
226 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500227 cpuinfo_vendor_umc = 56,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500228 /**
229 * Digital Equipment Corporation. Vendor of ARM processor microarchitecture.
230 *
231 * Sold its ARM designs in 1997. The last processor design was released in 1997.
232 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500233 cpuinfo_vendor_dec = 57,
234};
235
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500236/**
237 * Processor microarchitecture
238 *
239 * Processors with different microarchitectures often have different instruction performance characteristics,
240 * and may have dramatically different pipeline organization.
241 */
Marat Dukhan547fa362017-03-03 02:47:26 -0500242enum cpuinfo_uarch {
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500243 /** Microarchitecture is unknown, or the library failed to get information about the microarchitecture from OS */
Marat Dukhan547fa362017-03-03 02:47:26 -0500244 cpuinfo_uarch_unknown = 0,
245
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500246 /** Pentium and Pentium MMX microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500247 cpuinfo_uarch_p5 = 0x00100100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500248 /** Intel Quark microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500249 cpuinfo_uarch_quark = 0x00100101,
250
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500251 /** Pentium Pro, Pentium II, and Pentium III. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500252 cpuinfo_uarch_p6 = 0x00100200,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500253 /** Pentium M. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500254 cpuinfo_uarch_dothan = 0x00100201,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500255 /** Intel Core microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500256 cpuinfo_uarch_yonah = 0x00100202,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500257 /** Intel Core 2 microarchitecture on 65 nm process. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500258 cpuinfo_uarch_conroe = 0x00100203,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500259 /** Intel Core 2 microarchitecture on 45 nm process. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500260 cpuinfo_uarch_penryn = 0x00100204,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500261 /** Intel Nehalem and Westmere microarchitectures (Core i3/i5/i7 1st gen). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500262 cpuinfo_uarch_nehalem = 0x00100205,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500263 /** Intel Sandy Bridge microarchitecture (Core i3/i5/i7 2nd gen). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500264 cpuinfo_uarch_sandy_bridge = 0x00100206,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500265 /** Intel Ivy Bridge microarchitecture (Core i3/i5/i7 3rd gen). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500266 cpuinfo_uarch_ivy_bridge = 0x00100207,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500267 /** Intel Haswell microarchitecture (Core i3/i5/i7 4th gen). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500268 cpuinfo_uarch_haswell = 0x00100208,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500269 /** Intel Broadwell microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500270 cpuinfo_uarch_broadwell = 0x00100209,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500271 /** Intel Sky Lake microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500272 cpuinfo_uarch_sky_lake = 0x0010020A,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500273 /** Intel Kaby Lake microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500274 cpuinfo_uarch_kaby_lake = 0x0010020B,
275
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500276 /** Pentium 4 with Willamette, Northwood, or Foster cores. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500277 cpuinfo_uarch_willamette = 0x00100300,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500278 /** Pentium 4 with Prescott and later cores. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500279 cpuinfo_uarch_prescott = 0x00100301,
280
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500281 /** Intel Atom on 45 nm process. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500282 cpuinfo_uarch_bonnell = 0x00100400,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500283 /** Intel Atom on 32 nm process. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500284 cpuinfo_uarch_saltwell = 0x00100401,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500285 /** Intel Silvermont microarchitecture (22 nm out-of-order Atom). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500286 cpuinfo_uarch_silvermont = 0x00100402,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500287 /** Intel Airmont microarchitecture (14 nm out-of-order Atom). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500288 cpuinfo_uarch_airmont = 0x00100403,
289
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500290 /** Intel Knights Ferry HPC boards. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500291 cpuinfo_uarch_knights_ferry = 0x00100500,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500292 /** Intel Knights Corner HPC boards (aka Xeon Phi). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500293 cpuinfo_uarch_knights_corner = 0x00100501,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500294 /** Intel Knights Landing microarchitecture (second-gen MIC). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500295 cpuinfo_uarch_knights_landing = 0x00100502,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500296 /** Intel Knights Hill microarchitecture (third-gen MIC). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500297 cpuinfo_uarch_knights_hill = 0x00100503,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500298 /** Intel Knights Mill Xeon Phi. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500299 cpuinfo_uarch_knights_mill = 0x00100504,
300
Marat Dukhan3c982762017-05-08 06:16:45 +0000301 /** Intel/Marvell XScale series. */
302 cpuinfo_uarch_xscale = 0x00100600,
303
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500304 /** AMD K5. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500305 cpuinfo_uarch_k5 = 0x00200100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500306 /** AMD K6 and alike. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500307 cpuinfo_uarch_k6 = 0x00200101,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500308 /** AMD Athlon and Duron. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500309 cpuinfo_uarch_k7 = 0x00200102,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500310 /** AMD Athlon 64, Opteron 64. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500311 cpuinfo_uarch_k8 = 0x00200103,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500312 /** AMD Family 10h (Barcelona, Istambul, Magny-Cours). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500313 cpuinfo_uarch_k10 = 0x00200104,
314 /**
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500315 * AMD Bulldozer microarchitecture
316 * Zambezi FX-series CPUs, Zurich, Valencia and Interlagos Opteron CPUs.
Marat Dukhan547fa362017-03-03 02:47:26 -0500317 */
318 cpuinfo_uarch_bulldozer = 0x00200105,
319 /**
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500320 * AMD Piledriver microarchitecture
321 * Vishera FX-series CPUs, Trinity and Richland APUs, Delhi, Seoul, Abu Dhabi Opteron CPUs.
Marat Dukhan547fa362017-03-03 02:47:26 -0500322 */
323 cpuinfo_uarch_piledriver = 0x00200106,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500324 /** AMD Steamroller microarchitecture (Kaveri APUs). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500325 cpuinfo_uarch_steamroller = 0x00200107,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500326 /** AMD Excavator microarchitecture (Carizzo APUs). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500327 cpuinfo_uarch_excavator = 0x00200108,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500328 /** AMD Zen microarchitecture (Ryzen CPUs). */
Marat Dukhan547fa362017-03-03 02:47:26 -0500329 cpuinfo_uarch_zen = 0x00200109,
330
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500331 /** NSC Geode and AMD Geode GX and LX. */
Marat Dukhane25187d2017-04-16 05:03:07 -0400332 cpuinfo_uarch_geode = 0x00200200,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500333 /** AMD Bobcat mobile microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500334 cpuinfo_uarch_bobcat = 0x00200201,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500335 /** AMD Jaguar mobile microarchitecture. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500336 cpuinfo_uarch_jaguar = 0x00200202,
Marat Dukhan818e1992018-02-24 15:39:18 +0100337 /** AMD Puma mobile microarchitecture. */
338 cpuinfo_uarch_puma = 0x00200203,
Marat Dukhanb92e2ed2017-09-26 19:26:41 -0700339
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500340 /** ARM7 series. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500341 cpuinfo_uarch_arm7 = 0x00300100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500342 /** ARM9 series. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500343 cpuinfo_uarch_arm9 = 0x00300101,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500344 /** ARM 1136, ARM 1156, ARM 1176, or ARM 11MPCore. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500345 cpuinfo_uarch_arm11 = 0x00300102,
346
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500347 /** ARM Cortex-A5. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500348 cpuinfo_uarch_cortex_a5 = 0x00300205,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500349 /** ARM Cortex-A7. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500350 cpuinfo_uarch_cortex_a7 = 0x00300207,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500351 /** ARM Cortex-A8. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500352 cpuinfo_uarch_cortex_a8 = 0x00300208,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500353 /** ARM Cortex-A9. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500354 cpuinfo_uarch_cortex_a9 = 0x00300209,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500355 /** ARM Cortex-A12. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500356 cpuinfo_uarch_cortex_a12 = 0x00300212,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500357 /** ARM Cortex-A15. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500358 cpuinfo_uarch_cortex_a15 = 0x00300215,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500359 /** ARM Cortex-A17. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500360 cpuinfo_uarch_cortex_a17 = 0x00300217,
361
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500362 /** ARM Cortex-A32. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500363 cpuinfo_uarch_cortex_a32 = 0x00300332,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500364 /** ARM Cortex-A35. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500365 cpuinfo_uarch_cortex_a35 = 0x00300335,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500366 /** ARM Cortex-A53. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500367 cpuinfo_uarch_cortex_a53 = 0x00300353,
Marat Dukhana8fb3dd2017-08-09 13:49:39 -0700368 /** ARM Cortex-A55. */
369 cpuinfo_uarch_cortex_a55 = 0x00300355,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500370 /** ARM Cortex-A57. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500371 cpuinfo_uarch_cortex_a57 = 0x00300357,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500372 /** ARM Cortex-A72. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500373 cpuinfo_uarch_cortex_a72 = 0x00300372,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500374 /** ARM Cortex-A73. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500375 cpuinfo_uarch_cortex_a73 = 0x00300373,
Marat Dukhana8fb3dd2017-08-09 13:49:39 -0700376 /** ARM Cortex-A75. */
377 cpuinfo_uarch_cortex_a75 = 0x00300375,
Marat Dukhan547fa362017-03-03 02:47:26 -0500378
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500379 /** Qualcomm Scorpion. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500380 cpuinfo_uarch_scorpion = 0x00400100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500381 /** Qualcomm Krait. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500382 cpuinfo_uarch_krait = 0x00400101,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500383 /** Qualcomm Kryo. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500384 cpuinfo_uarch_kryo = 0x00400102,
385
Marat Dukhan93982f22017-10-20 13:10:23 -0700386 /** Nvidia Denver. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000387 cpuinfo_uarch_denver = 0x00500100,
388
Marat Dukhandcf096d2018-03-07 11:09:16 -0800389 /** Samsung Mongoose M1 (Exynos 8890 big cores). */
Marat Dukhana750f2a2018-03-07 11:07:48 -0800390 cpuinfo_uarch_mongoose_m1 = 0x00600100,
Marat Dukhandcf096d2018-03-07 11:09:16 -0800391 /** Samsung Mongoose M2 (Exynos 8895 big cores). */
Marat Dukhana750f2a2018-03-07 11:07:48 -0800392 cpuinfo_uarch_mongoose_m2 = 0x00600101,
Marat Dukhandcf096d2018-03-07 11:09:16 -0800393 /** Samsung Mongoose M3 (Exynos 9810 big cores). */
Marat Dukhana750f2a2018-03-07 11:07:48 -0800394 cpuinfo_uarch_mongoose_m3 = 0x00600102,
Marat Dukhan547fa362017-03-03 02:47:26 -0500395
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500396 /** Apple A6 and A6X processors. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000397 cpuinfo_uarch_swift = 0x00700100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500398 /** Apple A7 processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000399 cpuinfo_uarch_cyclone = 0x00700101,
Hao Lu922070c2017-10-18 16:29:02 -0700400 /** Apple A8 and A8X processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000401 cpuinfo_uarch_typhoon = 0x00700102,
Hao Lu922070c2017-10-18 16:29:02 -0700402 /** Apple A9 and A9X processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000403 cpuinfo_uarch_twister = 0x00700103,
Hao Lu922070c2017-10-18 16:29:02 -0700404 /** Apple A10 and A10X processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000405 cpuinfo_uarch_hurricane = 0x00700104,
Hao Lu922070c2017-10-18 16:29:02 -0700406 /** Apple A11 processor (big cores). */
407 cpuinfo_uarch_monsoon = 0x00700105,
408 /** Apple A11 processor (little cores). */
409 cpuinfo_uarch_mistral = 0x00700106,
Marat Dukhan92dae312017-05-09 14:10:17 +0000410
411 /** Cavium ThunderX. */
412 cpuinfo_uarch_thunderx = 0x00800100,
Marat Dukhan88718322017-08-24 10:12:20 -0700413
414 /** Marvell PJ4. */
415 cpuinfo_uarch_pj4 = 0x00900100,
Marat Dukhan547fa362017-03-03 02:47:26 -0500416};
417
418struct cpuinfo_processor {
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700419 /** SMT (hyperthread) ID within a core */
420 uint32_t smt_id;
421 /** Core containing this logical processor */
422 const struct cpuinfo_core* core;
423 /** Physical package containing this logical processor */
424 const struct cpuinfo_package* package;
Marat Dukhan15e1df92017-09-13 11:10:10 -0700425#if defined(__linux__)
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700426 /**
427 * Linux-specific ID for the logical processor:
428 * - Linux kernel exposes information about this logical processor in /sys/devices/system/cpu/cpu<linux_id>/
429 * - Bit <linux_id> in the cpu_set_t identifies this logical processor
430 */
Marat Dukhan15e1df92017-09-13 11:10:10 -0700431 int linux_id;
432#endif
Marat Dukhanb2fc4ab2018-02-19 22:43:26 -0800433#if defined(_WIN32)
434 /** Windows-specific ID for the group containing the logical processor. */
435 uint16_t windows_group_id;
436 /**
437 * Windows-specific ID of the logical processor within its group:
438 * - Bit <windows_processor_id> in the KAFFINITY mask identifies this logical processor within its group.
439 */
440 uint16_t windows_processor_id;
441#endif
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700442#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
443 /** APIC ID (unique x86-specific ID of the logical processor) */
444 uint32_t apic_id;
445#endif
Marat Dukhan547fa362017-03-03 02:47:26 -0500446 struct {
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700447 /** Level 1 instruction cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500448 const struct cpuinfo_cache* l1i;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700449 /** Level 1 data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500450 const struct cpuinfo_cache* l1d;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700451 /** Level 2 unified or data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500452 const struct cpuinfo_cache* l2;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700453 /** Level 3 unified or data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500454 const struct cpuinfo_cache* l3;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700455 /** Level 4 unified or data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500456 const struct cpuinfo_cache* l4;
457 } cache;
458};
459
460struct cpuinfo_core {
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700461 /** Index of the first logical processor on this core */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700462 uint32_t processor_start;
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700463 /** Number of logical processors on this core */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700464 uint32_t processor_count;
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700465 /** Core ID within a package */
466 uint32_t core_id;
467 /** Physical package containing this core */
468 const struct cpuinfo_package* package;
469 /** Vendor of the CPU microarchitecture for this core */
470 enum cpuinfo_vendor vendor;
471 /** CPU microarchitecture for this core */
472 enum cpuinfo_uarch uarch;
473#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
474 /** Value of CPUID leaf 1 EAX register for this core */
475 uint32_t cpuid;
476#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
477 /** Value of Main ID Register (MIDR) for this core */
478 uint32_t midr;
479#endif
Marat Dukhan547fa362017-03-03 02:47:26 -0500480};
481
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700482#define CPUINFO_PACKAGE_NAME_MAX 48
Marat Dukhanc40c7312017-09-21 16:08:18 -0700483#define CPUINFO_GPU_NAME_MAX 64
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700484
Marat Dukhan547fa362017-03-03 02:47:26 -0500485struct cpuinfo_package {
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700486 /** SoC or processor chip model name */
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700487 char name[CPUINFO_PACKAGE_NAME_MAX];
Hao Lu3617d5b2017-10-23 15:16:50 -0700488#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE)
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700489 /** Integrated GPU model name */
490 char gpu_name[CPUINFO_GPU_NAME_MAX];
491#endif
492 /** Index of the first logical processor on this physical package */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700493 uint32_t processor_start;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700494 /** Number of logical processors on this physical package */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700495 uint32_t processor_count;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700496 /** Index of the first core on this physical package */
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700497 uint32_t core_start;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700498 /** Number of cores on this physical package */
Marat Dukhan547fa362017-03-03 02:47:26 -0500499 uint32_t core_count;
Marat Dukhan547fa362017-03-03 02:47:26 -0500500};
501
502#ifdef __cplusplus
503extern "C" {
504#endif
505
Marat Dukhan53556512018-02-25 09:01:27 +0100506bool CPUINFO_ABI cpuinfo_initialize(void);
Marat Dukhan547fa362017-03-03 02:47:26 -0500507
508void CPUINFO_ABI cpuinfo_deinitialize(void);
509
510#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhanf720d102017-09-26 10:33:47 -0700511 /* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions instead. */
512 struct cpuinfo_x86_isa {
513 #if CPUINFO_ARCH_X86
514 bool rdtsc;
515 #endif
516 bool rdtscp;
517 bool rdpid;
518 bool sysenter;
519 #if CPUINFO_ARCH_X86
520 bool syscall;
521 #endif
522 bool msr;
523 bool clzero;
524 bool clflush;
525 bool clflushopt;
526 bool mwait;
527 bool mwaitx;
528 #if CPUINFO_ARCH_X86
529 bool emmx;
530 #endif
531 bool fxsave;
532 bool xsave;
533 #if CPUINFO_ARCH_X86
534 bool fpu;
535 bool mmx;
536 bool mmx_plus;
537 #endif
538 bool three_d_now;
539 bool three_d_now_plus;
540 #if CPUINFO_ARCH_X86
541 bool three_d_now_geode;
542 #endif
543 bool prefetch;
544 bool prefetchw;
545 bool prefetchwt1;
546 #if CPUINFO_ARCH_X86
547 bool daz;
548 bool sse;
549 bool sse2;
550 #endif
551 bool sse3;
552 bool ssse3;
553 bool sse4_1;
554 bool sse4_2;
555 bool sse4a;
556 bool misaligned_sse;
557 bool avx;
558 bool fma3;
559 bool fma4;
560 bool xop;
561 bool f16c;
562 bool avx2;
563 bool avx512f;
564 bool avx512pf;
565 bool avx512er;
566 bool avx512cd;
567 bool avx512dq;
568 bool avx512bw;
569 bool avx512vl;
570 bool avx512ifma;
571 bool avx512vbmi;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700572 bool avx512vbmi2;
573 bool avx512bitalg;
Marat Dukhanf720d102017-09-26 10:33:47 -0700574 bool avx512vpopcntdq;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700575 bool avx512vnni;
Marat Dukhanf720d102017-09-26 10:33:47 -0700576 bool avx512_4vnniw;
577 bool avx512_4fmaps;
578 bool hle;
579 bool rtm;
580 bool xtest;
581 bool mpx;
582 #if CPUINFO_ARCH_X86
583 bool cmov;
584 bool cmpxchg8b;
585 #endif
586 bool cmpxchg16b;
587 bool clwb;
588 bool movbe;
589 #if CPUINFO_ARCH_X86_64
590 bool lahf_sahf;
591 #endif
592 bool fs_gs_base;
593 bool lzcnt;
594 bool popcnt;
595 bool tbm;
596 bool bmi;
597 bool bmi2;
598 bool adx;
599 bool aes;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700600 bool vaes;
Marat Dukhanf720d102017-09-26 10:33:47 -0700601 bool pclmulqdq;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700602 bool vpclmulqdq;
603 bool gfni;
Marat Dukhanf720d102017-09-26 10:33:47 -0700604 bool rdrand;
605 bool rdseed;
606 bool sha;
607 bool rng;
608 bool ace;
609 bool ace2;
610 bool phe;
611 bool pmm;
612 bool lwp;
613 };
614
Marat Dukhan547fa362017-03-03 02:47:26 -0500615 extern struct cpuinfo_x86_isa cpuinfo_isa;
616#endif
617
Marat Dukhanf720d102017-09-26 10:33:47 -0700618static inline bool cpuinfo_has_x86_rdtsc(void) {
619 #if CPUINFO_ARCH_X86_64
620 return true;
621 #elif CPUINFO_ARCH_X86
622 #if defined(__ANDROID__)
623 return true;
624 #else
625 return cpuinfo_isa.rdtsc;
626 #endif
627 #else
628 return false;
629 #endif
630}
631
632static inline bool cpuinfo_has_x86_rdtscp(void) {
633 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
634 return cpuinfo_isa.rdtscp;
635 #else
636 return false;
637 #endif
638}
639
640static inline bool cpuinfo_has_x86_rdpid(void) {
641 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
642 return cpuinfo_isa.rdpid;
643 #else
644 return false;
645 #endif
646}
647
648static inline bool cpuinfo_has_x86_clzero(void) {
649 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
650 return cpuinfo_isa.clzero;
651 #else
652 return false;
653 #endif
654}
655
656static inline bool cpuinfo_has_x86_mwait(void) {
657 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
658 return cpuinfo_isa.mwait;
659 #else
660 return false;
661 #endif
662}
663
664static inline bool cpuinfo_has_x86_mwaitx(void) {
665 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
666 return cpuinfo_isa.mwaitx;
667 #else
668 return false;
669 #endif
670}
671
672static inline bool cpuinfo_has_x86_fxsave(void) {
673 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
674 return cpuinfo_isa.fxsave;
675 #else
676 return false;
677 #endif
678}
679
680static inline bool cpuinfo_has_x86_xsave(void) {
681 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
682 return cpuinfo_isa.xsave;
683 #else
684 return false;
685 #endif
686}
687
688static inline bool cpuinfo_has_x86_fpu(void) {
689 #if CPUINFO_ARCH_X86_64
690 return true;
691 #elif CPUINFO_ARCH_X86
692 #if defined(__ANDROID__)
693 return true;
694 #else
695 return cpuinfo_isa.fpu;
696 #endif
697 #else
698 return false;
699 #endif
700}
701
702static inline bool cpuinfo_has_x86_mmx(void) {
703 #if CPUINFO_ARCH_X86_64
704 return true;
705 #elif CPUINFO_ARCH_X86
706 #if defined(__ANDROID__)
707 return true;
708 #else
709 return cpuinfo_isa.mmx;
710 #endif
711 #else
712 return false;
713 #endif
714}
715
716static inline bool cpuinfo_has_x86_mmx_plus(void) {
717 #if CPUINFO_ARCH_X86_64
718 return true;
719 #elif CPUINFO_ARCH_X86
720 #if defined(__ANDROID__)
721 return true;
722 #else
723 return cpuinfo_isa.mmx_plus;
724 #endif
725 #else
726 return false;
727 #endif
728}
729
730static inline bool cpuinfo_has_x86_3dnow(void) {
731 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
732 return cpuinfo_isa.three_d_now;
733 #else
734 return false;
735 #endif
736}
737
738static inline bool cpuinfo_has_x86_3dnow_plus(void) {
739 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
740 return cpuinfo_isa.three_d_now_plus;
741 #else
742 return false;
743 #endif
744}
745
746static inline bool cpuinfo_has_x86_3dnow_geode(void) {
747 #if CPUINFO_ARCH_X86_64
748 return false;
749 #elif CPUINFO_ARCH_X86
750 #if defined(__ANDROID__)
751 return false;
752 #else
753 return cpuinfo_isa.three_d_now_geode;
754 #endif
755 #else
756 return false;
757 #endif
758}
759
760static inline bool cpuinfo_has_x86_prefetch(void) {
761 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
762 return cpuinfo_isa.prefetch;
763 #else
764 return false;
765 #endif
766}
767
768static inline bool cpuinfo_has_x86_prefetchw(void) {
769 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
770 return cpuinfo_isa.prefetchw;
771 #else
772 return false;
773 #endif
774}
775
776static inline bool cpuinfo_has_x86_prefetchwt1(void) {
777 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhan6022f802017-09-26 11:56:36 -0700778 return cpuinfo_isa.prefetchwt1;
Marat Dukhanf720d102017-09-26 10:33:47 -0700779 #else
780 return false;
781 #endif
782}
783
784static inline bool cpuinfo_has_x86_daz(void) {
785 #if CPUINFO_ARCH_X86_64
786 return true;
787 #elif CPUINFO_ARCH_X86
788 #if defined(__ANDROID__)
789 return true;
790 #else
791 return cpuinfo_isa.daz;
792 #endif
793 #else
794 return false;
795 #endif
796}
797
Marat Dukhan9da4c912017-09-26 10:53:28 -0700798static inline bool cpuinfo_has_x86_sse(void) {
799 #if CPUINFO_ARCH_X86_64
800 return true;
801 #elif CPUINFO_ARCH_X86
802 #if defined(__ANDROID__)
803 return true;
804 #else
805 return cpuinfo_isa.sse;
806 #endif
807 #else
808 return false;
809 #endif
810}
811
Marat Dukhanf720d102017-09-26 10:33:47 -0700812static inline bool cpuinfo_has_x86_sse2(void) {
813 #if CPUINFO_ARCH_X86_64
814 return true;
815 #elif CPUINFO_ARCH_X86
816 #if defined(__ANDROID__)
817 return true;
818 #else
819 return cpuinfo_isa.sse2;
820 #endif
821 #else
822 return false;
823 #endif
824}
825
826static inline bool cpuinfo_has_x86_sse3(void) {
827 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
828 #if defined(__ANDROID__)
829 return true;
830 #else
831 return cpuinfo_isa.sse3;
832 #endif
833 #else
834 return false;
835 #endif
836}
837
838static inline bool cpuinfo_has_x86_ssse3(void) {
839 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
840 #if defined(__ANDROID__)
841 return true;
842 #else
843 return cpuinfo_isa.ssse3;
844 #endif
845 #else
846 return false;
847 #endif
848}
849
850static inline bool cpuinfo_has_x86_sse4_1(void) {
851 #if CPUINFO_ARCH_X86_64
852 #if defined(__ANDROID__)
853 return true;
854 #else
855 return cpuinfo_isa.sse4_1;
856 #endif
857 #elif CPUINFO_ARCH_X86
858 return cpuinfo_isa.sse4_1;
859 #else
860 return false;
861 #endif
862}
863
864static inline bool cpuinfo_has_x86_sse4_2(void) {
865 #if CPUINFO_ARCH_X86_64
866 #if defined(__ANDROID__)
867 return true;
868 #else
869 return cpuinfo_isa.sse4_2;
870 #endif
871 #elif CPUINFO_ARCH_X86
872 return cpuinfo_isa.sse4_2;
873 #else
874 return false;
875 #endif
876}
877
878static inline bool cpuinfo_has_x86_sse4a(void) {
879 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
880 return cpuinfo_isa.sse4a;
881 #else
882 return false;
883 #endif
884}
885
886static inline bool cpuinfo_has_x86_misaligned_sse(void) {
887 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
888 return cpuinfo_isa.misaligned_sse;
889 #else
890 return false;
891 #endif
892}
893
894static inline bool cpuinfo_has_x86_avx(void) {
895 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
896 return cpuinfo_isa.avx;
897 #else
898 return false;
899 #endif
900}
901
902static inline bool cpuinfo_has_x86_fma3(void) {
903 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
904 return cpuinfo_isa.fma3;
905 #else
906 return false;
907 #endif
908}
909
910static inline bool cpuinfo_has_x86_fma4(void) {
911 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
912 return cpuinfo_isa.fma4;
913 #else
914 return false;
915 #endif
916}
917
918static inline bool cpuinfo_has_x86_xop(void) {
919 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
920 return cpuinfo_isa.xop;
921 #else
922 return false;
923 #endif
924}
925
926static inline bool cpuinfo_has_x86_f16c(void) {
927 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
928 return cpuinfo_isa.f16c;
929 #else
930 return false;
931 #endif
932}
933
934static inline bool cpuinfo_has_x86_avx2(void) {
935 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
936 return cpuinfo_isa.avx2;
937 #else
938 return false;
939 #endif
940}
941
942static inline bool cpuinfo_has_x86_avx512f(void) {
943 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
944 return cpuinfo_isa.avx512f;
945 #else
946 return false;
947 #endif
948}
949
950static inline bool cpuinfo_has_x86_avx512pf(void) {
951 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
952 return cpuinfo_isa.avx512pf;
953 #else
954 return false;
955 #endif
956}
957
958static inline bool cpuinfo_has_x86_avx512er(void) {
959 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
960 return cpuinfo_isa.avx512er;
961 #else
962 return false;
963 #endif
964}
965
966static inline bool cpuinfo_has_x86_avx512cd(void) {
967 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
968 return cpuinfo_isa.avx512cd;
969 #else
970 return false;
971 #endif
972}
973
974static inline bool cpuinfo_has_x86_avx512dq(void) {
975 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
976 return cpuinfo_isa.avx512dq;
977 #else
978 return false;
979 #endif
980}
981
982static inline bool cpuinfo_has_x86_avx512bw(void) {
983 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
984 return cpuinfo_isa.avx512bw;
985 #else
986 return false;
987 #endif
988}
989
990static inline bool cpuinfo_has_x86_avx512vl(void) {
991 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
992 return cpuinfo_isa.avx512vl;
993 #else
994 return false;
995 #endif
996}
997
998static inline bool cpuinfo_has_x86_avx512ifma(void) {
999 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1000 return cpuinfo_isa.avx512ifma;
1001 #else
1002 return false;
1003 #endif
1004}
1005
1006static inline bool cpuinfo_has_x86_avx512vbmi(void) {
1007 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1008 return cpuinfo_isa.avx512vbmi;
1009 #else
1010 return false;
1011 #endif
1012}
1013
Marat Dukhan861d21a2017-10-13 07:10:25 -07001014static inline bool cpuinfo_has_x86_avx512vbmi2(void) {
1015 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1016 return cpuinfo_isa.avx512vbmi2;
1017 #else
1018 return false;
1019 #endif
1020}
1021
1022static inline bool cpuinfo_has_x86_avx512bitalg(void) {
1023 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1024 return cpuinfo_isa.avx512bitalg;
1025 #else
1026 return false;
1027 #endif
1028}
1029
Marat Dukhanf720d102017-09-26 10:33:47 -07001030static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) {
1031 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1032 return cpuinfo_isa.avx512vpopcntdq;
1033 #else
1034 return false;
1035 #endif
1036}
1037
Marat Dukhan861d21a2017-10-13 07:10:25 -07001038static inline bool cpuinfo_has_x86_avx512vnni(void) {
Marat Dukhan6b33b232017-10-13 09:36:52 -07001039 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhan861d21a2017-10-13 07:10:25 -07001040 return cpuinfo_isa.avx512vnni;
1041 #else
1042 return false;
1043 #endif
1044}
1045
Marat Dukhanf720d102017-09-26 10:33:47 -07001046static inline bool cpuinfo_has_x86_avx512_4vnniw(void) {
1047 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1048 return cpuinfo_isa.avx512_4vnniw;
1049 #else
1050 return false;
1051 #endif
1052}
1053
1054static inline bool cpuinfo_has_x86_avx512_4fmaps(void) {
1055 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1056 return cpuinfo_isa.avx512_4fmaps;
1057 #else
1058 return false;
1059 #endif
1060}
1061
Marat Dukhan9e32e8d2017-09-26 11:02:37 -07001062static inline bool cpuinfo_has_x86_hle(void) {
1063 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1064 return cpuinfo_isa.hle;
1065 #else
1066 return false;
1067 #endif
1068}
1069
1070static inline bool cpuinfo_has_x86_rtm(void) {
1071 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1072 return cpuinfo_isa.rtm;
1073 #else
1074 return false;
1075 #endif
1076}
1077
1078static inline bool cpuinfo_has_x86_xtest(void) {
1079 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1080 return cpuinfo_isa.xtest;
1081 #else
1082 return false;
1083 #endif
1084}
1085
1086static inline bool cpuinfo_has_x86_mpx(void) {
1087 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1088 return cpuinfo_isa.mpx;
1089 #else
1090 return false;
1091 #endif
1092}
1093
Marat Dukhanf720d102017-09-26 10:33:47 -07001094static inline bool cpuinfo_has_x86_cmov(void) {
1095 #if CPUINFO_ARCH_X86_64
1096 return true;
1097 #elif CPUINFO_ARCH_X86
1098 return cpuinfo_isa.cmov;
1099 #else
1100 return false;
1101 #endif
1102}
1103
1104static inline bool cpuinfo_has_x86_cmpxchg8b(void) {
1105 #if CPUINFO_ARCH_X86_64
1106 return true;
1107 #elif CPUINFO_ARCH_X86
1108 return cpuinfo_isa.cmpxchg8b;
1109 #else
1110 return false;
1111 #endif
1112}
1113
1114static inline bool cpuinfo_has_x86_cmpxchg16b(void) {
1115 #if CPUINFO_ARCH_X86_64
1116 return cpuinfo_isa.cmpxchg16b;
1117 #else
1118 return false;
1119 #endif
1120}
1121
1122static inline bool cpuinfo_has_x86_clwb(void) {
1123 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1124 return cpuinfo_isa.clwb;
1125 #else
1126 return false;
1127 #endif
1128}
1129
1130static inline bool cpuinfo_has_x86_movbe(void) {
Marat Dukhan6022f802017-09-26 11:56:36 -07001131 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhanf720d102017-09-26 10:33:47 -07001132 return cpuinfo_isa.movbe;
1133 #else
1134 return false;
1135 #endif
1136}
1137
Marat Dukhan30401972017-09-26 18:35:52 -07001138static inline bool cpuinfo_has_x86_lahf_sahf(void) {
Marat Dukhanf720d102017-09-26 10:33:47 -07001139 #if CPUINFO_ARCH_X86
1140 return true;
1141 #elif CPUINFO_ARCH_X86_64
1142 return cpuinfo_isa.lahf_sahf;
1143 #else
1144 return false;
1145 #endif
1146}
1147
1148static inline bool cpuinfo_has_x86_lzcnt(void) {
1149 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1150 return cpuinfo_isa.lzcnt;
1151 #else
1152 return false;
1153 #endif
1154}
1155
1156static inline bool cpuinfo_has_x86_popcnt(void) {
1157 #if CPUINFO_ARCH_X86_64
1158 #if defined(__ANDROID__)
1159 return true;
1160 #else
1161 return cpuinfo_isa.popcnt;
1162 #endif
1163 #elif CPUINFO_ARCH_X86
1164 return cpuinfo_isa.popcnt;
1165 #else
1166 return false;
1167 #endif
1168}
1169
1170static inline bool cpuinfo_has_x86_tbm(void) {
1171 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1172 return cpuinfo_isa.tbm;
1173 #else
1174 return false;
1175 #endif
1176}
1177
1178static inline bool cpuinfo_has_x86_bmi(void) {
1179 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1180 return cpuinfo_isa.bmi;
1181 #else
1182 return false;
1183 #endif
1184}
1185
1186static inline bool cpuinfo_has_x86_bmi2(void) {
1187 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1188 return cpuinfo_isa.bmi2;
1189 #else
1190 return false;
1191 #endif
1192}
1193
1194static inline bool cpuinfo_has_x86_adx(void) {
1195 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1196 return cpuinfo_isa.adx;
1197 #else
1198 return false;
1199 #endif
1200}
1201
1202static inline bool cpuinfo_has_x86_aes(void) {
1203 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1204 return cpuinfo_isa.aes;
1205 #else
1206 return false;
1207 #endif
1208}
1209
Marat Dukhan861d21a2017-10-13 07:10:25 -07001210static inline bool cpuinfo_has_x86_vaes(void) {
1211 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1212 return cpuinfo_isa.vaes;
1213 #else
1214 return false;
1215 #endif
1216}
1217
Marat Dukhanf720d102017-09-26 10:33:47 -07001218static inline bool cpuinfo_has_x86_pclmulqdq(void) {
1219 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1220 return cpuinfo_isa.pclmulqdq;
1221 #else
1222 return false;
1223 #endif
1224}
1225
Marat Dukhan861d21a2017-10-13 07:10:25 -07001226static inline bool cpuinfo_has_x86_vpclmulqdq(void) {
1227 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1228 return cpuinfo_isa.vpclmulqdq;
1229 #else
1230 return false;
1231 #endif
1232}
1233
1234static inline bool cpuinfo_has_x86_gfni(void) {
1235 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1236 return cpuinfo_isa.gfni;
1237 #else
1238 return false;
1239 #endif
1240}
1241
Marat Dukhanf720d102017-09-26 10:33:47 -07001242static inline bool cpuinfo_has_x86_rdrand(void) {
1243 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1244 return cpuinfo_isa.rdrand;
1245 #else
1246 return false;
1247 #endif
1248}
1249
1250static inline bool cpuinfo_has_x86_rdseed(void) {
1251 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1252 return cpuinfo_isa.rdseed;
1253 #else
1254 return false;
1255 #endif
1256}
1257
1258static inline bool cpuinfo_has_x86_sha(void) {
1259 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1260 return cpuinfo_isa.sha;
1261 #else
1262 return false;
1263 #endif
1264}
1265
Marat Dukhanab42e7e2017-05-09 13:19:39 +00001266#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
Marat Dukhanf720d102017-09-26 10:33:47 -07001267 /* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions instead. */
1268 struct cpuinfo_arm_isa {
1269 #if CPUINFO_ARCH_ARM
1270 bool thumb;
1271 bool thumb2;
1272 bool thumbee;
1273 bool jazelle;
1274 bool armv5e;
1275 bool armv6;
1276 bool armv6k;
1277 bool armv7;
1278 bool armv7mp;
1279 bool idiv;
1280
1281 bool vfpv2;
1282 bool vfpv3;
1283 bool d32;
1284 bool fp16;
1285 bool fma;
1286
1287 bool wmmx;
1288 bool wmmx2;
1289 bool neon;
1290 #endif
1291 #if CPUINFO_ARCH_ARM64
1292 bool atomics;
1293 bool rdm;
1294 bool fp16arith;
1295 bool jscvt;
1296 bool fcma;
1297 #endif
1298
1299 bool aes;
1300 bool sha1;
1301 bool sha2;
1302 bool pmull;
1303 bool crc32;
1304 };
1305
Marat Dukhan3c982762017-05-08 06:16:45 +00001306 extern struct cpuinfo_arm_isa cpuinfo_isa;
1307#endif
1308
Marat Dukhanf720d102017-09-26 10:33:47 -07001309static inline bool cpuinfo_has_arm_thumb(void) {
1310 #if CPUINFO_ARCH_ARM
1311 return cpuinfo_isa.thumb;
1312 #else
1313 return false;
1314 #endif
1315}
1316
1317static inline bool cpuinfo_has_arm_thumb2(void) {
1318 #if CPUINFO_ARCH_ARM
1319 return cpuinfo_isa.thumb2;
1320 #else
1321 return false;
1322 #endif
1323}
1324
1325static inline bool cpuinfo_has_arm_v5e(void) {
1326 #if CPUINFO_ARCH_ARM
1327 return cpuinfo_isa.armv5e;
1328 #else
1329 return false;
1330 #endif
1331}
1332
1333static inline bool cpuinfo_has_arm_v6(void) {
1334 #if CPUINFO_ARCH_ARM
1335 return cpuinfo_isa.armv6;
1336 #else
1337 return false;
1338 #endif
1339}
1340
1341static inline bool cpuinfo_has_arm_v6k(void) {
1342 #if CPUINFO_ARCH_ARM
1343 return cpuinfo_isa.armv6k;
1344 #else
1345 return false;
1346 #endif
1347}
1348
1349static inline bool cpuinfo_has_arm_v7(void) {
1350 #if CPUINFO_ARCH_ARM
1351 return cpuinfo_isa.armv7;
1352 #else
1353 return false;
1354 #endif
1355}
1356
1357static inline bool cpuinfo_has_arm_v7mp(void) {
1358 #if CPUINFO_ARCH_ARM
1359 return cpuinfo_isa.armv7mp;
1360 #else
1361 return false;
1362 #endif
1363}
1364
1365static inline bool cpuinfo_has_arm_idiv(void) {
1366 #if CPUINFO_ARCH_ARM64
1367 return true;
1368 #elif CPUINFO_ARCH_ARM
1369 return cpuinfo_isa.idiv;
1370 #else
1371 return false;
1372 #endif
1373}
1374
1375static inline bool cpuinfo_has_arm_vfpv2(void) {
1376 #if CPUINFO_ARCH_ARM
1377 return cpuinfo_isa.vfpv2;
1378 #else
1379 return false;
1380 #endif
1381}
1382
1383static inline bool cpuinfo_has_arm_vfpv3(void) {
1384 #if CPUINFO_ARCH_ARM64
1385 return true;
1386 #elif CPUINFO_ARCH_ARM
1387 return cpuinfo_isa.vfpv3;
1388 #else
1389 return false;
1390 #endif
1391}
1392
1393static inline bool cpuinfo_has_arm_vfpv3_d32(void) {
1394 #if CPUINFO_ARCH_ARM64
1395 return true;
1396 #elif CPUINFO_ARCH_ARM
1397 return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32;
1398 #else
1399 return false;
1400 #endif
1401}
1402
1403static inline bool cpuinfo_has_arm_vfpv3_fp16(void) {
1404 #if CPUINFO_ARCH_ARM64
1405 return true;
1406 #elif CPUINFO_ARCH_ARM
1407 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16;
1408 #else
1409 return false;
1410 #endif
1411}
1412
1413static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) {
1414 #if CPUINFO_ARCH_ARM64
1415 return true;
1416 #elif CPUINFO_ARCH_ARM
1417 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32;
1418 #else
1419 return false;
1420 #endif
1421}
1422
Marat Dukhan6022f802017-09-26 11:56:36 -07001423static inline bool cpuinfo_has_arm_vfpv4(void) {
Marat Dukhanf720d102017-09-26 10:33:47 -07001424 #if CPUINFO_ARCH_ARM64
1425 return true;
1426 #elif CPUINFO_ARCH_ARM
1427 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma;
1428 #else
1429 return false;
1430 #endif
1431}
1432
Marat Dukhan6022f802017-09-26 11:56:36 -07001433static inline bool cpuinfo_has_arm_vfpv4_d32(void) {
Marat Dukhanf720d102017-09-26 10:33:47 -07001434 #if CPUINFO_ARCH_ARM64
1435 return true;
1436 #elif CPUINFO_ARCH_ARM
1437 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32;
1438 #else
1439 return false;
1440 #endif
1441}
1442
1443static inline bool cpuinfo_has_arm_wmmx(void) {
1444 #if CPUINFO_ARCH_ARM
1445 return cpuinfo_isa.wmmx;
1446 #else
1447 return false;
1448 #endif
1449}
1450
1451static inline bool cpuinfo_has_arm_wmmx2(void) {
1452 #if CPUINFO_ARCH_ARM
1453 return cpuinfo_isa.wmmx2;
1454 #else
1455 return false;
1456 #endif
1457}
1458
1459static inline bool cpuinfo_has_arm_neon(void) {
1460 #if CPUINFO_ARCH_ARM64
1461 return true;
1462 #elif CPUINFO_ARCH_ARM
1463 return cpuinfo_isa.neon;
1464 #else
1465 return false;
1466 #endif
1467}
1468
1469static inline bool cpuinfo_has_arm_neon_fp16(void) {
1470 #if CPUINFO_ARCH_ARM64
1471 return true;
1472 #elif CPUINFO_ARCH_ARM
1473 return cpuinfo_isa.neon && cpuinfo_isa.fp16;
1474 #else
1475 return false;
1476 #endif
1477}
1478
1479static inline bool cpuinfo_has_arm_neon_fma(void) {
1480 #if CPUINFO_ARCH_ARM64
1481 return true;
1482 #elif CPUINFO_ARCH_ARM
1483 return cpuinfo_isa.neon && cpuinfo_isa.fma;
1484 #else
1485 return false;
1486 #endif
1487}
1488
1489static inline bool cpuinfo_has_arm_atomics(void) {
1490 #if CPUINFO_ARCH_ARM64
1491 return cpuinfo_isa.atomics;
1492 #else
1493 return false;
1494 #endif
1495}
1496
1497static inline bool cpuinfo_has_arm_neon_rdm(void) {
1498 #if CPUINFO_ARCH_ARM64
1499 return cpuinfo_isa.rdm;
1500 #else
1501 return false;
1502 #endif
1503}
1504
1505static inline bool cpuinfo_has_arm_fp16_arith(void) {
1506 #if CPUINFO_ARCH_ARM64
1507 return cpuinfo_isa.fp16arith;
1508 #else
1509 return false;
1510 #endif
1511}
1512
1513static inline bool cpuinfo_has_arm_jscvt(void) {
1514 #if CPUINFO_ARCH_ARM64
1515 return cpuinfo_isa.jscvt;
1516 #else
1517 return false;
1518 #endif
1519}
1520
1521static inline bool cpuinfo_has_arm_fcma(void) {
1522 #if CPUINFO_ARCH_ARM64
1523 return cpuinfo_isa.fcma;
1524 #else
1525 return false;
1526 #endif
1527}
1528
1529static inline bool cpuinfo_has_arm_aes(void) {
1530 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1531 return cpuinfo_isa.aes;
1532 #else
1533 return false;
1534 #endif
1535}
1536
1537static inline bool cpuinfo_has_arm_sha1(void) {
1538 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1539 return cpuinfo_isa.sha1;
1540 #else
1541 return false;
1542 #endif
1543}
1544
1545static inline bool cpuinfo_has_arm_sha2(void) {
1546 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1547 return cpuinfo_isa.sha2;
1548 #else
1549 return false;
1550 #endif
1551}
1552
1553static inline bool cpuinfo_has_arm_pmull(void) {
1554 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1555 return cpuinfo_isa.pmull;
1556 #else
1557 return false;
1558 #endif
1559}
1560
1561static inline bool cpuinfo_has_arm_crc32(void) {
1562 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1563 return cpuinfo_isa.crc32;
1564 #else
1565 return false;
1566 #endif
1567}
1568
Marat Dukhan30401972017-09-26 18:35:52 -07001569const struct cpuinfo_processor* cpuinfo_get_processors(void);
1570const struct cpuinfo_core* cpuinfo_get_cores(void);
1571const struct cpuinfo_package* cpuinfo_get_packages(void);
1572const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void);
1573const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void);
1574const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void);
1575const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void);
1576const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void);
Marat Dukhan3045d4f2017-03-04 01:51:42 -05001577
Marat Dukhan30401972017-09-26 18:35:52 -07001578const struct cpuinfo_processor* cpuinfo_get_processor(uint32_t index);
1579const struct cpuinfo_core* cpuinfo_get_core(uint32_t index);
1580const struct cpuinfo_package* cpuinfo_get_package(uint32_t index);
1581const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index);
1582const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index);
1583const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index);
1584const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index);
1585const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index);
Marat Dukhan3045d4f2017-03-04 01:51:42 -05001586
Marat Dukhan30401972017-09-26 18:35:52 -07001587uint32_t cpuinfo_get_processors_count(void);
1588uint32_t cpuinfo_get_cores_count(void);
1589uint32_t cpuinfo_get_packages_count(void);
1590uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void);
1591uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void);
1592uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void);
1593uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void);
1594uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void);
Marat Dukhan8ecad1a2017-05-08 07:21:57 +00001595
Marat Dukhan30401972017-09-26 18:35:52 -07001596const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void);
1597const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void);
Marat Dukhan547fa362017-03-03 02:47:26 -05001598
1599#ifdef __cplusplus
1600} /* extern "C" */
1601#endif
1602
1603#endif /* CPUINFO_H */