]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
perf tools: Add clockid_name function
authorJiri Olsa <jolsa@kernel.org>
Wed, 5 Aug 2020 09:34:39 +0000 (11:34 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 6 Aug 2020 12:33:57 +0000 (09:33 -0300)
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>
tools/perf/util/clockid.c
tools/perf/util/clockid.h

index b7a08606dc3e8196f56ba4b62cb1dca162d18fbf..74365a5d99c1f17af2beba84eeaf4fe7181f7eb7 100644 (file)
@@ -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)";
+}
index 8e567b3ebbbd875d7e4ee52ddf44304aba1e7bdb..9b49b4711c76837a08a13d6379b49c117493d459 100644 (file)
@@ -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