summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-06-17 11:32:37 -0600
committerJens Axboe <axboe@kernel.dk>2019-06-17 11:34:22 -0600
commita8d4237e364b2a9973dabff35a6c0133572a3357 (patch)
treeab96eef14c9e2faf3369ce37950439c986578b32
parent9d9e3b87214ab7e70e7174299890c30ea3b24e28 (diff)
downloadliburing-a8d4237e364b2a9973dabff35a6c0133572a3357.tar.gz
liburing-a8d4237e364b2a9973dabff35a6c0133572a3357.tar.bz2
Add support for eventfd registration
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/liburing.h2
-rw-r--r--src/liburing.map2
-rw-r--r--src/register.c24
3 files changed, 28 insertions, 0 deletions
diff --git a/src/liburing.h b/src/liburing.h
index ca854b6..d3fcd15 100644
--- a/src/liburing.h
+++ b/src/liburing.h
@@ -84,6 +84,8 @@ extern int io_uring_unregister_buffers(struct io_uring *ring);
extern int io_uring_register_files(struct io_uring *ring, const int *files,
unsigned nr_files);
extern int io_uring_unregister_files(struct io_uring *ring);
+extern int io_uring_register_eventfd(struct io_uring *ring, int fd);
+extern int io_uring_unregister_eventfd(struct io_uring *ring);
#define io_uring_for_each_cqe(ring, head, cqe) \
for (head = *(ring)->cq.khead; \
diff --git a/src/liburing.map b/src/liburing.map
index 302443c..b37a146 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -16,6 +16,8 @@ LIBURING_0.1 {
io_uring_unregister_buffers;
io_uring_register_files;
io_uring_unregister_files;
+ io_uring_register_eventfd;
+ io_uring_unregister_eventfd;
local:
*;
diff --git a/src/register.c b/src/register.c
index b993fa9..7561575 100644
--- a/src/register.c
+++ b/src/register.c
@@ -58,3 +58,27 @@ int io_uring_unregister_files(struct io_uring *ring)
return 0;
}
+
+int io_uring_register_eventfd(struct io_uring *ring, int event_fd)
+{
+ int ret;
+
+ ret = io_uring_register(ring->ring_fd, IORING_REGISTER_EVENTFD,
+ &event_fd, 1);
+ if (ret < 0)
+ return -errno;
+
+ return 0;
+}
+
+int io_uring_unregister_eventfd(struct io_uring *ring)
+{
+ int ret;
+
+ ret = io_uring_register(ring->ring_fd, IORING_UNREGISTER_EVENTFD, NULL,
+ 0);
+ if (ret < 0)
+ return -errno;
+
+ return 0;
+}