summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/cpumap.h
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-09-26 12:41:14 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-09-26 12:41:14 -0300
commita14bb7a6fd4a3d563ca971daf462ba4dc294a7a6 (patch)
tree5ad6003f5cf57019c55b44023e10401e2d01b78e /tools/perf/util/cpumap.h
parent0b80f8b32f31f80e001fb6355fd86769555c4a3c (diff)
downloadlinux-a14bb7a6fd4a3d563ca971daf462ba4dc294a7a6.tar.gz
linux-a14bb7a6fd4a3d563ca971daf462ba4dc294a7a6.tar.bz2
linux-a14bb7a6fd4a3d563ca971daf462ba4dc294a7a6.zip
perf tools: Allow handling a NULL cpu_map as meaning "all cpus"
Or one with cpu_map->map[0] == -1. Reducing the boilerplate in setting up an evlist by nor requiring a cpu_map to be created at all. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-rnaqn3dtnsfo1wlbbf3fhx00@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/cpumap.h')
-rw-r--r--tools/perf/util/cpumap.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h
index 17b5264f6436..2f68a3b8c285 100644
--- a/tools/perf/util/cpumap.h
+++ b/tools/perf/util/cpumap.h
@@ -2,6 +2,7 @@
#define __PERF_CPUMAP_H
#include <stdio.h>
+#include <stdbool.h>
struct cpu_map {
int nr;
@@ -14,4 +15,14 @@ void cpu_map__delete(struct cpu_map *map);
struct cpu_map *cpu_map__read(FILE *file);
size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
+static inline int cpu_map__nr(const struct cpu_map *map)
+{
+ return map ? map->nr : 1;
+}
+
+static inline bool cpu_map__all(const struct cpu_map *map)
+{
+ return map ? map->map[0] == -1 : true;
+}
+
#endif /* __PERF_CPUMAP_H */