Commit 74429964d8e29c0107fa6e9cdf35b8f33f57405d
1 parent
dd5f5fd108
Exists in
master
and in
20 other branches
perf tools: Move evlist sample helpers to evlist area
These APIs should belong to evlist.c as they may not be exclusively tied to the headers. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Stephane Eranian <eranian@google.com
Showing 4 changed files with 34 additions and 33 deletions Side-by-side Diff
tools/perf/util/evlist.c
... | ... | @@ -398,4 +398,35 @@ |
398 | 398 | |
399 | 399 | return 0; |
400 | 400 | } |
401 | + | |
402 | +u64 perf_evlist__sample_type(struct perf_evlist *evlist) | |
403 | +{ | |
404 | + struct perf_evsel *pos; | |
405 | + u64 type = 0; | |
406 | + | |
407 | + list_for_each_entry(pos, &evlist->entries, node) { | |
408 | + if (!type) | |
409 | + type = pos->attr.sample_type; | |
410 | + else if (type != pos->attr.sample_type) | |
411 | + die("non matching sample_type"); | |
412 | + } | |
413 | + | |
414 | + return type; | |
415 | +} | |
416 | + | |
417 | +bool perf_evlist__sample_id_all(const struct perf_evlist *evlist) | |
418 | +{ | |
419 | + bool value = false, first = true; | |
420 | + struct perf_evsel *pos; | |
421 | + | |
422 | + list_for_each_entry(pos, &evlist->entries, node) { | |
423 | + if (first) { | |
424 | + value = pos->attr.sample_id_all; | |
425 | + first = false; | |
426 | + } else if (value != pos->attr.sample_id_all) | |
427 | + die("non matching sample_id_all"); | |
428 | + } | |
429 | + | |
430 | + return value; | |
431 | +} |
tools/perf/util/evlist.h
... | ... | @@ -65,5 +65,8 @@ |
65 | 65 | void perf_evlist__delete_maps(struct perf_evlist *evlist); |
66 | 66 | int perf_evlist__set_filters(struct perf_evlist *evlist); |
67 | 67 | |
68 | +u64 perf_evlist__sample_type(struct perf_evlist *evlist); | |
69 | +bool perf_evlist__sample_id_all(const struct perf_evlist *evlist); | |
70 | + | |
68 | 71 | #endif /* __PERF_EVLIST_H */ |
tools/perf/util/header.c
... | ... | @@ -934,37 +934,6 @@ |
934 | 934 | return -ENOMEM; |
935 | 935 | } |
936 | 936 | |
937 | -u64 perf_evlist__sample_type(struct perf_evlist *evlist) | |
938 | -{ | |
939 | - struct perf_evsel *pos; | |
940 | - u64 type = 0; | |
941 | - | |
942 | - list_for_each_entry(pos, &evlist->entries, node) { | |
943 | - if (!type) | |
944 | - type = pos->attr.sample_type; | |
945 | - else if (type != pos->attr.sample_type) | |
946 | - die("non matching sample_type"); | |
947 | - } | |
948 | - | |
949 | - return type; | |
950 | -} | |
951 | - | |
952 | -bool perf_evlist__sample_id_all(const struct perf_evlist *evlist) | |
953 | -{ | |
954 | - bool value = false, first = true; | |
955 | - struct perf_evsel *pos; | |
956 | - | |
957 | - list_for_each_entry(pos, &evlist->entries, node) { | |
958 | - if (first) { | |
959 | - value = pos->attr.sample_id_all; | |
960 | - first = false; | |
961 | - } else if (value != pos->attr.sample_id_all) | |
962 | - die("non matching sample_id_all"); | |
963 | - } | |
964 | - | |
965 | - return value; | |
966 | -} | |
967 | - | |
968 | 937 | int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id, |
969 | 938 | perf_event__handler_t process, |
970 | 939 | struct perf_session *session) |
tools/perf/util/header.h
... | ... | @@ -64,8 +64,6 @@ |
64 | 64 | int perf_header__push_event(u64 id, const char *name); |
65 | 65 | char *perf_header__find_event(u64 id); |
66 | 66 | |
67 | -u64 perf_evlist__sample_type(struct perf_evlist *evlist); | |
68 | -bool perf_evlist__sample_id_all(const struct perf_evlist *evlist); | |
69 | 67 | void perf_header__set_feat(struct perf_header *header, int feat); |
70 | 68 | void perf_header__clear_feat(struct perf_header *header, int feat); |
71 | 69 | bool perf_header__has_feat(const struct perf_header *header, int feat); |