lkml.org 
[lkml]   [2021]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] perf tools: Add weak variants for the deprecated libbpf functions
Date
Adding weak functions for deprecated libbpf functions, so that
we don't get build fail with libbpf version where they are
finally removed.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/bpf-event.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index ceb96360fd12..476427f3e804 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -22,6 +22,20 @@
#include "record.h"
#include "util/synthetic-events.h"

+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+int btf__get_from_id(__u32 id, struct btf **btf);
+struct bpf_program *bpf_program__next(struct bpf_program *prog,
+ const struct bpf_object *obj);
+struct bpf_map *bpf_map__next(const struct bpf_map *map, const struct bpf_object *obj);
+const void *btf__get_raw_data(const struct btf *btf, __u32 *size);
+#pragma GCC diagnostic pop
+
+int __weak btf__get_from_id(__u32 id __maybe_unused, struct btf **btf __maybe_unused)
+{
+ return -ENOTSUP;
+}
+
struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
{
struct btf *btf;
@@ -33,6 +47,13 @@ struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
return err ? ERR_PTR(err) : btf;
}

+struct bpf_program * __weak
+bpf_program__next(struct bpf_program *prog __maybe_unused,
+ const struct bpf_object *obj __maybe_unused)
+{
+ return NULL;
+}
+
struct bpf_program * __weak
bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
{
@@ -42,6 +63,12 @@ bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
#pragma GCC diagnostic pop
}

+struct bpf_map * __weak bpf_map__next(const struct bpf_map *map __maybe_unused,
+ const struct bpf_object *obj __maybe_unused)
+{
+ return NULL;
+}
+
struct bpf_map * __weak
bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev)
{
@@ -51,6 +78,12 @@ bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev)
#pragma GCC diagnostic pop
}

+const void * __weak btf__get_raw_data(const struct btf *btf __maybe_unused,
+ __u32 *size __maybe_unused)
+{
+ return NULL;
+}
+
const void * __weak
btf__raw_data(const struct btf *btf_ro, __u32 *size)
{
--
2.31.1
\
 
 \ /
  Last update: 2021-11-09 15:08    [W:0.388 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site