From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 2/2] liburing.h: dedup poll mask conversion
Date: Wed, 25 Aug 2021 13:23:02 +0100 [thread overview]
Message-ID: <9035fff2bde1c54bcac87ca48dfcfc54e6a815ab.1629893954.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Poll mask LE/BE translation is ugly enough to want to hide it in a
helper and not hand code many times.
Signed-off-by: Pavel Begunkov <[email protected]>
---
src/include/liburing.h | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/include/liburing.h b/src/include/liburing.h
index d20dd25..0ec07ee 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -313,14 +313,19 @@ static inline void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd,
sqe->msg_flags = flags;
}
-static inline void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,
- unsigned poll_mask)
+static inline unsigned __io_uring_prep_poll_mask(unsigned poll_mask)
{
- io_uring_prep_rw(IORING_OP_POLL_ADD, sqe, fd, NULL, 0, 0);
#if __BYTE_ORDER == __BIG_ENDIAN
poll_mask = __swahw32(poll_mask);
#endif
- sqe->poll32_events = poll_mask;
+ return poll_mask;
+}
+
+static inline void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd,
+ unsigned poll_mask)
+{
+ io_uring_prep_rw(IORING_OP_POLL_ADD, sqe, fd, NULL, 0, 0);
+ sqe->poll32_events = __io_uring_prep_poll_mask(poll_mask);
}
static inline void io_uring_prep_poll_multishot(struct io_uring_sqe *sqe,
@@ -343,10 +348,7 @@ static inline void io_uring_prep_poll_update(struct io_uring_sqe *sqe,
{
io_uring_prep_rw(IORING_OP_POLL_REMOVE, sqe, -1, old_user_data, flags,
(__u64)(uintptr_t)new_user_data);
-#if __BYTE_ORDER == __BIG_ENDIAN
- poll_mask = __swahw32(poll_mask);
-#endif
- sqe->poll32_events = poll_mask;
+ sqe->poll32_events = __io_uring_prep_poll_mask(poll_mask);
}
static inline void io_uring_prep_fsync(struct io_uring_sqe *sqe, int fd,
--
2.32.0
next prev parent reply other threads:[~2021-08-25 12:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-25 12:23 [PATCH liburing 0/2] liburing.h helpers cleanup Pavel Begunkov
2021-08-25 12:23 ` [PATCH liburing 1/2] liburing.h: add a multipoll helper Pavel Begunkov
2021-08-25 12:23 ` Pavel Begunkov [this message]
2021-08-25 14:59 ` [PATCH liburing 0/2] liburing.h helpers cleanup Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9035fff2bde1c54bcac87ca48dfcfc54e6a815ab.1629893954.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox