blob: 58f456140e982ebafd256fdbffb2f00fc1fb927f [file] [log] [blame]
Marat Dukhand9f76e02017-09-24 22:46:08 -07001#include <stdbool.h>
2#include <stdint.h>
3#include <stdlib.h>
4#include <string.h>
5#include <errno.h>
6
7#include <sched.h>
8
9#include <cpuinfo.h>
10#include <linux/api.h>
11
12
13const struct cpuinfo_processor** cpuinfo_linux_cpu_to_processor_map;
14const struct cpuinfo_core** cpuinfo_linux_cpu_to_core_map;
15
16
17const struct cpuinfo_processor* cpuinfo_current_processor(void) {
18 const int cpu = sched_getcpu();
19 if (cpu >= 0) {
20 return cpuinfo_linux_cpu_to_processor_map[cpu];
21 } else {
22 return &cpuinfo_processors[0];
23 }
24}
25
26const struct cpuinfo_core* cpuinfo_current_core(void) {
27 const int cpu = sched_getcpu();
28 if (cpu >= 0) {
29 return cpuinfo_linux_cpu_to_core_map[cpu];
30 } else {
31 return &cpuinfo_cores[0];
32 }
33}