Skip to content

Commit cc3365b

Browse files
olsajiriacmel
authored andcommitted
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 <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.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 6953beb commit cc3365b

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎tools/perf/util/clockid.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,14 @@ int parse_clockid(const struct option *opt, const char *str, int unset)
106106
ui__warning("unknown clockid %s, check man page\n", ostr);
107107
return -1;
108108
}
109+
110+
const char *clockid_name(clockid_t clk_id)
111+
{
112+
const struct clockid_map *cm;
113+
114+
for (cm = clockids; cm->name; cm++) {
115+
if (cm->clockid == clk_id)
116+
return cm->name;
117+
}
118+
return "(not found)";
119+
}

‎tools/perf/util/clockid.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
struct option;
77
int parse_clockid(const struct option *opt, const char *str, int unset);
88

9+
const char *clockid_name(clockid_t clk_id);
10+
911
#endif

0 commit comments

Comments
 (0)