mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roman Kiryanov <rkir@google.com>
To: mst@redhat.com, linux-kernel@vger.kernel.org
Cc: jansene@google.com, mett@google.com, jpcottin@google.com,
	 Roman Kiryanov <rkir@google.com>
Subject: [PATCH] UAPI: Make virtio_ring.h C++ friendly
Date: Thu, 20 Jun 2024 10:52:14 -0700	[thread overview]
Message-ID: <20240620175214.515211-1-rkir@google.com> (raw)

virtio_ring.h is an UAPI files which could
be used by code outside of the linux kernel
which could be written in C++.

Google-Bug-Id: 331190993
Change-Id: Ib27c1e57c273ec5613b4e745a3ab4d53bdde5aac
Signed-off-by: Roman Kiryanov <rkir@google.com>
---
 include/uapi/linux/virtio_ring.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
index f8c20d3de8da..be88871d512b 100644
--- a/include/uapi/linux/virtio_ring.h
+++ b/include/uapi/linux/virtio_ring.h
@@ -199,11 +199,13 @@ struct vring {
 static inline void vring_init(struct vring *vr, unsigned int num, void *p,
 			      unsigned long align)
 {
+	struct vring_desc *desc = (struct vring_desc *)p;
+
 	vr->num = num;
-	vr->desc = p;
-	vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
-	vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
-		+ align-1) & ~(align - 1));
+	vr->desc = desc;
+	vr->avail = (struct vring_avail *)(desc + num);
+	vr->used = (struct vring_used *)(((uintptr_t)&vr->avail->ring[num]
+		+ sizeof(__virtio16) + align-1) & ~(align - 1));
 }
 
 static inline unsigned vring_size(unsigned int num, unsigned long align)
-- 
2.45.2.741.gdbec12cfda-goog


                 reply	other threads:[~2024-06-20 17:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240620175214.515211-1-rkir@google.com \
    --to=rkir@google.com \
    --cc=jansene@google.com \
    --cc=jpcottin@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mett@google.com \
    --cc=mst@redhat.com \
    /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

all inboxes | Powered by JetHome®