summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-02-28 13:38:41 -0700
committerJens Axboe <axboe@kernel.dk>2019-02-28 13:38:41 -0700
commit432fa1d3d1818bbbcfac0710c28a17d62a31f719 (patch)
tree3acc65a470776034a5c25927a0f5939ed3ab1989 /src
parent5b5e6fe360affed9af8cd6c31cae26ff40a3c7f0 (diff)
Add read/write fixed prep support
Also unify the setup, all the read/write variants can use the same helper. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src')
-rw-r--r--src/liburing.h39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/liburing.h b/src/liburing.h
index 6b0ce71..1cea6a5 100644
--- a/src/liburing.h
+++ b/src/liburing.h
@@ -74,28 +74,43 @@ static inline void io_uring_sqe_set_data(struct io_uring_sqe *sqe, void *data)
sqe->user_data = (unsigned long) data;
}
-static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
- struct iovec *iovecs, unsigned nr_vecs,
- off_t offset)
+static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd,
+ void *addr, unsigned len, off_t offset)
{
memset(sqe, 0, sizeof(*sqe));
- sqe->opcode = IORING_OP_READV;
+ sqe->opcode = op;
sqe->fd = fd;
sqe->off = offset;
- sqe->addr = (unsigned long) iovecs;
- sqe->len = nr_vecs;
+ sqe->addr = (unsigned long) addr;
+ sqe->len = len;
+}
+
+static inline void io_uring_prep_readv(struct io_uring_sqe *sqe, int fd,
+ struct iovec *iovecs, unsigned nr_vecs,
+ off_t offset)
+{
+ io_uring_prep_rw(IORING_OP_READV, sqe, fd, iovecs, nr_vecs, offset);
+}
+
+static inline void io_uring_prep_read_fixed(struct io_uring_sqe *sqe, int fd,
+ void *buf, unsigned nbytes,
+ off_t offset)
+{
+ io_uring_prep_rw(IORING_OP_READ_FIXED, sqe, fd, buf, nbytes, offset);
}
static inline void io_uring_prep_writev(struct io_uring_sqe *sqe, int fd,
struct iovec *iovecs, unsigned nr_vecs,
off_t offset)
{
- memset(sqe, 0, sizeof(*sqe));
- sqe->opcode = IORING_OP_WRITEV;
- sqe->fd = fd;
- sqe->off = offset;
- sqe->addr = (unsigned long) iovecs;
- sqe->len = nr_vecs;
+ io_uring_prep_rw(IORING_OP_WRITEV, sqe, fd, iovecs, nr_vecs, offset);
+}
+
+static inline void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd,
+ void *buf, unsigned nbytes,
+ off_t offset)
+{
+ io_uring_prep_rw(IORING_OP_WRITE_FIXED, sqe, fd, buf, nbytes, offset);
}
static inline void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,