diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-07-01 02:13:52 +0000 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-08-07 10:16:56 -0300 |
commit | b3f59d66e22b8be4ccae67c8eaffa2cbb9e54eb1 (patch) | |
tree | e8911569d454df3f1b70da83e1f491a6bc89cbfd /tools/lib/bpf/libbpf.h | |
parent | 1b76c13e4b36f978ea45af079f38ad423a229630 (diff) | |
download | linux-stable-b3f59d66e22b8be4ccae67c8eaffa2cbb9e54eb1.tar.gz linux-stable-b3f59d66e22b8be4ccae67c8eaffa2cbb9e54eb1.tar.bz2 linux-stable-b3f59d66e22b8be4ccae67c8eaffa2cbb9e54eb1.zip |
bpf tools: Allow caller to set printing function
By libbpf_set_print(), users of libbpf are allowed to register he/she
own debug, info and warning printing functions. Libbpf will use those
functions to print messages. If not provided, default info and warning
printing functions are fprintf(stderr, ...); default debug printing
is NULL.
This API is designed to be used by perf, enables it to register its own
logging functions to make all logs uniform, instead of separated
logging level control.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1435716878-189507-5-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
-rw-r--r-- | tools/lib/bpf/libbpf.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index a6f46d908097..8d1eebafa958 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -8,4 +8,16 @@ #ifndef __BPF_LIBBPF_H #define __BPF_LIBBPF_H +/* + * In include/linux/compiler-gcc.h, __printf is defined. However + * it should be better if libbpf.h doesn't depend on Linux header file. + * So instead of __printf, here we use gcc attribute directly. + */ +typedef int (*libbpf_print_fn_t)(const char *, ...) + __attribute__((format(printf, 1, 2))); + +void libbpf_set_print(libbpf_print_fn_t warn, + libbpf_print_fn_t info, + libbpf_print_fn_t debug); + #endif |