1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LIBPERF_CPUMAP_H
3 #define __LIBPERF_CPUMAP_H
6 #include <perf/cpumap.h>
10 /** A wrapper around a CPU to avoid confusion with the perf_cpu_map's map's indices. */
15 LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void);
16 LIBPERF_API struct perf_cpu_map *perf_cpu_map__default_new(void);
17 LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list);
18 LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file);
19 LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
20 LIBPERF_API struct perf_cpu_map *perf_cpu_map__merge(struct perf_cpu_map *orig,
21 struct perf_cpu_map *other);
22 LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map);
23 LIBPERF_API struct perf_cpu perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx);
24 LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
25 LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map);
26 LIBPERF_API struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *map);
27 LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, struct perf_cpu cpu);
29 #define perf_cpu_map__for_each_cpu(cpu, idx, cpus) \
30 for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx); \
31 (idx) < perf_cpu_map__nr(cpus); \
32 (idx)++, (cpu) = perf_cpu_map__cpu(cpus, idx))
34 #define perf_cpu_map__for_each_idx(idx, cpus) \
35 for ((idx) = 0; (idx) < perf_cpu_map__nr(cpus); (idx)++)
37 #endif /* __LIBPERF_CPUMAP_H */