2009-06-02 05:31:03 +04:00
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
perf_counter tools: Define and use our own u64, s64 etc. definitions
On 64-bit powerpc, __u64 is defined to be unsigned long rather than
unsigned long long. This causes compiler warnings every time we
print a __u64 value with %Lx.
Rather than changing __u64, we define our own u64 to be unsigned long
long on all architectures, and similarly s64 as signed long long.
For consistency we also define u32, s32, u16, s16, u8 and s8. These
definitions are put in a new header, types.h, because these definitions
are needed in util/string.h and util/symbol.h.
The main change here is the mechanical change of __[us]{64,32,16,8}
to remove the "__". The other changes are:
* Create types.h
* Include types.h in perf.h, util/string.h and util/symbol.h
* Add types.h to the LIB_H definition in Makefile
* Added (u64) casts in process_overflow_event() and print_sym_table()
to kill two remaining warnings.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: benh@kernel.crashing.org
LKML-Reference: <19003.33494.495844.956580@cargo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-06-19 16:21:42 +04:00
|
|
|
int hex2u64(const char *ptr, u64 *long_val)
|
2009-06-02 05:31:03 +04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|