Skip to content

Commit

Permalink
[fix] Fix compiling error on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
pajama-coder committed May 13, 2024
1 parent 2bef4bb commit 1ad1a33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/api/bpf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ void BPF::pin(const std::string &pathname, int fd) {
)) syscall_error("BPF_OBJ_PIN");
}

auto BPF::get_pinned(const std::string &pathname) -> int {
auto BPF::get(const std::string &pathname) -> int {
union bpf_attr attr;
int fd = syscall_bpf(
BPF_OBJ_GET, &attr, attr_size(file_flags),
Expand Down Expand Up @@ -1011,6 +1011,11 @@ void BPF::pin(const std::string &pathname, int fd) {
unsupported();
}

auto BPF::get(const std::string &pathname) -> int {
unsupported();
return 0;
}

void BPF::attach(int attach_type, int fd) {
unsupported();
}
Expand Down Expand Up @@ -1241,7 +1246,7 @@ template<> void ClassDef<BPF>::init() {
Str *pathname;
try {
if (!ctx.arguments(1, &pathname)) return;
ret.set(BPF::get_pinned(pathname->str()));
ret.set(BPF::get(pathname->str()));
} catch (std::runtime_error &err) {
ctx.error(err);
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/bpf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Map : public pjs::ObjectTemplate<Map> {
class BPF : public pjs::ObjectTemplate<BPF> {
public:
static void pin(const std::string &pathname, int fd);
static auto get_pinned(const std::string &pathname) -> int;
static auto get(const std::string &pathname) -> int;
static void attach(int attach_type, int fd);
static void detach(int attach_type, int fd);
static void attach(int attach_type, int fd, const std::string &cgroup);
Expand Down

0 comments on commit 1ad1a33

Please sign in to comment.