Commit cc3365bb authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Geneviève Bastien <gbastien@versatic.net>
Cc: Ian Rogers <irogers@google.com>
Cc: Jeremie Galarneau <jgalar@efficios.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lore.kernel.org/lkml/20200805093444.314999-3-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 6953beb4
...@@ -106,3 +106,14 @@ int parse_clockid(const struct option *opt, const char *str, int unset) ...@@ -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); ui__warning("unknown clockid %s, check man page\n", ostr);
return -1; 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)";
}
...@@ -6,4 +6,6 @@ ...@@ -6,4 +6,6 @@
struct option; struct option;
int parse_clockid(const struct option *opt, const char *str, int unset); int parse_clockid(const struct option *opt, const char *str, int unset);
const char *clockid_name(clockid_t clk_id);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment