aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-10-27 17:18:30 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-29 09:36:02 -0400
commitb2aff5f615793fa4c1313d82635b83cd7de8d9fd (patch)
tree6110632337165978884cefb68710aebe3c72f152 /tools/perf
parent4383db88a7afb2664941ef1e82d41f5aad8be2ec (diff)
perf tools: Move hex2u64 into util object
Moving hex2u64 function into util object. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Namhyung Kim <namhyung@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1351372712-21104-4-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/symbol.c33
-rw-r--r--tools/perf/util/symbol.h1
-rw-r--r--tools/perf/util/util.c33
-rw-r--r--tools/perf/util/util.h1
4 files changed, 34 insertions, 34 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e36e8c2755b6..08b825799a9e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -2050,39 +2050,6 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid)
2050 return machine__create_kernel_maps(machine); 2050 return machine__create_kernel_maps(machine);
2051} 2051}
2052 2052
2053static int hex(char ch)
2054{
2055 if ((ch >= '0') && (ch <= '9'))
2056 return ch - '0';
2057 if ((ch >= 'a') && (ch <= 'f'))
2058 return ch - 'a' + 10;
2059 if ((ch >= 'A') && (ch <= 'F'))
2060 return ch - 'A' + 10;
2061 return -1;
2062}
2063
2064/*
2065 * While we find nice hex chars, build a long_val.
2066 * Return number of chars processed.
2067 */
2068int hex2u64(const char *ptr, u64 *long_val)
2069{
2070 const char *p = ptr;
2071 *long_val = 0;
2072
2073 while (*p) {
2074 const int hex_val = hex(*p);
2075
2076 if (hex_val < 0)
2077 break;
2078
2079 *long_val = (*long_val << 4) | hex_val;
2080 p++;
2081 }
2082
2083 return p - ptr;
2084}
2085
2086char *strxfrchar(char *s, char from, char to) 2053char *strxfrchar(char *s, char from, char to)
2087{ 2054{
2088 char *p = s; 2055 char *p = s;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 6eb7d3b9c88e..bc34dc1fb741 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -40,7 +40,6 @@ static inline char *bfd_demangle(void __maybe_unused *v,
40#endif 40#endif
41#endif 41#endif
42 42
43int hex2u64(const char *ptr, u64 *val);
44char *strxfrchar(char *s, char from, char to); 43char *strxfrchar(char *s, char from, char to);
45 44
46/* 45/*
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 637b5cc54362..5906e8426cc7 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -166,6 +166,39 @@ size_t hex_width(u64 v)
166 return n; 166 return n;
167} 167}
168 168
169static int hex(char ch)
170{
171 if ((ch >= '0') && (ch <= '9'))
172 return ch - '0';
173 if ((ch >= 'a') && (ch <= 'f'))
174 return ch - 'a' + 10;
175 if ((ch >= 'A') && (ch <= 'F'))
176 return ch - 'A' + 10;
177 return -1;
178}
179
180/*
181 * While we find nice hex chars, build a long_val.
182 * Return number of chars processed.
183 */
184int hex2u64(const char *ptr, u64 *long_val)
185{
186 const char *p = ptr;
187 *long_val = 0;
188
189 while (*p) {
190 const int hex_val = hex(*p);
191
192 if (hex_val < 0)
193 break;
194
195 *long_val = (*long_val << 4) | hex_val;
196 p++;
197 }
198
199 return p - ptr;
200}
201
169/* Obtain a backtrace and print it to stdout. */ 202/* Obtain a backtrace and print it to stdout. */
170#ifdef BACKTRACE_SUPPORT 203#ifdef BACKTRACE_SUPPORT
171void dump_stack(void) 204void dump_stack(void)
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0d85209db8f1..d6c22c51911b 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -262,6 +262,7 @@ bool is_power_of_2(unsigned long n)
262} 262}
263 263
264size_t hex_width(u64 v); 264size_t hex_width(u64 v);
265int hex2u64(const char *ptr, u64 *val);
265 266
266char *rtrim(char *s); 267char *rtrim(char *s);
267 268