mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] UAPI: Make virtio_ring.h C++ friendly
@ 2024-06-20 17:52 Roman Kiryanov
  0 siblings, 0 replies; only message in thread
From: Roman Kiryanov @ 2024-06-20 17:52 UTC (permalink / raw)
  To: mst, linux-kernel; +Cc: jansene, mett, jpcottin, Roman Kiryanov

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-06-20 17:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-20 17:52 [PATCH] UAPI: Make virtio_ring.h C++ friendly Roman Kiryanov

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®