xen/public: add new macro to ring.h
PATCH v2 1/1 xen/public: add new macro to ring.h
For the initialization of a ring page by the frontend two macros are available in ring.h: SHARED_RING_INIT() and FRONT_RING_INIT().
All known users use always both of them in direct sequence.
Add another macro XEN_FRONT_RING_INIT() combining the two macros.
---
V2:
- modify comment (Jan Beulich)
- drop underscores from macro parameters (Jan Beulich)
--- xen/include/public/io/ring.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
xen/include/public/io/ring.h +7 -3
@@ -95,9 +95,8 @@ typedef unsigned int RING_IDX;* of the shared memory area (PAGE_SIZE, for instance). To initialise * the front half: * -* mytag_front_ring_t front_ring; -* SHARED_RING_INIT((mytag_sring_t *)shared_page); -* FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); +* mytag_front_ring_t ring; +* XEN_FRONT_RING_INIT(&ring, (mytag_sring_t *)shared_page, PAGE_SIZE); * * Initializing the back follows similarly (note that only the front * initializes the shared ring):
@@ -184,6 +183,11 @@ typedef struct __name##_back_ring __name##_back_ring_t#define FRONT_RING_INIT (_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __size) +#define XEN_FRONT_RING_INIT (r, s, size) do { \ + SHARED_RING_INIT(s); \ + FRONT_RING_INIT(r, s, size); \ +} while (0) +#define BACK_RING_ATTACH (_r, _s, _i, __size) do { \ (_r)->rsp_prod_pvt = (_i); \ (_r)->req_cons = (_i); \
Signature · 1 line
2.34.1
Quoted 8 lines · Juergen Gross
For the initialization of a ring page by the frontend two macros are available in
ring.h:SHARED_RING_INIT()andFRONT_RING_INIT().All known users use always both of them in direct sequence.
Add another macro
XEN_FRONT_RING_INIT()combining the two macros.Signed-off-by Juergen Gross <[email protected]>
albeit ...
xen/include/public/io/ring.h typedef unsigned int RING_IDX; · line 99
Quoted 11 lines
xen/include/public/io/ring.h +2
-3@@ -95,9 +95,8 @@ typedef unsigned int RING_IDX;* of the shared memory area (PAGE_SIZE, for instance). To initialise * the front half: * -* mytag_front_ring_t front_ring; -* SHARED_RING_INIT((mytag_sring_t *)shared_page); -* FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); +* mytag_front_ring_t ring; +* XEN_FRONT_RING_INIT(&ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
... I had hoped for the original text to remain and the new macro being suggested as a shorthand. But you're the maintainer ...
Jan
Quoted 13 lines · Jan Beulich
Quoted 8 lines · Juergen Gross
For the initialization of a ring page by the frontend two macros are available in
ring.h:SHARED_RING_INIT()andFRONT_RING_INIT().All known users use always both of them in direct sequence.
Add another macro
XEN_FRONT_RING_INIT()combining the two macros.Signed-off-by Juergen Gross <[email protected]>Reviewed-by Jan Beulich <[email protected]>albeit ...
Quoted 14 lines
xen/include/public/io/ring.h typedef unsigned int RING_IDX; · line 99
Quoted 11 lines
xen/include/public/io/ring.h +2
-3@@ -95,9 +95,8 @@ typedef unsigned int RING_IDX;* of the shared memory area (PAGE_SIZE, for instance). To initialise * the front half: * -* mytag_front_ring_t front_ring; -* SHARED_RING_INIT((mytag_sring_t *)shared_page); -* FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); +* mytag_front_ring_t ring; +* XEN_FRONT_RING_INIT(&ring, (mytag_sring_t *)shared_page, PAGE_SIZE); ... I had hoped for the original text to remain and the new macro being suggested as a shorthand. But you're the maintainer ...
I prefer the single macro, as it is less code and has the proper name space.
Juergen