summaryrefslogtreecommitdiffstats
path: root/include/xen/interface/io
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2010-12-08 12:39:12 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2010-12-15 12:34:28 -0800
commit667c78afaec0ac500908e191e8f236e9578d7b1f (patch)
tree11a469d8a4cfefea2fd3a56be2cda4c7784d54a1 /include/xen/interface/io
parent6c965ff5e7ca844494f1dcf0ec0440146db01294 (diff)
downloadop-kernel-dev-667c78afaec0ac500908e191e8f236e9578d7b1f.zip
op-kernel-dev-667c78afaec0ac500908e191e8f236e9578d7b1f.tar.gz
xen: Provide a variant of __RING_SIZE() that is an integer constant expression
Without this, gcc 4.5 won't compile xen-netfront and xen-blkfront, where this is being used to specify array sizes. Signed-off-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: David Miller <davem@davemloft.net> Cc: Stable Kernel <stable@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/xen/interface/io')
-rw-r--r--include/xen/interface/io/ring.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/ring.h
index e8cbf43..75271b9 100644
--- a/include/xen/interface/io/ring.h
+++ b/include/xen/interface/io/ring.h
@@ -24,8 +24,15 @@ 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 __RING_SIZE(_s, _sz) \
- (__RD32(((_sz) - (long)&(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0])))
+#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])))
/*
* Macros to make the correct C datatypes for a new kind of ring.
OpenPOWER on IntegriCloud