Skip to content

Commit

Permalink
Fix header issue and add guard properly
Browse files Browse the repository at this point in the history
  • Loading branch information
hp77-creator committed Aug 24, 2024
1 parent ed9212a commit 9baa34a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion runtime/src/bpf_map/userspace/prog_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#if __linux__
#if BPFTIME_BUILD_WITH_LIBBPF
#include "bpf/bpf.h"
#include "linux/bpf.h"
#include <bpf/libbpf.h>
#endif
#include "linux/bpf.h"
#include <gnu/lib-names.h>
#elif __APPLE__
#include "bpftime_epoll.h"
Expand Down
27 changes: 25 additions & 2 deletions runtime/syscall-server/syscall_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#include "syscall_context.hpp"
#include "handler/perf_event_handler.hpp"
#if __linux__
#include "linux/perf_event.h"
#if BPFTIME_BUILD_WITH_LIBBPF
#include <bpf/bpf.h>
#endif
#include <linux/bpf.h>
#include "linux/perf_event.h"
#include <sys/epoll.h>
#include <bpf/bpf.h>
#include <linux/perf_event.h>
#include <linux/filter.h>
#elif __APPLE__
Expand Down Expand Up @@ -46,6 +48,27 @@
.imm = IMM })
#endif

#if linux && !BPFTIME_BUILD_WITH_LIBBPF
inline int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len)
{
const size_t attr_sz = offsetofend(union bpf_attr, info);
union bpf_attr attr;
int err;

memset(&attr, 0, attr_sz);
attr.info.bpf_fd = bpf_fd;
attr.info.info_len = *info_len;
attr.info.info = ptr_to_u64(info);

err = sys_bpf(BPF_OBJ_GET_INFO_BY_FD, &attr, attr_sz);
if (!err)
*info_len = attr.info.info_len;
// no-op stub
// return libbpf_err_errno(err);
return 1;
}
#endif

using namespace bpftime;
#if __APPLE__
using namespace bpftime_epoll;
Expand Down

0 comments on commit 9baa34a

Please sign in to comment.