Skip to contentSkip to conversation

compile fix for RING_HAS_UNCONSUMED_REQUESTS

PATCH In review John Levon 2 participants 5 messages Oct 17, 2006

lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/1 compile fix for RING_HAS_UNCONSUMED_REQUESTS

# HG changeset patch
# User [email protected]
# Date 1161091691 25200
# Node ID ae762c159e7311a5a19e6b29227a665994a1325b # Parent a58e7e6dde6b1f6094ea07917b3db794082c409b fixes to compile ring.h on solaris with Sun's cc

xen/include/public/io/ring.h +10 -6
@@ -27,6 +27,12 @@ typedef unsigned int RING_IDX;
 #define __RING_SIZE(_s, _sz) \
     (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
 
+/* Solaris equivalents */
+#ifdef _SOLARIS
+#define	wmb	membar_producer
+#define	mb	membar_enter
+#endif
+
 /*
  * Macros to make the correct C datatypes for a new kind of ring.
  * 
@@ -166,12 +172,10 @@ typedef struct __name##_back_ring __name
     ((_r)->sring->rsp_prod - (_r)->rsp_cons)
 
 #define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
-    ({									\
-	unsigned int req = (_r)->sring->req_prod - (_r)->req_cons;	\
-	unsigned int rsp = RING_SIZE(_r) -				\
-			   ((_r)->req_cons - (_r)->rsp_prod_pvt);	\
-	req < rsp ? req : rsp;						\
-    })
+	(((_r)->sring->req_prod - (_r)->req_cons) <			\
+	(RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ?	\
+	    ((_r)->sring->req_prod - (_r)->req_cons) :			\
+	    (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))
 
 /* Direct access to individual ring elements, by index. */
 #define RING_GET_REQUEST(_r, _idx)                                      \
#1 lore raw
Quoted 3 lines · John Levon

fixes to compile ring.h on solaris with Sun's cc

Not nice. I assume you snapshot the headers anyway, so you'll just have to patch as you do so.

-- Keir

author
#2 lore raw
Quoted 6 lines · Keir Fraser
Quoted 3 lines

fixes to compile ring.h on solaris with Sun's cc

Not nice. I assume you snapshot the headers anyway, so you'll just have to patch as you do so.

Yes, we do. Having to patch from upstream is a constant pain, even with mq. If GCC-specific gunk is OK we'll eventually end up diverging totally as people use GCC stuff more and more.

It's a pretty vile define anyway...

regards,
john

#3 lore raw
In reply to John Levon
Quoted 8 lines · John Levon

# HG changeset patch
# User [email protected]
# Date 1161091691 25200
# Node ID ae762c159e7311a5a19e6b29227a665994a1325b # Parent a58e7e6dde6b1f6094ea07917b3db794082c409b fixes to compile ring.h on solaris with Sun's cc

I like the gcc syntax so I'll take the patch version of that macro as a non-GNUC alternative, so both live in the upstream header file. I'm not taking the chunk with the mb/wmb definitions for Solaris. It's up to the user of this public header file to provide suitable definitions external to this header file.

-- Keir

author
#4 lore raw
Quoted 8 lines · Keir Fraser
Quoted 2 lines

# Parent a58e7e6dde6b1f6094ea07917b3db794082c409b fixes to compile ring.h on solaris with Sun's cc

I like the gcc syntax so I'll take the patch version of that macro as a non-GNUC alternative, so both live in the upstream header file. I'm not taking the chunk with the mb/wmb definitions for Solaris. It's up to the user of this public header file to provide suitable definitions external to this header file.

OK, sure.

thanks,
john