7 int cpumap
[MAX_NR_CPUS
];
9 static int default_cpu_map(void)
13 nr_cpus
= sysconf(_SC_NPROCESSORS_ONLN
);
14 assert(nr_cpus
<= MAX_NR_CPUS
);
15 assert((int)nr_cpus
>= 0);
17 for (i
= 0; i
< nr_cpus
; ++i
)
23 int read_cpu_map(void)
30 onlnf
= fopen("/sys/devices/system/cpu/online", "r");
32 return default_cpu_map();
37 n
= fscanf(onlnf
, "%u%c", &cpu
, &sep
);
41 assert(nr_cpus
+ cpu
- prev
- 1 < MAX_NR_CPUS
);
43 cpumap
[nr_cpus
++] = prev
;
45 assert (nr_cpus
< MAX_NR_CPUS
);
46 cpumap
[nr_cpus
++] = cpu
;
47 if (n
== 2 && sep
== '-')
51 if (n
== 1 || sep
== '\n')
58 return default_cpu_map();