lkml.org 
[lkml]   [2020]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/6] perf tools: Add clockid_name function
Date
Adding clockid_name function to get the clock name based
on its clockid. It will be used in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-record.c | 11 +++++++++++
tools/perf/util/util.h | 2 ++
2 files changed, 13 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b6bdccd875bc..468c669519a6 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -2121,6 +2121,17 @@ static const struct clockid_map clockids[] = {
CLOCKID_END,
};

+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)";
+}
+
static int get_clockid_res(clockid_t clk_id, u64 *res_ns)
{
struct timespec res;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index f486fdd3a538..126dad238ee3 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -62,4 +62,6 @@ char *perf_exe(char *buf, int len);
#endif
#endif

+const char *clockid_name(clockid_t clk_id);
+
#endif /* GIT_COMPAT_UTIL_H */
--
2.25.4
\
 
 \ /
  Last update: 2020-07-30 23:41    [W:0.177 / U:1.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site