]> xenbits.xensource.com Git - xen.git/commitdiff
Provide a variant of __RING_SIZE() that is an integer constant
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 24 Feb 2010 11:03:56 +0000 (11:03 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 24 Feb 2010 11:03:56 +0000 (11:03 +0000)
expression

Without that, gcc 4.5 won't compile (at least) netfront, where this is
being used to specify array sizes.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/include/public/io/ring.h
xen/include/public/io/usbif.h

index 3c56bc2d62e634d73a9b5bdf9afee83a18e5134d..0880b1c52ef465d0aae27190adac0f09522b73f9 100644 (file)
@@ -50,6 +50,12 @@ typedef unsigned int RING_IDX;
  * A ring contains as many entries as will fit, rounded down to the nearest 
  * power of two (so we can mask with (size-1) to loop around).
  */
+#define __CONST_RING_SIZE(_s, _sz) \
+    (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
+           sizeof(((struct _s##_sring *)0)->ring[0])))
+/*
+ * The same for passing in an actual pointer instead of a name tag.
+ */
 #define __RING_SIZE(_s, _sz) \
     (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
 
index 91e82b88298fb87976d77fbe959f1f5588bccdcc..6099c29baa8a3e7cf3460a6ee3ed2ab7ac330111 100644 (file)
@@ -128,7 +128,7 @@ struct usbif_urb_response {
 typedef struct usbif_urb_response usbif_urb_response_t;
 
 DEFINE_RING_TYPES(usbif_urb, struct usbif_urb_request, struct usbif_urb_response);
-#define USB_URB_RING_SIZE __RING_SIZE((struct usbif_urb_sring *)0, PAGE_SIZE)
+#define USB_URB_RING_SIZE __CONST_RING_SIZE(usbif_urb, PAGE_SIZE)
 
 /*
  * RING for notifying connect/disconnect events to frontend
@@ -146,6 +146,6 @@ struct usbif_conn_response {
 typedef struct usbif_conn_response usbif_conn_response_t;
 
 DEFINE_RING_TYPES(usbif_conn, struct usbif_conn_request, struct usbif_conn_response);
-#define USB_CONN_RING_SIZE __RING_SIZE((struct usbif_conn_sring *)0, PAGE_SIZE)
+#define USB_CONN_RING_SIZE __CONST_RING_SIZE(usbif_conn, PAGE_SIZE)
 
 #endif /* __XEN_PUBLIC_IO_USBIF_H__ */