summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-26 00:41:24 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-26 00:41:24 -0600
commit6d3380256165537291377c3c0b75ed30711f22e1 (patch)
tree0cc663b812f8934d1b2019fd43f888275a8dfc39
parent1148b7e3f1afb004d3ccf8bbf77ca36960b4e6e2 (diff)
downloadliburing-6d3380256165537291377c3c0b75ed30711f22e1.tar.gz
liburing-6d3380256165537291377c3c0b75ed30711f22e1.tar.bz2
io_uring_peek_batch_cqe(): fixup style and add to exports
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/liburing.map1
-rw-r--r--src/queue.c16
2 files changed, 11 insertions, 6 deletions
diff --git a/src/liburing.map b/src/liburing.map
index 730d5eb..9a2e870 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -5,6 +5,7 @@ LIBURING_0.1 {
io_uring_queue_exit;
io_uring_peek_cqe;
io_uring_wait_cqe;
+ io_uring_peek_batch_cqe;
io_uring_wait_cqe_timeout;
io_uring_wait_cqes_timeout;
io_uring_submit;
diff --git a/src/queue.c b/src/queue.c
index 470c3a2..14ec1b7 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -56,18 +56,22 @@ int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
* Fill in an array of IO completions up to count, if any are available.
* Returns the amount of IO completions filled.
*/
-unsigned io_uring_peek_batch_cqe(struct io_uring *ring, struct io_uring_cqe **cqes, unsigned count)
+unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
+ struct io_uring_cqe **cqes, unsigned count)
{
- unsigned ready = io_uring_cq_ready(ring);
+ unsigned ready;
+
+ ready = io_uring_cq_ready(ring);
if (ready) {
- count = count > ready ? ready : count;
unsigned head = *ring->cq.khead;
- unsigned last = head + count;
unsigned mask = *ring->cq.kring_mask;
+ unsigned last;
int i = 0;
- for (;head!=last;head++,i++) {
+
+ count = count > ready ? ready : count;
+ last = head + count;
+ for (;head != last; head++, i++)
cqes[i] = &ring->cq.cqes[head & mask];
- }
return count;
}