diff options
Diffstat (limited to 'tools/perf/util/string.c')
| -rw-r--r-- | tools/perf/util/string.c | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index a175949ed216..0409fc7c0058 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c | |||
| @@ -1,48 +1,5 @@ | |||
| 1 | #include "string.h" | ||
| 2 | #include "util.h" | 1 | #include "util.h" |
| 3 | 2 | #include "string.h" | |
| 4 | static int hex(char ch) | ||
| 5 | { | ||
| 6 | if ((ch >= '0') && (ch <= '9')) | ||
| 7 | return ch - '0'; | ||
| 8 | if ((ch >= 'a') && (ch <= 'f')) | ||
| 9 | return ch - 'a' + 10; | ||
| 10 | if ((ch >= 'A') && (ch <= 'F')) | ||
| 11 | return ch - 'A' + 10; | ||
| 12 | return -1; | ||
| 13 | } | ||
| 14 | |||
| 15 | /* | ||
| 16 | * While we find nice hex chars, build a long_val. | ||
| 17 | * Return number of chars processed. | ||
| 18 | */ | ||
| 19 | int hex2u64(const char *ptr, u64 *long_val) | ||
| 20 | { | ||
| 21 | const char *p = ptr; | ||
| 22 | *long_val = 0; | ||
| 23 | |||
| 24 | while (*p) { | ||
| 25 | const int hex_val = hex(*p); | ||
| 26 | |||
| 27 | if (hex_val < 0) | ||
| 28 | break; | ||
| 29 | |||
| 30 | *long_val = (*long_val << 4) | hex_val; | ||
| 31 | p++; | ||
| 32 | } | ||
| 33 | |||
| 34 | return p - ptr; | ||
| 35 | } | ||
| 36 | |||
| 37 | char *strxfrchar(char *s, char from, char to) | ||
| 38 | { | ||
| 39 | char *p = s; | ||
| 40 | |||
| 41 | while ((p = strchr(p, from)) != NULL) | ||
| 42 | *p++ = to; | ||
| 43 | |||
| 44 | return s; | ||
| 45 | } | ||
| 46 | 3 | ||
| 47 | #define K 1024LL | 4 | #define K 1024LL |
| 48 | /* | 5 | /* |
