[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] Provide a variant of __RING_SIZE() that is an integer constant



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1267009502 0
# Node ID efae51e0fa91a9ef3f0497dcba19e7ade60397c5
# Parent  ff275dae07eecb5bbcd99cc0f8cb9fd41d400145
Provide a variant of __RING_SIZE() that is an integer constant
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@xxxxxxxxxx>
---
 drivers/xen/blkfront/block.h     |    2 +-
 drivers/xen/blktap/blktap.c      |    2 +-
 drivers/xen/blktap2/blktap.h     |    2 +-
 drivers/xen/netback/common.h     |    4 ++--
 drivers/xen/netfront/netfront.h  |    4 ++--
 drivers/xen/scsifront/common.h   |    3 +--
 include/xen/interface/io/ring.h  |    6 ++++++
 include/xen/interface/io/usbif.h |    4 ++--
 8 files changed, 16 insertions(+), 11 deletions(-)

diff -r ff275dae07ee -r efae51e0fa91 drivers/xen/blkfront/block.h
--- a/drivers/xen/blkfront/block.h      Mon Feb 22 10:03:18 2010 +0000
+++ b/drivers/xen/blkfront/block.h      Wed Feb 24 11:05:02 2010 +0000
@@ -87,7 +87,7 @@ struct blk_shadow {
        unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 };
 
-#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+#define BLK_RING_SIZE __CONST_RING_SIZE(blkif, PAGE_SIZE)
 
 /*
  * We have one of these per vbd, whether ide, scsi or 'other'.  They
diff -r ff275dae07ee -r efae51e0fa91 drivers/xen/blktap/blktap.c
--- a/drivers/xen/blktap/blktap.c       Mon Feb 22 10:03:18 2010 +0000
+++ b/drivers/xen/blktap/blktap.c       Wed Feb 24 11:05:02 2010 +0000
@@ -70,7 +70,7 @@
  * mmap_alloc is initialised to 2 and should be adjustable on the fly via
  * sysfs.
  */
-#define BLK_RING_SIZE          __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+#define BLK_RING_SIZE          __CONST_RING_SIZE(blkif, PAGE_SIZE)
 #define MAX_DYNAMIC_MEM                BLK_RING_SIZE
 #define MAX_PENDING_REQS       BLK_RING_SIZE
 #define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
diff -r ff275dae07ee -r efae51e0fa91 drivers/xen/blktap2/blktap.h
--- a/drivers/xen/blktap2/blktap.h      Mon Feb 22 10:03:18 2010 +0000
+++ b/drivers/xen/blktap2/blktap.h      Wed Feb 24 11:05:02 2010 +0000
@@ -69,7 +69,7 @@ extern int blktap_debug_level;
  * mmap_alloc is initialised to 2 and should be adjustable on the fly via
  * sysfs.
  */
-#define BLK_RING_SIZE          __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+#define BLK_RING_SIZE          __CONST_RING_SIZE(blkif, PAGE_SIZE)
 #define MAX_DYNAMIC_MEM                BLK_RING_SIZE
 #define MAX_PENDING_REQS       BLK_RING_SIZE
 #define MMAP_PAGES (MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
diff -r ff275dae07ee -r efae51e0fa91 drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h      Mon Feb 22 10:03:18 2010 +0000
+++ b/drivers/xen/netback/common.h      Wed Feb 24 11:05:02 2010 +0000
@@ -177,8 +177,8 @@ void netif_accel_init(void);
 void netif_accel_init(void);
 
 
-#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
-#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
+#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
+#define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE)
 
 void netif_disconnect(netif_t *netif);
 
diff -r ff275dae07ee -r efae51e0fa91 drivers/xen/netfront/netfront.h
--- a/drivers/xen/netfront/netfront.h   Mon Feb 22 10:03:18 2010 +0000
+++ b/drivers/xen/netfront/netfront.h   Wed Feb 24 11:05:02 2010 +0000
@@ -38,8 +38,8 @@
 #include <linux/skbuff.h>
 #include <linux/list.h>
 
-#define NET_TX_RING_SIZE __RING_SIZE((struct netif_tx_sring *)0, PAGE_SIZE)
-#define NET_RX_RING_SIZE __RING_SIZE((struct netif_rx_sring *)0, PAGE_SIZE)
+#define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
+#define NET_RX_RING_SIZE __CONST_RING_SIZE(netif_rx, PAGE_SIZE)
 
 #include <xen/xenbus.h>
 
diff -r ff275dae07ee -r efae51e0fa91 drivers/xen/scsifront/common.h
--- a/drivers/xen/scsifront/common.h    Mon Feb 22 10:03:18 2010 +0000
+++ b/drivers/xen/scsifront/common.h    Wed Feb 24 11:05:02 2010 +0000
@@ -70,8 +70,7 @@
 #define VSCSIIF_MAX_TARGET          64
 #define VSCSIIF_MAX_LUN             255
 
-#define VSCSIIF_RING_SIZE      \
-    __RING_SIZE((struct vscsiif_sring *)0, PAGE_SIZE)
+#define VSCSIIF_RING_SIZE      __CONST_RING_SIZE(vscsiif, PAGE_SIZE)
 #define VSCSIIF_MAX_REQS       VSCSIIF_RING_SIZE
 
 struct vscsifrnt_shadow {
diff -r ff275dae07ee -r efae51e0fa91 include/xen/interface/io/ring.h
--- a/include/xen/interface/io/ring.h   Mon Feb 22 10:03:18 2010 +0000
+++ b/include/xen/interface/io/ring.h   Wed Feb 24 11:05:02 2010 +0000
@@ -49,6 +49,12 @@ typedef unsigned int RING_IDX;
  * ring and indexes (_sz), and the name tag of the request/response structure.
  * 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])))
diff -r ff275dae07ee -r efae51e0fa91 include/xen/interface/io/usbif.h
--- a/include/xen/interface/io/usbif.h  Mon Feb 22 10:03:18 2010 +0000
+++ b/include/xen/interface/io/usbif.h  Wed Feb 24 11:05:02 2010 +0000
@@ -128,7 +128,7 @@ typedef struct usbif_urb_response usbif_
 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 @@ typedef struct usbif_conn_response usbif
 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__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.