Skip to content

Commit

Permalink
add #ifdef BPFTIME_ENABLE_IOURING_EXT
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Dec 1, 2023
1 parent 12bdb8d commit 3d2f120
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ build: ## build the package
cmake -Bbuild -DBPFTIME_ENABLE_UNIT_TESTING=1
cmake --build build --config Debug
cd tools/cli-rs && cargo build

build-iouring: ## build the package
cmake -Bbuild -DBPFTIME_ENABLE_UNIT_TESTING=0 -DBPFTIME_ENABLE_IOURING_EXT=1 -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build build --config Release
cd tools/cli-rs && cargo build

release-without-cli:
cmake -Bbuild -DBPFTIME_ENABLE_UNIT_TESTING=0 \
-DCMAKE_BUILD_TYPE:STRING=Release \
Expand Down
24 changes: 15 additions & 9 deletions runtime/extension/extension_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include <spdlog/spdlog.h>
#include <vector>

#ifdef BPFTIME_ENABLE_IOURING_EXT
#include "liburing.h"
#endif

using namespace std;

Expand All @@ -43,6 +45,10 @@ uint64_t bpftime_path_join(const char *filename1, const char *filename2,
}
#endif

namespace bpftime
{
#ifdef BPFTIME_ENABLE_IOURING_EXT

static int submit_io_uring_write(struct io_uring *ring, int fd, char *buf,
size_t size)
{
Expand Down Expand Up @@ -93,27 +99,24 @@ static int io_uring_wait_and_seen(struct io_uring *ring,
return 0;
}

namespace bpftime
{

static struct io_uring ring;

uint64_t io_uring_init_global(void)
{
return io_uring_init(&ring);
}

uint64_t io_uring_submit_write(int fd, char *buf, size_t size)
uint64_t bpftime_io_uring_submit_write(int fd, char *buf, size_t size)
{
return submit_io_uring_write(&ring, fd, buf, size);
}

uint64_t io_uring_submit_fsync(int fd)
uint64_t bpftime_io_uring_submit_fsync(int fd)
{
return submit_io_uring_fsync(&ring, fd);
}

uint64_t io_uring_wait_and_seen(void)
uint64_t bpftime_io_uring_wait_and_seen(void)
{
struct io_uring_cqe *cqe = nullptr;
return io_uring_wait_and_seen(&ring, cqe);
Expand All @@ -123,6 +126,7 @@ uint64_t bpftime_io_uring_submit(void)
{
return io_uring_submit(&ring);
}
#endif

extern const bpftime_helper_group extesion_group = { {
{ FFI_HELPER_ID_FIND_ID,
Expand Down Expand Up @@ -151,6 +155,7 @@ extern const bpftime_helper_group extesion_group = { {
.fn = (void *)bpftime_path_join,
} },
#endif
#ifdef BPFTIME_ENABLE_IOURING_EXT
{ EXTENDED_HELPER_IOURING_INIT,
bpftime_helper_info{
.index = EXTENDED_HELPER_IOURING_INIT,
Expand All @@ -161,26 +166,27 @@ extern const bpftime_helper_group extesion_group = { {
bpftime_helper_info{
.index = EXTENDED_HELPER_IOURING_SUBMIT_WRITE,
.name = "io_uring_submit_write",
.fn = (void *)io_uring_submit_write,
.fn = (void *)bpftime_io_uring_submit_write,
} },
{ EXTENDED_HELPER_IOURING_SUBMIT_FSYNC,
bpftime_helper_info{
.index = EXTENDED_HELPER_IOURING_SUBMIT_FSYNC,
.name = "io_uring_submit_fsync",
.fn = (void *)io_uring_submit_fsync,
.fn = (void *)bpftime_io_uring_submit_fsync,
} },
{ EXTENDED_HELPER_IOURING_WAIT_AND_SEEN,
bpftime_helper_info{
.index = EXTENDED_HELPER_IOURING_WAIT_AND_SEEN,
.name = "io_uring_wait_and_seen",
.fn = (void *)io_uring_wait_and_seen,
.fn = (void *)bpftime_io_uring_wait_and_seen,
} },
{ EXTENDED_HELPER_IOURING_SUBMIT,
bpftime_helper_info{
.index = EXTENDED_HELPER_IOURING_SUBMIT,
.name = "io_uring_submit",
.fn = (void *)bpftime_io_uring_submit,
} },
#endif
} };

} // namespace bpftime

0 comments on commit 3d2f120

Please sign in to comment.