blob: dc966dd9fd75f7c9deac218f82eedab01121c790 [file] [log] [blame]
Wang Nan1b76c132015-07-01 02:13:51 +00001/*
2 * Common eBPF ELF object loading operations.
3 *
4 * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org>
5 * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com>
6 * Copyright (C) 2015 Huawei Inc.
7 */
8#ifndef __BPF_LIBBPF_H
9#define __BPF_LIBBPF_H
10
Wang Nan1a5e3fb2015-07-01 02:13:53 +000011#include <stdio.h>
12
Wang Nanb3f59d62015-07-01 02:13:52 +000013/*
14 * In include/linux/compiler-gcc.h, __printf is defined. However
15 * it should be better if libbpf.h doesn't depend on Linux header file.
16 * So instead of __printf, here we use gcc attribute directly.
17 */
18typedef int (*libbpf_print_fn_t)(const char *, ...)
19 __attribute__((format(printf, 1, 2)));
20
21void libbpf_set_print(libbpf_print_fn_t warn,
22 libbpf_print_fn_t info,
23 libbpf_print_fn_t debug);
24
Wang Nan1a5e3fb2015-07-01 02:13:53 +000025/* Hide internal to user */
26struct bpf_object;
27
28struct bpf_object *bpf_object__open(const char *path);
Wang Nan6c956392015-07-01 02:13:54 +000029struct bpf_object *bpf_object__open_buffer(void *obj_buf,
30 size_t obj_buf_sz);
Wang Nan1a5e3fb2015-07-01 02:13:53 +000031void bpf_object__close(struct bpf_object *object);
32
Wang Nan1b76c132015-07-01 02:13:51 +000033#endif