Skip to contentSkip to conversation

xen/public: add new macro to ring.h

PATCH Superseded Juergen Gross 2 participants 3 messages Apr 26, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 xen/include/public/io/ring.h | 5 +++++
 1 file changed, 5 insertions(+)
xen/include/public/io/ring.h +5 -0
index 277af36e61..3925d6ad95 100644
@@ -184,6 +184,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
#1 lore raw

xen/include/public/io/ring.h typedef struct __name##_back_ring __name##_back_ring_t · line 190

Quoted 10 lines · Juergen Gross
xen/include/public/io/ring.h +4 -0
@@ -184,6 +184,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)

I think it would be good for the comment around line 100 to also have a reference to this.

As to style: Could I talk you into not further proliferating the inappropriate use of underscore-prefixed names as macro parameters? Even more so one with a double underscore?

As to functionality: I take it that it is not viewed as an issue that many of the macros here evaluate their arguments multiple times?

Jan

#2 lore raw
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Juergen Gross
xen/include/public/io/ring.h +0 -0
@@ -184,6 +184,11 @@ typedef struct __name##_back_ring __name##_back_ring_t
 
  #define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __size)
 
Quoted 7 lines

xen/include/public/io/ring.h typedef struct __name##_back_ring __name##_back_ring_t · line 190

Quoted 4 lines
xen/include/public/io/ring.h +4 -0
+#define XEN_FRONT_RING_INIT(_r, _s, __size) do {                        \
+    SHARED_RING_INIT(_s);                                               \
+    FRONT_RING_INIT(_r, _s, __size);                                    \
+} while (0)

I think it would be good for the comment around line 100 to also have a reference to this.

Okay.

Quoted 3 lines

As to style: Could I talk you into not further proliferating the inappropriate use of underscore-prefixed names as macro parameters? Even more so one with a double underscore?

Okay.

Quoted 3 lines

As to functionality: I take it that it is not viewed as an issue that many of the macros here evaluate their arguments multiple times?

I don't think this is problematic.

Juergen