public inbox for [email protected]
 help / color / mirror / Atom feed
From: Stefan Metzmacher <[email protected]>
To: [email protected], [email protected]
Cc: Stefan Metzmacher <[email protected]>
Subject: [RFC PATCH 6/8] io_uring: add BUILD_BUG_SQE_HDR_COMMON() macro
Date: Fri, 12 Aug 2022 10:34:30 +0200	[thread overview]
Message-ID: <3d34b306c65ccf095646ba01b08cdf473a54957b.1660291547.git.metze@samba.org> (raw)
In-Reply-To: <[email protected]>

This will be used in the next commits in order to
check common fields of opcode specific struct io_uring_sqe
union arms.

Signed-off-by: Stefan Metzmacher <[email protected]>
---
 io_uring/io_uring.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index f82173bde393..8e1a8800b252 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3916,6 +3916,20 @@ static int __init io_uring_init(void)
 #define BUILD_BUG_SQE_LEGACY_ALIAS(eoffset, etype, ename, lname) \
 	__BUILD_BUG_VERIFY_ALIAS(struct io_uring_sqe, eoffset, sizeof(etype), ename, legacy.lname)
 
+#define BUILD_BUG_SQE_HDR_COMMON(subtype, subname) do { \
+	BUILD_BUG_ON(sizeof(subtype) != 64); \
+	BUILD_BUG_SQE_ELEM(0,  subtype, subname); \
+	BUILD_BUG_SQE_ELEM(0,  struct io_uring_sqe_hdr, subname.hdr); \
+	BUILD_BUG_SQE_ALIAS(0,  __u8,   subname.hdr.opcode, hdr.opcode); \
+	BUILD_BUG_SQE_ALIAS(1,  __u8,   subname.hdr.flags, hdr.flags); \
+	BUILD_BUG_SQE_ALIAS(2,  __u16,  subname.hdr.ioprio, hdr.ioprio); \
+	BUILD_BUG_SQE_ALIAS(4,  __s32,  subname.hdr.fd, hdr.fd); \
+	BUILD_BUG_SQE_ELEM(32, struct io_uring_sqe_common, subname.common); \
+	BUILD_BUG_SQE_ALIAS(32, __u64,  subname.common.user_data, common.user_data); \
+	BUILD_BUG_SQE_ALIAS(40, __u16,  subname.common.buf_info, common.buf_info); \
+	BUILD_BUG_SQE_ALIAS(42, __u16,  subname.common.personality, common.personality); \
+} while (0)
+
 	BUILD_BUG_ON(sizeof(struct io_uring_sqe_hdr) != 8);
 	BUILD_BUG_SQE_HDR_ELEM(0,  __u8,   opcode);
 	BUILD_BUG_SQE_HDR_ELEM(1,  __u8,   flags);
-- 
2.34.1


  parent reply	other threads:[~2022-08-12  8:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12  8:34 [RFC PATCH 0/8] cleanup struct io_uring_sqe layout Stefan Metzmacher
2022-08-12  8:34 ` [RFC PATCH 1/8] io_uring: move the current struct io_uring_sqe members to legacy sub struct Stefan Metzmacher
2022-08-12  8:34 ` [RFC PATCH 2/8] io_uring: add a generic structure for struct io_uring_sqe Stefan Metzmacher
2022-08-12  8:34 ` [RFC PATCH 3/8] io_uring: check legacy layout of struct io_uring_sqe with BUILD_BUG_SQE_LEGACY* Stefan Metzmacher
2022-08-12  8:34 ` [RFC PATCH 4/8] io_uring: only make use generic struct io_uring_sqe elements for tracing Stefan Metzmacher
2022-08-12  8:34 ` [RFC PATCH 5/8] io_uring: only access generic struct io_uring_sqe elements in io_uring.c Stefan Metzmacher
2022-08-12  8:34 ` Stefan Metzmacher [this message]
2022-08-12  8:34 ` [RFC PATCH 7/8] io_uring: introduce struct io_uring_sqe_rw for all io_prep_rw() using opcodes Stefan Metzmacher
2022-08-12  8:34 ` [RFC PATCH 8/8] io_uring: introduce struct io_uring_sqe_{fsync,sfr,fallocate} Stefan Metzmacher

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=3d34b306c65ccf095646ba01b08cdf473a54957b.1660291547.git.metze@samba.org \
    [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