Skip to content

Commit

Permalink
Add check for BUILD_WITH_LIBBPF wherever bpf libraries are used
Browse files Browse the repository at this point in the history
  • Loading branch information
hp77-creator committed Aug 23, 2024
1 parent 3bfd290 commit ed9212a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions runtime/src/bpf_map/userspace/prog_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* All rights reserved.
*/

#if __linux__
#include <bpf/bpf.h>
#include <linux/bpf.h>
#if __linux__
#if BPFTIME_BUILD_WITH_LIBBPF
#include "bpf/bpf.h"
#include "linux/bpf.h"
#include <bpf/libbpf.h>
#endif
#include <gnu/lib-names.h>
#elif __APPLE__
#include "bpftime_epoll.h"
Expand All @@ -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
Expand Down Expand Up @@ -75,6 +78,7 @@ int my_bpf_prog_get_fd_by_id(__u32 id)
return fd;
}

#endif
#endif

namespace bpftime
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ed9212a

Please sign in to comment.