blob: cae8af9b031f6c755c7c9f24af030c1a6b131de0 [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 Dukhanb92e2ed2017-09-26 19:26:41 -0700337
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500338 /** ARM7 series. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500339 cpuinfo_uarch_arm7 = 0x00300100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500340 /** ARM9 series. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500341 cpuinfo_uarch_arm9 = 0x00300101,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500342 /** ARM 1136, ARM 1156, ARM 1176, or ARM 11MPCore. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500343 cpuinfo_uarch_arm11 = 0x00300102,
344
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500345 /** ARM Cortex-A5. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500346 cpuinfo_uarch_cortex_a5 = 0x00300205,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500347 /** ARM Cortex-A7. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500348 cpuinfo_uarch_cortex_a7 = 0x00300207,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500349 /** ARM Cortex-A8. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500350 cpuinfo_uarch_cortex_a8 = 0x00300208,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500351 /** ARM Cortex-A9. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500352 cpuinfo_uarch_cortex_a9 = 0x00300209,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500353 /** ARM Cortex-A12. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500354 cpuinfo_uarch_cortex_a12 = 0x00300212,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500355 /** ARM Cortex-A15. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500356 cpuinfo_uarch_cortex_a15 = 0x00300215,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500357 /** ARM Cortex-A17. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500358 cpuinfo_uarch_cortex_a17 = 0x00300217,
359
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500360 /** ARM Cortex-A32. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500361 cpuinfo_uarch_cortex_a32 = 0x00300332,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500362 /** ARM Cortex-A35. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500363 cpuinfo_uarch_cortex_a35 = 0x00300335,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500364 /** ARM Cortex-A53. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500365 cpuinfo_uarch_cortex_a53 = 0x00300353,
Marat Dukhana8fb3dd2017-08-09 13:49:39 -0700366 /** ARM Cortex-A55. */
367 cpuinfo_uarch_cortex_a55 = 0x00300355,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500368 /** ARM Cortex-A57. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500369 cpuinfo_uarch_cortex_a57 = 0x00300357,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500370 /** ARM Cortex-A72. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500371 cpuinfo_uarch_cortex_a72 = 0x00300372,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500372 /** ARM Cortex-A73. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500373 cpuinfo_uarch_cortex_a73 = 0x00300373,
Marat Dukhana8fb3dd2017-08-09 13:49:39 -0700374 /** ARM Cortex-A75. */
375 cpuinfo_uarch_cortex_a75 = 0x00300375,
Marat Dukhan547fa362017-03-03 02:47:26 -0500376
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500377 /** Qualcomm Scorpion. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500378 cpuinfo_uarch_scorpion = 0x00400100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500379 /** Qualcomm Krait. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500380 cpuinfo_uarch_krait = 0x00400101,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500381 /** Qualcomm Kryo. */
Marat Dukhan547fa362017-03-03 02:47:26 -0500382 cpuinfo_uarch_kryo = 0x00400102,
383
Marat Dukhan93982f22017-10-20 13:10:23 -0700384 /** Nvidia Denver. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000385 cpuinfo_uarch_denver = 0x00500100,
386
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500387 /** Samsung Mongoose. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000388 cpuinfo_uarch_mongoose = 0x00600100,
Marat Dukhan547fa362017-03-03 02:47:26 -0500389
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500390 /** Apple A6 and A6X processors. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000391 cpuinfo_uarch_swift = 0x00700100,
Marat Dukhan3045d4f2017-03-04 01:51:42 -0500392 /** Apple A7 processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000393 cpuinfo_uarch_cyclone = 0x00700101,
Hao Lu922070c2017-10-18 16:29:02 -0700394 /** Apple A8 and A8X processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000395 cpuinfo_uarch_typhoon = 0x00700102,
Hao Lu922070c2017-10-18 16:29:02 -0700396 /** Apple A9 and A9X processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000397 cpuinfo_uarch_twister = 0x00700103,
Hao Lu922070c2017-10-18 16:29:02 -0700398 /** Apple A10 and A10X processor. */
Marat Dukhan3c982762017-05-08 06:16:45 +0000399 cpuinfo_uarch_hurricane = 0x00700104,
Hao Lu922070c2017-10-18 16:29:02 -0700400 /** Apple A11 processor (big cores). */
401 cpuinfo_uarch_monsoon = 0x00700105,
402 /** Apple A11 processor (little cores). */
403 cpuinfo_uarch_mistral = 0x00700106,
Marat Dukhan92dae312017-05-09 14:10:17 +0000404
405 /** Cavium ThunderX. */
406 cpuinfo_uarch_thunderx = 0x00800100,
Marat Dukhan88718322017-08-24 10:12:20 -0700407
408 /** Marvell PJ4. */
409 cpuinfo_uarch_pj4 = 0x00900100,
Marat Dukhan547fa362017-03-03 02:47:26 -0500410};
411
412struct cpuinfo_processor {
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700413 /** SMT (hyperthread) ID within a core */
414 uint32_t smt_id;
415 /** Core containing this logical processor */
416 const struct cpuinfo_core* core;
417 /** Physical package containing this logical processor */
418 const struct cpuinfo_package* package;
Marat Dukhan15e1df92017-09-13 11:10:10 -0700419#if defined(__linux__)
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700420 /**
421 * Linux-specific ID for the logical processor:
422 * - Linux kernel exposes information about this logical processor in /sys/devices/system/cpu/cpu<linux_id>/
423 * - Bit <linux_id> in the cpu_set_t identifies this logical processor
424 */
Marat Dukhan15e1df92017-09-13 11:10:10 -0700425 int linux_id;
426#endif
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700427#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
428 /** APIC ID (unique x86-specific ID of the logical processor) */
429 uint32_t apic_id;
430#endif
Marat Dukhan547fa362017-03-03 02:47:26 -0500431 struct {
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700432 /** Level 1 instruction cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500433 const struct cpuinfo_cache* l1i;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700434 /** Level 1 data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500435 const struct cpuinfo_cache* l1d;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700436 /** Level 2 unified or data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500437 const struct cpuinfo_cache* l2;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700438 /** Level 3 unified or data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500439 const struct cpuinfo_cache* l3;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700440 /** Level 4 unified or data cache */
Marat Dukhan547fa362017-03-03 02:47:26 -0500441 const struct cpuinfo_cache* l4;
442 } cache;
443};
444
445struct cpuinfo_core {
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700446 /** Index of the first logical processor on this core */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700447 uint32_t processor_start;
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700448 /** Number of logical processors on this core */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700449 uint32_t processor_count;
Marat Dukhan2d37dc42017-09-25 01:32:37 -0700450 /** Core ID within a package */
451 uint32_t core_id;
452 /** Physical package containing this core */
453 const struct cpuinfo_package* package;
454 /** Vendor of the CPU microarchitecture for this core */
455 enum cpuinfo_vendor vendor;
456 /** CPU microarchitecture for this core */
457 enum cpuinfo_uarch uarch;
458#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
459 /** Value of CPUID leaf 1 EAX register for this core */
460 uint32_t cpuid;
461#elif CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
462 /** Value of Main ID Register (MIDR) for this core */
463 uint32_t midr;
464#endif
Marat Dukhan547fa362017-03-03 02:47:26 -0500465};
466
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700467#define CPUINFO_PACKAGE_NAME_MAX 48
Marat Dukhanc40c7312017-09-21 16:08:18 -0700468#define CPUINFO_GPU_NAME_MAX 64
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700469
Marat Dukhan547fa362017-03-03 02:47:26 -0500470struct cpuinfo_package {
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700471 /** SoC or processor chip model name */
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700472 char name[CPUINFO_PACKAGE_NAME_MAX];
Hao Lu3617d5b2017-10-23 15:16:50 -0700473#if defined(__ANDROID__) || (defined(__APPLE__) && TARGET_OS_IPHONE)
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700474 /** Integrated GPU model name */
475 char gpu_name[CPUINFO_GPU_NAME_MAX];
476#endif
477 /** Index of the first logical processor on this physical package */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700478 uint32_t processor_start;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700479 /** Number of logical processors on this physical package */
Marat Dukhanab3a1272017-08-25 23:20:07 -0700480 uint32_t processor_count;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700481 /** Index of the first core on this physical package */
Marat Dukhanfb4fbe02017-09-13 00:51:05 -0700482 uint32_t core_start;
Marat Dukhan8f79efb2017-09-25 11:17:21 -0700483 /** Number of cores on this physical package */
Marat Dukhan547fa362017-03-03 02:47:26 -0500484 uint32_t core_count;
Marat Dukhan547fa362017-03-03 02:47:26 -0500485};
486
487#ifdef __cplusplus
488extern "C" {
489#endif
490
491void CPUINFO_ABI cpuinfo_initialize(void);
492
493void CPUINFO_ABI cpuinfo_deinitialize(void);
494
495#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhanf720d102017-09-26 10:33:47 -0700496 /* This structure is not a part of stable API. Use cpuinfo_has_x86_* functions instead. */
497 struct cpuinfo_x86_isa {
498 #if CPUINFO_ARCH_X86
499 bool rdtsc;
500 #endif
501 bool rdtscp;
502 bool rdpid;
503 bool sysenter;
504 #if CPUINFO_ARCH_X86
505 bool syscall;
506 #endif
507 bool msr;
508 bool clzero;
509 bool clflush;
510 bool clflushopt;
511 bool mwait;
512 bool mwaitx;
513 #if CPUINFO_ARCH_X86
514 bool emmx;
515 #endif
516 bool fxsave;
517 bool xsave;
518 #if CPUINFO_ARCH_X86
519 bool fpu;
520 bool mmx;
521 bool mmx_plus;
522 #endif
523 bool three_d_now;
524 bool three_d_now_plus;
525 #if CPUINFO_ARCH_X86
526 bool three_d_now_geode;
527 #endif
528 bool prefetch;
529 bool prefetchw;
530 bool prefetchwt1;
531 #if CPUINFO_ARCH_X86
532 bool daz;
533 bool sse;
534 bool sse2;
535 #endif
536 bool sse3;
537 bool ssse3;
538 bool sse4_1;
539 bool sse4_2;
540 bool sse4a;
541 bool misaligned_sse;
542 bool avx;
543 bool fma3;
544 bool fma4;
545 bool xop;
546 bool f16c;
547 bool avx2;
548 bool avx512f;
549 bool avx512pf;
550 bool avx512er;
551 bool avx512cd;
552 bool avx512dq;
553 bool avx512bw;
554 bool avx512vl;
555 bool avx512ifma;
556 bool avx512vbmi;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700557 bool avx512vbmi2;
558 bool avx512bitalg;
Marat Dukhanf720d102017-09-26 10:33:47 -0700559 bool avx512vpopcntdq;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700560 bool avx512vnni;
Marat Dukhanf720d102017-09-26 10:33:47 -0700561 bool avx512_4vnniw;
562 bool avx512_4fmaps;
563 bool hle;
564 bool rtm;
565 bool xtest;
566 bool mpx;
567 #if CPUINFO_ARCH_X86
568 bool cmov;
569 bool cmpxchg8b;
570 #endif
571 bool cmpxchg16b;
572 bool clwb;
573 bool movbe;
574 #if CPUINFO_ARCH_X86_64
575 bool lahf_sahf;
576 #endif
577 bool fs_gs_base;
578 bool lzcnt;
579 bool popcnt;
580 bool tbm;
581 bool bmi;
582 bool bmi2;
583 bool adx;
584 bool aes;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700585 bool vaes;
Marat Dukhanf720d102017-09-26 10:33:47 -0700586 bool pclmulqdq;
Marat Dukhan861d21a2017-10-13 07:10:25 -0700587 bool vpclmulqdq;
588 bool gfni;
Marat Dukhanf720d102017-09-26 10:33:47 -0700589 bool rdrand;
590 bool rdseed;
591 bool sha;
592 bool rng;
593 bool ace;
594 bool ace2;
595 bool phe;
596 bool pmm;
597 bool lwp;
598 };
599
Marat Dukhan547fa362017-03-03 02:47:26 -0500600 extern struct cpuinfo_x86_isa cpuinfo_isa;
601#endif
602
Marat Dukhanf720d102017-09-26 10:33:47 -0700603static inline bool cpuinfo_has_x86_rdtsc(void) {
604 #if CPUINFO_ARCH_X86_64
605 return true;
606 #elif CPUINFO_ARCH_X86
607 #if defined(__ANDROID__)
608 return true;
609 #else
610 return cpuinfo_isa.rdtsc;
611 #endif
612 #else
613 return false;
614 #endif
615}
616
617static inline bool cpuinfo_has_x86_rdtscp(void) {
618 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
619 return cpuinfo_isa.rdtscp;
620 #else
621 return false;
622 #endif
623}
624
625static inline bool cpuinfo_has_x86_rdpid(void) {
626 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
627 return cpuinfo_isa.rdpid;
628 #else
629 return false;
630 #endif
631}
632
633static inline bool cpuinfo_has_x86_clzero(void) {
634 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
635 return cpuinfo_isa.clzero;
636 #else
637 return false;
638 #endif
639}
640
641static inline bool cpuinfo_has_x86_mwait(void) {
642 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
643 return cpuinfo_isa.mwait;
644 #else
645 return false;
646 #endif
647}
648
649static inline bool cpuinfo_has_x86_mwaitx(void) {
650 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
651 return cpuinfo_isa.mwaitx;
652 #else
653 return false;
654 #endif
655}
656
657static inline bool cpuinfo_has_x86_fxsave(void) {
658 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
659 return cpuinfo_isa.fxsave;
660 #else
661 return false;
662 #endif
663}
664
665static inline bool cpuinfo_has_x86_xsave(void) {
666 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
667 return cpuinfo_isa.xsave;
668 #else
669 return false;
670 #endif
671}
672
673static inline bool cpuinfo_has_x86_fpu(void) {
674 #if CPUINFO_ARCH_X86_64
675 return true;
676 #elif CPUINFO_ARCH_X86
677 #if defined(__ANDROID__)
678 return true;
679 #else
680 return cpuinfo_isa.fpu;
681 #endif
682 #else
683 return false;
684 #endif
685}
686
687static inline bool cpuinfo_has_x86_mmx(void) {
688 #if CPUINFO_ARCH_X86_64
689 return true;
690 #elif CPUINFO_ARCH_X86
691 #if defined(__ANDROID__)
692 return true;
693 #else
694 return cpuinfo_isa.mmx;
695 #endif
696 #else
697 return false;
698 #endif
699}
700
701static inline bool cpuinfo_has_x86_mmx_plus(void) {
702 #if CPUINFO_ARCH_X86_64
703 return true;
704 #elif CPUINFO_ARCH_X86
705 #if defined(__ANDROID__)
706 return true;
707 #else
708 return cpuinfo_isa.mmx_plus;
709 #endif
710 #else
711 return false;
712 #endif
713}
714
715static inline bool cpuinfo_has_x86_3dnow(void) {
716 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
717 return cpuinfo_isa.three_d_now;
718 #else
719 return false;
720 #endif
721}
722
723static inline bool cpuinfo_has_x86_3dnow_plus(void) {
724 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
725 return cpuinfo_isa.three_d_now_plus;
726 #else
727 return false;
728 #endif
729}
730
731static inline bool cpuinfo_has_x86_3dnow_geode(void) {
732 #if CPUINFO_ARCH_X86_64
733 return false;
734 #elif CPUINFO_ARCH_X86
735 #if defined(__ANDROID__)
736 return false;
737 #else
738 return cpuinfo_isa.three_d_now_geode;
739 #endif
740 #else
741 return false;
742 #endif
743}
744
745static inline bool cpuinfo_has_x86_prefetch(void) {
746 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
747 return cpuinfo_isa.prefetch;
748 #else
749 return false;
750 #endif
751}
752
753static inline bool cpuinfo_has_x86_prefetchw(void) {
754 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
755 return cpuinfo_isa.prefetchw;
756 #else
757 return false;
758 #endif
759}
760
761static inline bool cpuinfo_has_x86_prefetchwt1(void) {
762 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhan6022f802017-09-26 11:56:36 -0700763 return cpuinfo_isa.prefetchwt1;
Marat Dukhanf720d102017-09-26 10:33:47 -0700764 #else
765 return false;
766 #endif
767}
768
769static inline bool cpuinfo_has_x86_daz(void) {
770 #if CPUINFO_ARCH_X86_64
771 return true;
772 #elif CPUINFO_ARCH_X86
773 #if defined(__ANDROID__)
774 return true;
775 #else
776 return cpuinfo_isa.daz;
777 #endif
778 #else
779 return false;
780 #endif
781}
782
Marat Dukhan9da4c912017-09-26 10:53:28 -0700783static inline bool cpuinfo_has_x86_sse(void) {
784 #if CPUINFO_ARCH_X86_64
785 return true;
786 #elif CPUINFO_ARCH_X86
787 #if defined(__ANDROID__)
788 return true;
789 #else
790 return cpuinfo_isa.sse;
791 #endif
792 #else
793 return false;
794 #endif
795}
796
Marat Dukhanf720d102017-09-26 10:33:47 -0700797static inline bool cpuinfo_has_x86_sse2(void) {
798 #if CPUINFO_ARCH_X86_64
799 return true;
800 #elif CPUINFO_ARCH_X86
801 #if defined(__ANDROID__)
802 return true;
803 #else
804 return cpuinfo_isa.sse2;
805 #endif
806 #else
807 return false;
808 #endif
809}
810
811static inline bool cpuinfo_has_x86_sse3(void) {
812 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
813 #if defined(__ANDROID__)
814 return true;
815 #else
816 return cpuinfo_isa.sse3;
817 #endif
818 #else
819 return false;
820 #endif
821}
822
823static inline bool cpuinfo_has_x86_ssse3(void) {
824 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
825 #if defined(__ANDROID__)
826 return true;
827 #else
828 return cpuinfo_isa.ssse3;
829 #endif
830 #else
831 return false;
832 #endif
833}
834
835static inline bool cpuinfo_has_x86_sse4_1(void) {
836 #if CPUINFO_ARCH_X86_64
837 #if defined(__ANDROID__)
838 return true;
839 #else
840 return cpuinfo_isa.sse4_1;
841 #endif
842 #elif CPUINFO_ARCH_X86
843 return cpuinfo_isa.sse4_1;
844 #else
845 return false;
846 #endif
847}
848
849static inline bool cpuinfo_has_x86_sse4_2(void) {
850 #if CPUINFO_ARCH_X86_64
851 #if defined(__ANDROID__)
852 return true;
853 #else
854 return cpuinfo_isa.sse4_2;
855 #endif
856 #elif CPUINFO_ARCH_X86
857 return cpuinfo_isa.sse4_2;
858 #else
859 return false;
860 #endif
861}
862
863static inline bool cpuinfo_has_x86_sse4a(void) {
864 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
865 return cpuinfo_isa.sse4a;
866 #else
867 return false;
868 #endif
869}
870
871static inline bool cpuinfo_has_x86_misaligned_sse(void) {
872 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
873 return cpuinfo_isa.misaligned_sse;
874 #else
875 return false;
876 #endif
877}
878
879static inline bool cpuinfo_has_x86_avx(void) {
880 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
881 return cpuinfo_isa.avx;
882 #else
883 return false;
884 #endif
885}
886
887static inline bool cpuinfo_has_x86_fma3(void) {
888 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
889 return cpuinfo_isa.fma3;
890 #else
891 return false;
892 #endif
893}
894
895static inline bool cpuinfo_has_x86_fma4(void) {
896 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
897 return cpuinfo_isa.fma4;
898 #else
899 return false;
900 #endif
901}
902
903static inline bool cpuinfo_has_x86_xop(void) {
904 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
905 return cpuinfo_isa.xop;
906 #else
907 return false;
908 #endif
909}
910
911static inline bool cpuinfo_has_x86_f16c(void) {
912 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
913 return cpuinfo_isa.f16c;
914 #else
915 return false;
916 #endif
917}
918
919static inline bool cpuinfo_has_x86_avx2(void) {
920 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
921 return cpuinfo_isa.avx2;
922 #else
923 return false;
924 #endif
925}
926
927static inline bool cpuinfo_has_x86_avx512f(void) {
928 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
929 return cpuinfo_isa.avx512f;
930 #else
931 return false;
932 #endif
933}
934
935static inline bool cpuinfo_has_x86_avx512pf(void) {
936 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
937 return cpuinfo_isa.avx512pf;
938 #else
939 return false;
940 #endif
941}
942
943static inline bool cpuinfo_has_x86_avx512er(void) {
944 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
945 return cpuinfo_isa.avx512er;
946 #else
947 return false;
948 #endif
949}
950
951static inline bool cpuinfo_has_x86_avx512cd(void) {
952 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
953 return cpuinfo_isa.avx512cd;
954 #else
955 return false;
956 #endif
957}
958
959static inline bool cpuinfo_has_x86_avx512dq(void) {
960 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
961 return cpuinfo_isa.avx512dq;
962 #else
963 return false;
964 #endif
965}
966
967static inline bool cpuinfo_has_x86_avx512bw(void) {
968 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
969 return cpuinfo_isa.avx512bw;
970 #else
971 return false;
972 #endif
973}
974
975static inline bool cpuinfo_has_x86_avx512vl(void) {
976 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
977 return cpuinfo_isa.avx512vl;
978 #else
979 return false;
980 #endif
981}
982
983static inline bool cpuinfo_has_x86_avx512ifma(void) {
984 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
985 return cpuinfo_isa.avx512ifma;
986 #else
987 return false;
988 #endif
989}
990
991static inline bool cpuinfo_has_x86_avx512vbmi(void) {
992 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
993 return cpuinfo_isa.avx512vbmi;
994 #else
995 return false;
996 #endif
997}
998
Marat Dukhan861d21a2017-10-13 07:10:25 -0700999static inline bool cpuinfo_has_x86_avx512vbmi2(void) {
1000 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1001 return cpuinfo_isa.avx512vbmi2;
1002 #else
1003 return false;
1004 #endif
1005}
1006
1007static inline bool cpuinfo_has_x86_avx512bitalg(void) {
1008 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1009 return cpuinfo_isa.avx512bitalg;
1010 #else
1011 return false;
1012 #endif
1013}
1014
Marat Dukhanf720d102017-09-26 10:33:47 -07001015static inline bool cpuinfo_has_x86_avx512vpopcntdq(void) {
1016 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1017 return cpuinfo_isa.avx512vpopcntdq;
1018 #else
1019 return false;
1020 #endif
1021}
1022
Marat Dukhan861d21a2017-10-13 07:10:25 -07001023static inline bool cpuinfo_has_x86_avx512vnni(void) {
Marat Dukhan6b33b232017-10-13 09:36:52 -07001024 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhan861d21a2017-10-13 07:10:25 -07001025 return cpuinfo_isa.avx512vnni;
1026 #else
1027 return false;
1028 #endif
1029}
1030
Marat Dukhanf720d102017-09-26 10:33:47 -07001031static inline bool cpuinfo_has_x86_avx512_4vnniw(void) {
1032 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1033 return cpuinfo_isa.avx512_4vnniw;
1034 #else
1035 return false;
1036 #endif
1037}
1038
1039static inline bool cpuinfo_has_x86_avx512_4fmaps(void) {
1040 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1041 return cpuinfo_isa.avx512_4fmaps;
1042 #else
1043 return false;
1044 #endif
1045}
1046
Marat Dukhan9e32e8d2017-09-26 11:02:37 -07001047static inline bool cpuinfo_has_x86_hle(void) {
1048 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1049 return cpuinfo_isa.hle;
1050 #else
1051 return false;
1052 #endif
1053}
1054
1055static inline bool cpuinfo_has_x86_rtm(void) {
1056 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1057 return cpuinfo_isa.rtm;
1058 #else
1059 return false;
1060 #endif
1061}
1062
1063static inline bool cpuinfo_has_x86_xtest(void) {
1064 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1065 return cpuinfo_isa.xtest;
1066 #else
1067 return false;
1068 #endif
1069}
1070
1071static inline bool cpuinfo_has_x86_mpx(void) {
1072 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1073 return cpuinfo_isa.mpx;
1074 #else
1075 return false;
1076 #endif
1077}
1078
Marat Dukhanf720d102017-09-26 10:33:47 -07001079static inline bool cpuinfo_has_x86_cmov(void) {
1080 #if CPUINFO_ARCH_X86_64
1081 return true;
1082 #elif CPUINFO_ARCH_X86
1083 return cpuinfo_isa.cmov;
1084 #else
1085 return false;
1086 #endif
1087}
1088
1089static inline bool cpuinfo_has_x86_cmpxchg8b(void) {
1090 #if CPUINFO_ARCH_X86_64
1091 return true;
1092 #elif CPUINFO_ARCH_X86
1093 return cpuinfo_isa.cmpxchg8b;
1094 #else
1095 return false;
1096 #endif
1097}
1098
1099static inline bool cpuinfo_has_x86_cmpxchg16b(void) {
1100 #if CPUINFO_ARCH_X86_64
1101 return cpuinfo_isa.cmpxchg16b;
1102 #else
1103 return false;
1104 #endif
1105}
1106
1107static inline bool cpuinfo_has_x86_clwb(void) {
1108 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1109 return cpuinfo_isa.clwb;
1110 #else
1111 return false;
1112 #endif
1113}
1114
1115static inline bool cpuinfo_has_x86_movbe(void) {
Marat Dukhan6022f802017-09-26 11:56:36 -07001116 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
Marat Dukhanf720d102017-09-26 10:33:47 -07001117 return cpuinfo_isa.movbe;
1118 #else
1119 return false;
1120 #endif
1121}
1122
Marat Dukhan30401972017-09-26 18:35:52 -07001123static inline bool cpuinfo_has_x86_lahf_sahf(void) {
Marat Dukhanf720d102017-09-26 10:33:47 -07001124 #if CPUINFO_ARCH_X86
1125 return true;
1126 #elif CPUINFO_ARCH_X86_64
1127 return cpuinfo_isa.lahf_sahf;
1128 #else
1129 return false;
1130 #endif
1131}
1132
1133static inline bool cpuinfo_has_x86_lzcnt(void) {
1134 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1135 return cpuinfo_isa.lzcnt;
1136 #else
1137 return false;
1138 #endif
1139}
1140
1141static inline bool cpuinfo_has_x86_popcnt(void) {
1142 #if CPUINFO_ARCH_X86_64
1143 #if defined(__ANDROID__)
1144 return true;
1145 #else
1146 return cpuinfo_isa.popcnt;
1147 #endif
1148 #elif CPUINFO_ARCH_X86
1149 return cpuinfo_isa.popcnt;
1150 #else
1151 return false;
1152 #endif
1153}
1154
1155static inline bool cpuinfo_has_x86_tbm(void) {
1156 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1157 return cpuinfo_isa.tbm;
1158 #else
1159 return false;
1160 #endif
1161}
1162
1163static inline bool cpuinfo_has_x86_bmi(void) {
1164 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1165 return cpuinfo_isa.bmi;
1166 #else
1167 return false;
1168 #endif
1169}
1170
1171static inline bool cpuinfo_has_x86_bmi2(void) {
1172 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1173 return cpuinfo_isa.bmi2;
1174 #else
1175 return false;
1176 #endif
1177}
1178
1179static inline bool cpuinfo_has_x86_adx(void) {
1180 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1181 return cpuinfo_isa.adx;
1182 #else
1183 return false;
1184 #endif
1185}
1186
1187static inline bool cpuinfo_has_x86_aes(void) {
1188 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1189 return cpuinfo_isa.aes;
1190 #else
1191 return false;
1192 #endif
1193}
1194
Marat Dukhan861d21a2017-10-13 07:10:25 -07001195static inline bool cpuinfo_has_x86_vaes(void) {
1196 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1197 return cpuinfo_isa.vaes;
1198 #else
1199 return false;
1200 #endif
1201}
1202
Marat Dukhanf720d102017-09-26 10:33:47 -07001203static inline bool cpuinfo_has_x86_pclmulqdq(void) {
1204 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1205 return cpuinfo_isa.pclmulqdq;
1206 #else
1207 return false;
1208 #endif
1209}
1210
Marat Dukhan861d21a2017-10-13 07:10:25 -07001211static inline bool cpuinfo_has_x86_vpclmulqdq(void) {
1212 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1213 return cpuinfo_isa.vpclmulqdq;
1214 #else
1215 return false;
1216 #endif
1217}
1218
1219static inline bool cpuinfo_has_x86_gfni(void) {
1220 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1221 return cpuinfo_isa.gfni;
1222 #else
1223 return false;
1224 #endif
1225}
1226
Marat Dukhanf720d102017-09-26 10:33:47 -07001227static inline bool cpuinfo_has_x86_rdrand(void) {
1228 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1229 return cpuinfo_isa.rdrand;
1230 #else
1231 return false;
1232 #endif
1233}
1234
1235static inline bool cpuinfo_has_x86_rdseed(void) {
1236 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1237 return cpuinfo_isa.rdseed;
1238 #else
1239 return false;
1240 #endif
1241}
1242
1243static inline bool cpuinfo_has_x86_sha(void) {
1244 #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1245 return cpuinfo_isa.sha;
1246 #else
1247 return false;
1248 #endif
1249}
1250
Marat Dukhanab42e7e2017-05-09 13:19:39 +00001251#if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
Marat Dukhanf720d102017-09-26 10:33:47 -07001252 /* This structure is not a part of stable API. Use cpuinfo_has_arm_* functions instead. */
1253 struct cpuinfo_arm_isa {
1254 #if CPUINFO_ARCH_ARM
1255 bool thumb;
1256 bool thumb2;
1257 bool thumbee;
1258 bool jazelle;
1259 bool armv5e;
1260 bool armv6;
1261 bool armv6k;
1262 bool armv7;
1263 bool armv7mp;
1264 bool idiv;
1265
1266 bool vfpv2;
1267 bool vfpv3;
1268 bool d32;
1269 bool fp16;
1270 bool fma;
1271
1272 bool wmmx;
1273 bool wmmx2;
1274 bool neon;
1275 #endif
1276 #if CPUINFO_ARCH_ARM64
1277 bool atomics;
1278 bool rdm;
1279 bool fp16arith;
1280 bool jscvt;
1281 bool fcma;
1282 #endif
1283
1284 bool aes;
1285 bool sha1;
1286 bool sha2;
1287 bool pmull;
1288 bool crc32;
1289 };
1290
Marat Dukhan3c982762017-05-08 06:16:45 +00001291 extern struct cpuinfo_arm_isa cpuinfo_isa;
1292#endif
1293
Marat Dukhanf720d102017-09-26 10:33:47 -07001294static inline bool cpuinfo_has_arm_thumb(void) {
1295 #if CPUINFO_ARCH_ARM
1296 return cpuinfo_isa.thumb;
1297 #else
1298 return false;
1299 #endif
1300}
1301
1302static inline bool cpuinfo_has_arm_thumb2(void) {
1303 #if CPUINFO_ARCH_ARM
1304 return cpuinfo_isa.thumb2;
1305 #else
1306 return false;
1307 #endif
1308}
1309
1310static inline bool cpuinfo_has_arm_v5e(void) {
1311 #if CPUINFO_ARCH_ARM
1312 return cpuinfo_isa.armv5e;
1313 #else
1314 return false;
1315 #endif
1316}
1317
1318static inline bool cpuinfo_has_arm_v6(void) {
1319 #if CPUINFO_ARCH_ARM
1320 return cpuinfo_isa.armv6;
1321 #else
1322 return false;
1323 #endif
1324}
1325
1326static inline bool cpuinfo_has_arm_v6k(void) {
1327 #if CPUINFO_ARCH_ARM
1328 return cpuinfo_isa.armv6k;
1329 #else
1330 return false;
1331 #endif
1332}
1333
1334static inline bool cpuinfo_has_arm_v7(void) {
1335 #if CPUINFO_ARCH_ARM
1336 return cpuinfo_isa.armv7;
1337 #else
1338 return false;
1339 #endif
1340}
1341
1342static inline bool cpuinfo_has_arm_v7mp(void) {
1343 #if CPUINFO_ARCH_ARM
1344 return cpuinfo_isa.armv7mp;
1345 #else
1346 return false;
1347 #endif
1348}
1349
1350static inline bool cpuinfo_has_arm_idiv(void) {
1351 #if CPUINFO_ARCH_ARM64
1352 return true;
1353 #elif CPUINFO_ARCH_ARM
1354 return cpuinfo_isa.idiv;
1355 #else
1356 return false;
1357 #endif
1358}
1359
1360static inline bool cpuinfo_has_arm_vfpv2(void) {
1361 #if CPUINFO_ARCH_ARM
1362 return cpuinfo_isa.vfpv2;
1363 #else
1364 return false;
1365 #endif
1366}
1367
1368static inline bool cpuinfo_has_arm_vfpv3(void) {
1369 #if CPUINFO_ARCH_ARM64
1370 return true;
1371 #elif CPUINFO_ARCH_ARM
1372 return cpuinfo_isa.vfpv3;
1373 #else
1374 return false;
1375 #endif
1376}
1377
1378static inline bool cpuinfo_has_arm_vfpv3_d32(void) {
1379 #if CPUINFO_ARCH_ARM64
1380 return true;
1381 #elif CPUINFO_ARCH_ARM
1382 return cpuinfo_isa.vfpv3 && cpuinfo_isa.d32;
1383 #else
1384 return false;
1385 #endif
1386}
1387
1388static inline bool cpuinfo_has_arm_vfpv3_fp16(void) {
1389 #if CPUINFO_ARCH_ARM64
1390 return true;
1391 #elif CPUINFO_ARCH_ARM
1392 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16;
1393 #else
1394 return false;
1395 #endif
1396}
1397
1398static inline bool cpuinfo_has_arm_vfpv3_fp16_d32(void) {
1399 #if CPUINFO_ARCH_ARM64
1400 return true;
1401 #elif CPUINFO_ARCH_ARM
1402 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fp16 && cpuinfo_isa.d32;
1403 #else
1404 return false;
1405 #endif
1406}
1407
Marat Dukhan6022f802017-09-26 11:56:36 -07001408static inline bool cpuinfo_has_arm_vfpv4(void) {
Marat Dukhanf720d102017-09-26 10:33:47 -07001409 #if CPUINFO_ARCH_ARM64
1410 return true;
1411 #elif CPUINFO_ARCH_ARM
1412 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma;
1413 #else
1414 return false;
1415 #endif
1416}
1417
Marat Dukhan6022f802017-09-26 11:56:36 -07001418static inline bool cpuinfo_has_arm_vfpv4_d32(void) {
Marat Dukhanf720d102017-09-26 10:33:47 -07001419 #if CPUINFO_ARCH_ARM64
1420 return true;
1421 #elif CPUINFO_ARCH_ARM
1422 return cpuinfo_isa.vfpv3 && cpuinfo_isa.fma && cpuinfo_isa.d32;
1423 #else
1424 return false;
1425 #endif
1426}
1427
1428static inline bool cpuinfo_has_arm_wmmx(void) {
1429 #if CPUINFO_ARCH_ARM
1430 return cpuinfo_isa.wmmx;
1431 #else
1432 return false;
1433 #endif
1434}
1435
1436static inline bool cpuinfo_has_arm_wmmx2(void) {
1437 #if CPUINFO_ARCH_ARM
1438 return cpuinfo_isa.wmmx2;
1439 #else
1440 return false;
1441 #endif
1442}
1443
1444static inline bool cpuinfo_has_arm_neon(void) {
1445 #if CPUINFO_ARCH_ARM64
1446 return true;
1447 #elif CPUINFO_ARCH_ARM
1448 return cpuinfo_isa.neon;
1449 #else
1450 return false;
1451 #endif
1452}
1453
1454static inline bool cpuinfo_has_arm_neon_fp16(void) {
1455 #if CPUINFO_ARCH_ARM64
1456 return true;
1457 #elif CPUINFO_ARCH_ARM
1458 return cpuinfo_isa.neon && cpuinfo_isa.fp16;
1459 #else
1460 return false;
1461 #endif
1462}
1463
1464static inline bool cpuinfo_has_arm_neon_fma(void) {
1465 #if CPUINFO_ARCH_ARM64
1466 return true;
1467 #elif CPUINFO_ARCH_ARM
1468 return cpuinfo_isa.neon && cpuinfo_isa.fma;
1469 #else
1470 return false;
1471 #endif
1472}
1473
1474static inline bool cpuinfo_has_arm_atomics(void) {
1475 #if CPUINFO_ARCH_ARM64
1476 return cpuinfo_isa.atomics;
1477 #else
1478 return false;
1479 #endif
1480}
1481
1482static inline bool cpuinfo_has_arm_neon_rdm(void) {
1483 #if CPUINFO_ARCH_ARM64
1484 return cpuinfo_isa.rdm;
1485 #else
1486 return false;
1487 #endif
1488}
1489
1490static inline bool cpuinfo_has_arm_fp16_arith(void) {
1491 #if CPUINFO_ARCH_ARM64
1492 return cpuinfo_isa.fp16arith;
1493 #else
1494 return false;
1495 #endif
1496}
1497
1498static inline bool cpuinfo_has_arm_jscvt(void) {
1499 #if CPUINFO_ARCH_ARM64
1500 return cpuinfo_isa.jscvt;
1501 #else
1502 return false;
1503 #endif
1504}
1505
1506static inline bool cpuinfo_has_arm_fcma(void) {
1507 #if CPUINFO_ARCH_ARM64
1508 return cpuinfo_isa.fcma;
1509 #else
1510 return false;
1511 #endif
1512}
1513
1514static inline bool cpuinfo_has_arm_aes(void) {
1515 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1516 return cpuinfo_isa.aes;
1517 #else
1518 return false;
1519 #endif
1520}
1521
1522static inline bool cpuinfo_has_arm_sha1(void) {
1523 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1524 return cpuinfo_isa.sha1;
1525 #else
1526 return false;
1527 #endif
1528}
1529
1530static inline bool cpuinfo_has_arm_sha2(void) {
1531 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1532 return cpuinfo_isa.sha2;
1533 #else
1534 return false;
1535 #endif
1536}
1537
1538static inline bool cpuinfo_has_arm_pmull(void) {
1539 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1540 return cpuinfo_isa.pmull;
1541 #else
1542 return false;
1543 #endif
1544}
1545
1546static inline bool cpuinfo_has_arm_crc32(void) {
1547 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
1548 return cpuinfo_isa.crc32;
1549 #else
1550 return false;
1551 #endif
1552}
1553
Marat Dukhan30401972017-09-26 18:35:52 -07001554const struct cpuinfo_processor* cpuinfo_get_processors(void);
1555const struct cpuinfo_core* cpuinfo_get_cores(void);
1556const struct cpuinfo_package* cpuinfo_get_packages(void);
1557const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_caches(void);
1558const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_caches(void);
1559const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_caches(void);
1560const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_caches(void);
1561const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_caches(void);
Marat Dukhan3045d4f2017-03-04 01:51:42 -05001562
Marat Dukhan30401972017-09-26 18:35:52 -07001563const struct cpuinfo_processor* cpuinfo_get_processor(uint32_t index);
1564const struct cpuinfo_core* cpuinfo_get_core(uint32_t index);
1565const struct cpuinfo_package* cpuinfo_get_package(uint32_t index);
1566const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1i_cache(uint32_t index);
1567const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l1d_cache(uint32_t index);
1568const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l2_cache(uint32_t index);
1569const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l3_cache(uint32_t index);
1570const struct cpuinfo_cache* CPUINFO_ABI cpuinfo_get_l4_cache(uint32_t index);
Marat Dukhan3045d4f2017-03-04 01:51:42 -05001571
Marat Dukhan30401972017-09-26 18:35:52 -07001572uint32_t cpuinfo_get_processors_count(void);
1573uint32_t cpuinfo_get_cores_count(void);
1574uint32_t cpuinfo_get_packages_count(void);
1575uint32_t CPUINFO_ABI cpuinfo_get_l1i_caches_count(void);
1576uint32_t CPUINFO_ABI cpuinfo_get_l1d_caches_count(void);
1577uint32_t CPUINFO_ABI cpuinfo_get_l2_caches_count(void);
1578uint32_t CPUINFO_ABI cpuinfo_get_l3_caches_count(void);
1579uint32_t CPUINFO_ABI cpuinfo_get_l4_caches_count(void);
Marat Dukhan8ecad1a2017-05-08 07:21:57 +00001580
Marat Dukhan30401972017-09-26 18:35:52 -07001581const struct cpuinfo_processor* CPUINFO_ABI cpuinfo_get_current_processor(void);
1582const struct cpuinfo_core* CPUINFO_ABI cpuinfo_get_current_core(void);
Marat Dukhan547fa362017-03-03 02:47:26 -05001583
1584#ifdef __cplusplus
1585} /* extern "C" */
1586#endif
1587
1588#endif /* CPUINFO_H */