Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
cc3365bb 6953beb4

+13
+11
tools/perf/util/clockid.c
··· 106 106 ui__warning("unknown clockid %s, check man page\n", ostr); 107 107 return -1; 108 108 } 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 + }
+2
tools/perf/util/clockid.h
··· 6 6 struct option; 7 7 int parse_clockid(const struct option *opt, const char *str, int unset); 8 8 9 + const char *clockid_name(clockid_t clk_id); 10 + 9 11 #endif