diff options
author | Stanislav Fomichev <sdf@google.com> | 2018-11-21 12:29:44 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-11-21 17:15:41 -0500 |
commit | 8c4905b995c649ac71e21611abc2fcefc904b56a (patch) | |
tree | 8f81fc53ebbdf9a0c08cd0b6b9b16d5a19d33655 /tools/lib/bpf/libbpf.h | |
parent | 462c124c590fe633564192dbfa26e99af788a67c (diff) |
libbpf: make sure bpf headers are c++ include-able
Wrap headers in extern "C", to turn off C++ mangling.
This simplifies including libbpf in c++ and linking against it.
v2 changes:
* do the same for btf.h
v3 changes:
* test_libbpf.cpp to test for possible future c++ breakages
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/lib/bpf/libbpf.h')
-rw-r--r-- | tools/lib/bpf/libbpf.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index b1686a787102..74e57e041705 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h | |||
@@ -16,6 +16,10 @@ | |||
16 | #include <sys/types.h> // for size_t | 16 | #include <sys/types.h> // for size_t |
17 | #include <linux/bpf.h> | 17 | #include <linux/bpf.h> |
18 | 18 | ||
19 | #ifdef __cplusplus | ||
20 | extern "C" { | ||
21 | #endif | ||
22 | |||
19 | #ifndef LIBBPF_API | 23 | #ifndef LIBBPF_API |
20 | #define LIBBPF_API __attribute__((visibility("default"))) | 24 | #define LIBBPF_API __attribute__((visibility("default"))) |
21 | #endif | 25 | #endif |
@@ -335,4 +339,9 @@ int libbpf_nl_get_qdisc(int sock, unsigned int nl_pid, int ifindex, | |||
335 | libbpf_dump_nlmsg_t dump_qdisc_nlmsg, void *cookie); | 339 | libbpf_dump_nlmsg_t dump_qdisc_nlmsg, void *cookie); |
336 | int libbpf_nl_get_filter(int sock, unsigned int nl_pid, int ifindex, int handle, | 340 | int libbpf_nl_get_filter(int sock, unsigned int nl_pid, int ifindex, int handle, |
337 | libbpf_dump_nlmsg_t dump_filter_nlmsg, void *cookie); | 341 | libbpf_dump_nlmsg_t dump_filter_nlmsg, void *cookie); |
342 | |||
343 | #ifdef __cplusplus | ||
344 | } /* extern "C" */ | ||
345 | #endif | ||
346 | |||
338 | #endif /* __LIBBPF_LIBBPF_H */ | 347 | #endif /* __LIBBPF_LIBBPF_H */ |