From ed9212a79a31034d06fe1eee3307776b19490f03 Mon Sep 17 00:00:00 2001 From: Himanshu Pandey <24816726+hp77-creator@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:00:37 +0530 Subject: [PATCH] Add check for BUILD_WITH_LIBBPF wherever bpf libraries are used --- runtime/src/bpf_map/userspace/prog_array.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/runtime/src/bpf_map/userspace/prog_array.cpp b/runtime/src/bpf_map/userspace/prog_array.cpp index 4bd4fa35..f770666a 100644 --- a/runtime/src/bpf_map/userspace/prog_array.cpp +++ b/runtime/src/bpf_map/userspace/prog_array.cpp @@ -4,10 +4,12 @@ * All rights reserved. */ -#if __linux__ -#include -#include +#if __linux__ +#if BPFTIME_BUILD_WITH_LIBBPF +#include "bpf/bpf.h" +#include "linux/bpf.h" #include +#endif #include #elif __APPLE__ #include "bpftime_epoll.h" @@ -26,6 +28,7 @@ #if __linux__ +#if BPFTIME_BUILD_WITH_LIBBPF // syscall() function was hooked by syscall server, direct call to it will lead // to a result provided by bpftime. So if we want to get things from kernel, we @@ -75,6 +78,7 @@ int my_bpf_prog_get_fd_by_id(__u32 id) return fd; } +#endif #endif namespace bpftime @@ -94,6 +98,7 @@ prog_array_map_impl::prog_array_map_impl( } #if __linux__ +#if BPFTIME_BUILD_WITH_LIBBPF void *prog_array_map_impl::elem_lookup(const void *key) { @@ -134,7 +139,7 @@ long prog_array_map_impl::elem_update(const void *key, const void *value, info.id); return 0; } - +#endif #endif long prog_array_map_impl::elem_delete(const void *key)