diff mbox series

xen/public: add new macro to ring.h

Message ID 20220426090810.28616-1-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series xen/public: add new macro to ring.h | expand

Commit Message

Jürgen Groß April 26, 2022, 9:08 a.m. UTC
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.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/include/public/io/ring.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jan Beulich April 26, 2022, 9:43 a.m. UTC | #1
On 26.04.2022 11:08, Juergen Gross wrote:
> --- a/xen/include/public/io/ring.h
> +++ b/xen/include/public/io/ring.h
> @@ -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
Jürgen Groß April 26, 2022, 3:31 p.m. UTC | #2
On 26.04.22 11:43, Jan Beulich wrote:
> On 26.04.2022 11:08, Juergen Gross wrote:
>> --- a/xen/include/public/io/ring.h
>> +++ b/xen/include/public/io/ring.h
>> @@ -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.

Okay.

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

> 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
diff mbox series

Patch

diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h
index 277af36e61..3925d6ad95 100644
--- a/xen/include/public/io/ring.h
+++ b/xen/include/public/io/ring.h
@@ -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);                                              \