Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: fix export bpf api for eunomia-bpf repo #19

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/bpf-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void bpf_buffer__free(struct bpf_buffer *);
void bpf_object__close(struct bpf_object *object);
int bpf_link__destroy(bpf_link *link);
}

/// @brief init libbpf callbacks
void init_libbpf(void);
struct wasm_bpf_program {
Expand Down Expand Up @@ -60,6 +61,6 @@ enum bpf_map_cmd {
int bpf_map_operate(int fd, int cmd, void *key, void *value, void *next_key,
uint64_t flags);
/// The main entry, argc and argv will be passed to the wasm module.
int wasm_main(std::vector<uint8_t> wasm_module, int argc, char *argv[]);
int wasm_main(unsigned char *buf, unsigned int size, int argc, char *argv[]);

#endif
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ int main(int argc, char *argv[]) {
std::ifstream file(argv[1]);
std::vector<uint8_t> wasm_module((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
return wasm_main(wasm_module, argc - 1, argv + 1);
return wasm_main(wasm_module.data(), wasm_module.size(), argc - 1, argv + 1);
}
4 changes: 2 additions & 2 deletions src/wasm-bpf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ int wasm_bpf_map_operate(wasm_exec_env_t exec_env, int fd, int cmd, void *key,
}
}

int wasm_main(std::vector<uint8_t> wasm_module, int argc, char *argv[]) {
int wasm_main(unsigned char *buf, unsigned int size, int argc, char *argv[]) {
char error_buf[128];
int exit_code = 0;
char *wasm_path = NULL;
Expand Down Expand Up @@ -301,7 +301,7 @@ int wasm_main(std::vector<uint8_t> wasm_module, int argc, char *argv[]) {
printf("Init runtime environment failed.\n");
return -1;
}
module = wasm_runtime_load(wasm_module.data(), (uint32_t)wasm_module.size(),
module = wasm_runtime_load(buf, size,
error_buf, sizeof(error_buf));
if (!module) {
printf("Load wasm module failed. error: %s\n", error_buf);
Expand Down