diff options
author | Jiri Olsa <[email protected]> | 2020-08-05 11:34:39 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2020-08-06 09:33:57 -0300 |
commit | cc3365bbd07c26aa2e4c7435068292e03116d4e7 (patch) | |
tree | 444e91ed91f01874292d20139ece3eb5940b63a6 | |
parent | 6953beb4ddab87ad00029d8a11c1f985df09981e (diff) |
perf tools: Add clockid_name function
Add the clockid_name() function to get the clock name based on its
clockid. It will be used in the following changes.
Signed-off-by: Jiri Olsa <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Geneviève Bastien <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jeremie Galarneau <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/clockid.c | 11 | ||||
-rw-r--r-- | tools/perf/util/clockid.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tools/perf/util/clockid.c b/tools/perf/util/clockid.c index b7a08606dc3e..74365a5d99c1 100644 --- a/tools/perf/util/clockid.c +++ b/tools/perf/util/clockid.c @@ -106,3 +106,14 @@ int parse_clockid(const struct option *opt, const char *str, int unset) ui__warning("unknown clockid %s, check man page\n", ostr); return -1; } + +const char *clockid_name(clockid_t clk_id) +{ + const struct clockid_map *cm; + + for (cm = clockids; cm->name; cm++) { + if (cm->clockid == clk_id) + return cm->name; + } + return "(not found)"; +} diff --git a/tools/perf/util/clockid.h b/tools/perf/util/clockid.h index 8e567b3ebbbd..9b49b4711c76 100644 --- a/tools/perf/util/clockid.h +++ b/tools/perf/util/clockid.h @@ -6,4 +6,6 @@ struct option; int parse_clockid(const struct option *opt, const char *str, int unset); +const char *clockid_name(clockid_t clk_id); + #endif |