Skip to content

Commit

Permalink
Remove guard for object directory
Browse files Browse the repository at this point in the history
  • Loading branch information
hp77-creator committed Jun 22, 2024
1 parent 6f820c1 commit 75e7bef
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
3 changes: 0 additions & 3 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ message(DEBUG "Successfully added all dependencies and linked against them.")
set(BPFTIME_RUNTIME_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src)


if(UNIX AND NOT APPLE)
add_subdirectory(object)
endif()

add_subdirectory(agent)
add_subdirectory(syscall-server)
#
Expand Down
36 changes: 36 additions & 0 deletions runtime/include/bpftime_epoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
#define __NR_bpf 515 // This is a placeholder value. Linux assigns syscall numbers dynamically.
#endif

#if __GNUC__ >= 4
#define LIBBPF_API __attribute__((visibility("default")))
#else
#define LIBBPF_API
#endif

#ifndef __NR_perf_event_open
#define __NR_perf_event_open 516 // This is a placeholder value. Linux assigns syscall numbers dynamically.
#endif
Expand Down Expand Up @@ -770,6 +776,7 @@ struct perf_event_attr {

__u64 config3; /* extension of config2 */
};

namespace bpftime_epoll{
struct bpf_map_info {
__u32 type;
Expand Down Expand Up @@ -1241,6 +1248,35 @@ static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
// No-op stub
return 0;
}

// from libbpf/btf
void btf__free(struct btf *btf);
// from libbpf
void
bpf_object__close(struct bpf_object* object);

LIBBPF_API struct bpf_program *
bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prog);

#define bpf_object__for_each_program(pos, obj) \
for ((pos) = bpf_object__next_program((obj), NULL); \
(pos) != NULL; \
(pos) = bpf_object__next_program((obj), (pos)))

struct bpf_program;

LIBBPF_API const struct bpf_insn *bpf_program__insns(const struct bpf_program *prog);
LIBBPF_API size_t bpf_program__insn_cnt(const struct bpf_program *prog);
LIBBPF_API const char *bpf_program__name(const struct bpf_program *prog);
LIBBPF_API const char *bpf_program__section_name(const struct bpf_program *prog);
LIBBPF_API struct bpf_object *bpf_object__open(const char *path);

enum libbpf_print_level {
LIBBPF_WARN,
LIBBPF_INFO,
LIBBPF_DEBUG,
};

// https://github.com/torvalds/linux/blob/2ef5971ff345d3c000873725db555085e0131961/tools/lib/bpf/bpf.h#L503
inline int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len)
{
Expand Down
5 changes: 5 additions & 0 deletions runtime/object/bpf_object.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if __linux__
#include <linux/bpf.h>
#elif __APPLE__
#include "bpftime_epoll.h"
#endif
#include <string>
#include <list>
Expand All @@ -9,6 +11,9 @@
#include <spdlog/spdlog.h>
using namespace std;
using namespace bpftime;
#if __APPLE__
using namespace bpftime_epoll;
#endif

#ifdef USE_LIBBPF
extern "C" {
Expand Down

0 comments on commit 75e7bef

Please sign in to comment.