summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/liburing.h2
-rw-r--r--src/liburing.map2
-rw-r--r--src/setup.c27
3 files changed, 21 insertions, 10 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 2fda45e..d4699eb 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -72,6 +72,8 @@ extern int io_uring_register(int fd, unsigned int opcode, const void *arg,
/*
* Library interface
*/
+extern int io_uring_queue_init_params(unsigned entries, struct io_uring *ring,
+ struct io_uring_params *p);
extern int io_uring_queue_init(unsigned entries, struct io_uring *ring,
unsigned flags);
extern int io_uring_queue_mmap(int fd, struct io_uring_params *p,
diff --git a/src/liburing.map b/src/liburing.map
index 6088904..b944209 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -30,4 +30,6 @@ LIBURING_0.2 {
io_uring_wait_cqes;
__io_uring_get_cqe;
+
+ io_uring_queue_init_params;
} LIBURING_0.1;
diff --git a/src/setup.c b/src/setup.c
index dda4d1c..a52071b 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -94,6 +94,22 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring
return ret;
}
+int io_uring_queue_init_params(unsigned entries, struct io_uring *ring,
+ struct io_uring_params *p)
+{
+ int fd, ret;
+
+ fd = io_uring_setup(entries, p);
+ if (fd < 0)
+ return -errno;
+
+ ret = io_uring_queue_mmap(fd, p, ring);
+ if (ret)
+ close(fd);
+
+ return ret;
+}
+
/*
* Returns -1 on error, or zero on success. On success, 'ring'
* contains the necessary information to read/write to the rings.
@@ -101,20 +117,11 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ring
int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags)
{
struct io_uring_params p;
- int fd, ret;
memset(&p, 0, sizeof(p));
p.flags = flags;
- fd = io_uring_setup(entries, &p);
- if (fd < 0)
- return -errno;
-
- ret = io_uring_queue_mmap(fd, &p, ring);
- if (ret)
- close(fd);
-
- return ret;
+ return io_uring_queue_init_params(entries, ring, &p);
}
void io_uring_queue_exit(struct io_uring *ring)