perf cpu_map: Add more helpers
[deliverable/linux.git] / tools / perf / util / cpumap.c
index 15f83acac1b85d777ca17c9588526fe31f86343a..2c0b52264a468103e9bbd32b8631d76fae585ff4 100644 (file)
@@ -588,15 +588,25 @@ int cpu__setup_cpunode_map(void)
 }
 
 bool cpu_map__has(struct cpu_map *cpus, int cpu)
+{
+       return cpu_map__idx(cpus, cpu) != -1;
+}
+
+int cpu_map__idx(struct cpu_map *cpus, int cpu)
 {
        int i;
 
        for (i = 0; i < cpus->nr; ++i) {
                if (cpus->map[i] == cpu)
-                       return true;
+                       return i;
        }
 
-       return false;
+       return -1;
+}
+
+int cpu_map__cpu(struct cpu_map *cpus, int idx)
+{
+       return cpus->map[idx];
 }
 
 size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
This page took 0.025375 seconds and 5 git commands to generate.