• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <stdint.h>
4 #include <stdbool.h>
5 
6 #if defined(_WIN32) || defined(__CYGWIN__)
7 	#include <windows.h>
8 #endif
9 
10 #include <cpuinfo.h>
11 #include <cpuinfo/common.h>
12 
13 
14 enum cpuinfo_cache_level {
15 	cpuinfo_cache_level_1i  = 0,
16 	cpuinfo_cache_level_1d  = 1,
17 	cpuinfo_cache_level_2   = 2,
18 	cpuinfo_cache_level_3   = 3,
19 	cpuinfo_cache_level_4   = 4,
20 	cpuinfo_cache_level_max = 5,
21 };
22 
23 extern CPUINFO_INTERNAL bool cpuinfo_is_initialized;
24 
25 extern CPUINFO_INTERNAL struct cpuinfo_processor* cpuinfo_processors;
26 extern CPUINFO_INTERNAL struct cpuinfo_core* cpuinfo_cores;
27 extern CPUINFO_INTERNAL struct cpuinfo_cluster* cpuinfo_clusters;
28 extern CPUINFO_INTERNAL struct cpuinfo_package* cpuinfo_packages;
29 extern CPUINFO_INTERNAL struct cpuinfo_cache* cpuinfo_cache[cpuinfo_cache_level_max];
30 
31 extern CPUINFO_INTERNAL uint32_t cpuinfo_processors_count;
32 extern CPUINFO_INTERNAL uint32_t cpuinfo_cores_count;
33 extern CPUINFO_INTERNAL uint32_t cpuinfo_clusters_count;
34 extern CPUINFO_INTERNAL uint32_t cpuinfo_packages_count;
35 extern CPUINFO_INTERNAL uint32_t cpuinfo_cache_count[cpuinfo_cache_level_max];
36 extern CPUINFO_INTERNAL uint32_t cpuinfo_max_cache_size;
37 
38 #if CPUINFO_ARCH_ARM || CPUINFO_ARCH_ARM64
39 	extern CPUINFO_INTERNAL struct cpuinfo_uarch_info* cpuinfo_uarchs;
40 	extern CPUINFO_INTERNAL uint32_t cpuinfo_uarchs_count;
41 #else
42 	extern CPUINFO_INTERNAL struct cpuinfo_uarch_info cpuinfo_global_uarch;
43 #endif
44 
45 #ifdef __linux__
46 	extern CPUINFO_INTERNAL uint32_t cpuinfo_linux_cpu_max;
47 	extern CPUINFO_INTERNAL const struct cpuinfo_processor** cpuinfo_linux_cpu_to_processor_map;
48 	extern CPUINFO_INTERNAL const struct cpuinfo_core** cpuinfo_linux_cpu_to_core_map;
49 #endif
50 
51 CPUINFO_PRIVATE void cpuinfo_x86_mach_init(void);
52 CPUINFO_PRIVATE void cpuinfo_x86_linux_init(void);
53 #if defined(_WIN32) || defined(__CYGWIN__)
54 	#if CPUINFO_ARCH_ARM64
55 		CPUINFO_PRIVATE BOOL CALLBACK cpuinfo_arm_windows_init(PINIT_ONCE init_once, PVOID parameter, PVOID* context);
56 	#else
57 		CPUINFO_PRIVATE BOOL CALLBACK cpuinfo_x86_windows_init(PINIT_ONCE init_once, PVOID parameter, PVOID* context);
58 	#endif
59 #endif
60 CPUINFO_PRIVATE void cpuinfo_arm_mach_init(void);
61 CPUINFO_PRIVATE void cpuinfo_arm_linux_init(void);
62 CPUINFO_PRIVATE void cpuinfo_emscripten_init(void);
63 
64 CPUINFO_PRIVATE uint32_t cpuinfo_compute_max_cache_size(const struct cpuinfo_processor* processor);
65 
66 typedef void (*cpuinfo_processor_callback)(uint32_t);
67