Skip to content

Commit ed9212a

Browse files
committed
Add check for BUILD_WITH_LIBBPF wherever bpf libraries are used
1 parent 3bfd290 commit ed9212a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

runtime/src/bpf_map/userspace/prog_array.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* All rights reserved.
55
*/
66

7-
#if __linux__
8-
#include <bpf/bpf.h>
9-
#include <linux/bpf.h>
7+
#if __linux__
8+
#if BPFTIME_BUILD_WITH_LIBBPF
9+
#include "bpf/bpf.h"
10+
#include "linux/bpf.h"
1011
#include <bpf/libbpf.h>
12+
#endif
1113
#include <gnu/lib-names.h>
1214
#elif __APPLE__
1315
#include "bpftime_epoll.h"
@@ -26,6 +28,7 @@
2628

2729

2830
#if __linux__
31+
#if BPFTIME_BUILD_WITH_LIBBPF
2932

3033
// syscall() function was hooked by syscall server, direct call to it will lead
3134
// 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)
7578
return fd;
7679
}
7780

81+
#endif
7882
#endif
7983

8084
namespace bpftime
@@ -94,6 +98,7 @@ prog_array_map_impl::prog_array_map_impl(
9498
}
9599

96100
#if __linux__
101+
#if BPFTIME_BUILD_WITH_LIBBPF
97102

98103
void *prog_array_map_impl::elem_lookup(const void *key)
99104
{
@@ -134,7 +139,7 @@ long prog_array_map_impl::elem_update(const void *key, const void *value,
134139
info.id);
135140
return 0;
136141
}
137-
142+
#endif
138143
#endif
139144

140145
long prog_array_map_impl::elem_delete(const void *key)

0 commit comments

Comments
 (0)