]> Pileus Git - ~andy/linux/commitdiff
perf tools: Move hex2u64 into util object
authorJiri Olsa <jolsa@redhat.com>
Sat, 27 Oct 2012 21:18:30 +0000 (23:18 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Oct 2012 13:36:02 +0000 (11:36 -0200)
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>
tools/perf/util/symbol.c
tools/perf/util/symbol.h
tools/perf/util/util.c
tools/perf/util/util.h

index e36e8c2755b66178fb7eb25b7dcd1cea7c2e1254..08b825799a9e4d71ac20a4c12678a377a9becfae 100644 (file)
@@ -2050,39 +2050,6 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid)
        return machine__create_kernel_maps(machine);
 }
 
-static int hex(char ch)
-{
-       if ((ch >= '0') && (ch <= '9'))
-               return ch - '0';
-       if ((ch >= 'a') && (ch <= 'f'))
-               return ch - 'a' + 10;
-       if ((ch >= 'A') && (ch <= 'F'))
-               return ch - 'A' + 10;
-       return -1;
-}
-
-/*
- * While we find nice hex chars, build a long_val.
- * Return number of chars processed.
- */
-int hex2u64(const char *ptr, u64 *long_val)
-{
-       const char *p = ptr;
-       *long_val = 0;
-
-       while (*p) {
-               const int hex_val = hex(*p);
-
-               if (hex_val < 0)
-                       break;
-
-               *long_val = (*long_val << 4) | hex_val;
-               p++;
-       }
-
-       return p - ptr;
-}
-
 char *strxfrchar(char *s, char from, char to)
 {
        char *p = s;
index 6eb7d3b9c88e73e87358ff0602db4c6c71d78b49..bc34dc1fb741f626b783cb86b60dd8ec264dae97 100644 (file)
@@ -40,7 +40,6 @@ static inline char *bfd_demangle(void __maybe_unused *v,
 #endif
 #endif
 
-int hex2u64(const char *ptr, u64 *val);
 char *strxfrchar(char *s, char from, char to);
 
 /*
index 637b5cc5436299d317c71d84af6b64e5e774f58e..5906e8426cc7698161ed09ac30e52291107d9b40 100644 (file)
@@ -166,6 +166,39 @@ size_t hex_width(u64 v)
        return n;
 }
 
+static int hex(char ch)
+{
+       if ((ch >= '0') && (ch <= '9'))
+               return ch - '0';
+       if ((ch >= 'a') && (ch <= 'f'))
+               return ch - 'a' + 10;
+       if ((ch >= 'A') && (ch <= 'F'))
+               return ch - 'A' + 10;
+       return -1;
+}
+
+/*
+ * While we find nice hex chars, build a long_val.
+ * Return number of chars processed.
+ */
+int hex2u64(const char *ptr, u64 *long_val)
+{
+       const char *p = ptr;
+       *long_val = 0;
+
+       while (*p) {
+               const int hex_val = hex(*p);
+
+               if (hex_val < 0)
+                       break;
+
+               *long_val = (*long_val << 4) | hex_val;
+               p++;
+       }
+
+       return p - ptr;
+}
+
 /* Obtain a backtrace and print it to stdout. */
 #ifdef BACKTRACE_SUPPORT
 void dump_stack(void)
index 0d85209db8f11424c26508b956fb13db8b968f6e..d6c22c51911b6a572c4e37dc66079609151d3406 100644 (file)
@@ -262,6 +262,7 @@ bool is_power_of_2(unsigned long n)
 }
 
 size_t hex_width(u64 v);
+int hex2u64(const char *ptr, u64 *val);
 
 char *rtrim(char *s);