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 <[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]>
1 parent 6953beb commit cc3365b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

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)