[v1,2/5] perf trace-event: Add libtraceevent version tools to header

Message ID 20221213232651.1269909-3-irogers@google.com
State New
Headers
Series build/libtraceevent resends |

Commit Message

Ian Rogers Dec. 13, 2022, 11:26 p.m. UTC
  Allow comparisons like:
\#if MAKE_LIBTRACEEVENT_VERSION(1, 3, 0) <= LIBTRACEEVENT_VERSION

Based on previously reverted:
https://lore.kernel.org/linux-perf-users/20210923001024.550263-4-irogers@google.com/

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/trace-event.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Patch

diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index add6c5d9531c..1fbf4c3f8809 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -6,6 +6,19 @@ 
 #include <stdio.h>
 #include <linux/types.h>
 
+#ifdef HAVE_LIBTRACEEVENT
+#include <traceevent/event-parse.h>
+#endif
+
+#define MAKE_LIBTRACEEVENT_VERSION(a, b, c) ((a)*255*255+(b)*255+(c))
+#ifndef LIBTRACEEVENT_VERSION
+/*
+ * If LIBTRACEEVENT_VERSION wasn't computed then set to version 1.1.0 that
+ * previously shipped with the Linux kernel tools.
+ */
+#define LIBTRACEEVENT_VERSION MAKE_LIBTRACEEVENT_VERSION(1, 1, 0)
+#endif
+
 struct evlist;
 struct machine;
 struct perf_sample;