Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338916
b: refs/heads/master
c: b2aff5f
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Oct 29, 2012
1 parent eac2053 commit 7fcdd65
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4383db88a7afb2664941ef1e82d41f5aad8be2ec
refs/heads/master: b2aff5f615793fa4c1313d82635b83cd7de8d9fd
33 changes: 0 additions & 33 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down
33 changes: 33 additions & 0 deletions trunk/tools/perf/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7fcdd65

Please sign in to comment.