Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[muen/linux.git] / tools / perf / util / bpf-loader.c
index 6e68698aa0ad8edbc6388366533216227cf1f968..251d9ea6252f958debb85a3fed7f3e923989e034 100644 (file)
 #include "llvm-utils.h"
 #include "c++/clang-c.h"
 
-#define DEFINE_PRINT_FN(name, level) \
-static int libbpf_##name(const char *fmt, ...) \
-{                                              \
-       va_list args;                           \
-       int ret;                                \
-                                               \
-       va_start(args, fmt);                    \
-       ret = veprintf(level, verbose, pr_fmt(fmt), args);\
-       va_end(args);                           \
-       return ret;                             \
+static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)),
+                             const char *fmt, va_list args)
+{
+       return veprintf(1, verbose, pr_fmt(fmt), args);
 }
 
-DEFINE_PRINT_FN(warning, 1)
-DEFINE_PRINT_FN(info, 1)
-DEFINE_PRINT_FN(debug, 1)
-
 struct bpf_prog_priv {
        bool is_tp;
        char *sys_name;
@@ -60,9 +50,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
        struct bpf_object *obj;
 
        if (!libbpf_initialized) {
-               libbpf_set_print(libbpf_warning,
-                                libbpf_info,
-                                libbpf_debug);
+               libbpf_set_print(libbpf_perf_print);
                libbpf_initialized = true;
        }
 
@@ -80,9 +68,7 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
        struct bpf_object *obj;
 
        if (!libbpf_initialized) {
-               libbpf_set_print(libbpf_warning,
-                                libbpf_info,
-                                libbpf_debug);
+               libbpf_set_print(libbpf_perf_print);
                libbpf_initialized = true;
        }
 
@@ -1504,7 +1490,7 @@ apply_obj_config_object(struct bpf_object *obj)
        struct bpf_map *map;
        int err;
 
-       bpf_map__for_each(map, obj) {
+       bpf_object__for_each_map(map, obj) {
                err = apply_obj_config_map(map);
                if (err)
                        return err;
@@ -1528,7 +1514,7 @@ int bpf__apply_obj_config(void)
 
 #define bpf__for_each_map(pos, obj, objtmp)    \
        bpf_object__for_each_safe(obj, objtmp)  \
-               bpf_map__for_each(pos, obj)
+               bpf_object__for_each_map(pos, obj)
 
 #define bpf__for_each_map_named(pos, obj, objtmp, name)        \
        bpf__for_each_map(pos, obj, objtmp)             \