aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/test_libbpf.cpp
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@google.com>2018-11-21 09:29:44 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2018-11-21 23:15:41 +0100
commit8c4905b995c649ac71e21611abc2fcefc904b56a (patch)
tree8f81fc53ebbdf9a0c08cd0b6b9b16d5a19d33655 /tools/lib/bpf/test_libbpf.cpp
parentbpf: fix a libbpf loader issue (diff)
downloadlinux-dev-8c4905b995c649ac71e21611abc2fcefc904b56a.tar.xz
linux-dev-8c4905b995c649ac71e21611abc2fcefc904b56a.zip
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 '')
-rw-r--r--tools/lib/bpf/test_libbpf.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/lib/bpf/test_libbpf.cpp b/tools/lib/bpf/test_libbpf.cpp
new file mode 100644
index 000000000000..abf3fc25c9fa
--- /dev/null
+++ b/tools/lib/bpf/test_libbpf.cpp
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+#include "libbpf.h"
+#include "bpf.h"
+#include "btf.h"
+
+/* do nothing, just make sure we can link successfully */
+
+int main(int argc, char *argv[])
+{
+ /* libbpf.h */
+ libbpf_set_print(NULL, NULL, NULL);
+
+ /* bpf.h */
+ bpf_prog_get_fd_by_id(0);
+
+ /* btf.h */
+ btf__new(NULL, 0, NULL);
+}