Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323898
b: refs/heads/master
c: e6b6f67
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Sep 26, 2012
1 parent 44ff0ab commit 82ceb86
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 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: 0807d2d8a381f4fc600ad481c3e77e5cdb624eed
refs/heads/master: e6b6f6795265ec19ff35572f527bb74c07ff9399
38 changes: 34 additions & 4 deletions trunk/tools/perf/util/evsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,13 +1108,43 @@ u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
const char *name)
{
struct format_field *field = perf_evsel__field(evsel, name);
u64 val;
void *ptr;
u64 value;

if (!field)
return 0;

val = pevent_read_number(evsel->tp_format->pevent,
sample->raw_data + field->offset, field->size);
return val;
ptr = sample->raw_data + field->offset;

switch (field->size) {
case 1:
return *(u8 *)ptr;
case 2:
value = *(u16 *)ptr;
break;
case 4:
value = *(u32 *)ptr;
break;
case 8:
value = *(u64 *)ptr;
break;
default:
return 0;
}

if (!evsel->needs_swap)
return value;

switch (field->size) {
case 2:
return bswap_16(value);
case 4:
return bswap_32(value);
case 8:
return bswap_64(value);
default:
return 0;
}

return 0;
}

0 comments on commit 82ceb86

Please sign in to comment.