[PATCH 01/21] perf tools: Add perf_evsel__is_sample_bit function

From: Jiri Olsa
Date: Wed Jan 24 2018 - 06:51:58 EST


Adding perf_evsel__is_sample_bit function to check on the
evsel's sample_type bit. It will be used later in the patchset.

Link: http://lkml.kernel.org/n/tip-woz5sp8qxvnhz8h14ne0657g@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/evsel.c | 6 ++++++
tools/perf/util/evsel.h | 5 +++++
2 files changed, 11 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 66fa45198a11..0f62de48594e 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -183,6 +183,12 @@ void perf_evsel__calc_id_pos(struct perf_evsel *evsel)
evsel->is_pos = __perf_evsel__calc_is_pos(evsel->attr.sample_type);
}

+bool __perf_evsel__is_sample_bit(struct perf_evsel *evsel,
+ enum perf_event_sample_format bit)
+{
+ return evsel->attr.sample_type & bit;
+}
+
void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit)
{
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 846e41644525..e54ea37469b3 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -234,11 +234,16 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size);
int perf_evsel__alloc_id(struct perf_evsel *evsel, int ncpus, int nthreads);
void perf_evsel__close_fd(struct perf_evsel *evsel);

+bool __perf_evsel__is_sample_bit(struct perf_evsel *evsel,
+ enum perf_event_sample_format bit);
void __perf_evsel__set_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit);
void __perf_evsel__reset_sample_bit(struct perf_evsel *evsel,
enum perf_event_sample_format bit);

+#define perf_evsel__is_sample_bit(evsel, bit) \
+ __perf_evsel__is_sample_bit(evsel, PERF_SAMPLE_##bit)
+
#define perf_evsel__set_sample_bit(evsel, bit) \
__perf_evsel__set_sample_bit(evsel, PERF_SAMPLE_##bit)

--
2.13.6