WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Fix compat mode type checking macros for

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Fix compat mode type checking macros for gcc 4.5
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 08 Mar 2010 11:15:16 -0800
Delivery-date: Mon, 08 Mar 2010 11:15:41 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1268075460 0
# Node ID a02b1c791c9b954b66e0b225982088fd97e3422b
# Parent  2fc43ea6b8def7bd921b2fcfcec21499c5fb7570
Fix compat mode type checking macros for gcc 4.5

Just like with the __RING_SIZE() macro, the compat mode type checking
macros also need changing in order to work with gcc 4.5.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/common/compat/memory.c |   13 ++++-----
 xen/include/xen/compat.h   |   63 ++++++++++++++++++++++++++++-----------------
 2 files changed, 46 insertions(+), 30 deletions(-)

diff -r 2fc43ea6b8de -r a02b1c791c9b xen/common/compat/memory.c
--- a/xen/common/compat/memory.c        Mon Mar 08 19:10:27 2010 +0000
+++ b/xen/common/compat/memory.c        Mon Mar 08 19:11:00 2010 +0000
@@ -6,6 +6,12 @@
 #include <xen/event.h>
 #include <asm/current.h>
 #include <compat/memory.h>
+
+#define xen_domid_t domid_t
+#define compat_domid_t domid_compat_t
+CHECK_TYPE(domid);
+#undef compat_domid_t
+#undef xen_domid_t
 
 int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat)
 {
@@ -169,13 +175,6 @@ int compat_memory_op(unsigned int cmd, X
         case XENMEM_current_reservation:
         case XENMEM_maximum_reservation:
         case XENMEM_maximum_gpfn:
-        {
-#define xen_domid_t domid_t
-#define compat_domid_t domid_compat_t
-            CHECK_TYPE(domid);
-#undef compat_domid_t
-#undef xen_domid_t
-        }
         case XENMEM_maximum_ram_page:
             nat.hnd = compat;
             break;
diff -r 2fc43ea6b8de -r a02b1c791c9b xen/include/xen/compat.h
--- a/xen/include/xen/compat.h  Mon Mar 08 19:10:27 2010 +0000
+++ b/xen/include/xen/compat.h  Mon Mar 08 19:11:00 2010 +0000
@@ -128,44 +128,61 @@
 })
 
 
+#define CHECK_NAME(name, tag) __check ## tag ## name
+#define CHECK_NAME_(k, n, tag) __check ## tag ## k ## _ ## n
+
 #define CHECK_TYPE(name) \
-    typedef int __checkT ## name[1 - ((xen_ ## name ## _t *)0 != \
-                                   (compat_ ## name ## _t *)0) * 2]
+static inline int CHECK_NAME(name, T)(xen_ ## name ## _t *x, \
+                                      compat_ ## name ## _t *c) \
+{ \
+    return x == c; \
+}
 #define CHECK_TYPE_(k, n) \
-    typedef int __checkT ## k ## _ ## n[1 - ((k xen_ ## n *)0 != \
-                                          (k compat_ ## n *)0) * 2]
+static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \
+                                       k compat_ ## n *c) \
+{ \
+    return x == c; \
+}
 
 #define CHECK_SIZE(name) \
-    typedef int __checkS ## name[1 - (sizeof(xen_ ## name ## _t) != \
-                                   sizeof(compat_ ## name ## _t)) * 2]
+    typedef int CHECK_NAME(name, S)[1 - (sizeof(xen_ ## name ## _t) != \
+                                         sizeof(compat_ ## name ## _t)) * 2]
 #define CHECK_SIZE_(k, n) \
-    typedef int __checkS ## k ## _ ## n[1 - (sizeof(k xen_ ## n) != \
+    typedef int CHECK_NAME_(k, n, S)[1 - (sizeof(k xen_ ## n) != \
                                           sizeof(k compat_ ## n)) * 2]
 
+#define CHECK_FIELD_COMMON(name, t, f) \
+static inline int name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \
+{ \
+    BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \
+                 offsetof(compat_ ## t ## _t, f)); \
+    return &x->f == &c->f; \
+}
+#define CHECK_FIELD_COMMON_(k, name, n, f) \
+static inline int name(k xen_ ## n *x, k compat_ ## n *c) \
+{ \
+    BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \
+                 offsetof(k compat_ ## n, f)); \
+    return &x->f == &c->f; \
+}
+
 #define CHECK_FIELD(t, f) \
-    typedef int __checkF ## t ## __ ## f[1 - (&((xen_ ## t ## _t *)0)->f != \
-                                           &((compat_ ## t ## _t *)0)->f) * 2]
+    CHECK_FIELD_COMMON(CHECK_NAME(t ## __ ## f, F), t, f)
 #define CHECK_FIELD_(k, n, f) \
-    typedef int __checkF ## k ## _ ## n ## __ ## f[1 - (&((k xen_ ## n *)0)->f 
!= \
-                                                     &((k compat_ ## n 
*)0)->f) * 2]
+    CHECK_FIELD_COMMON_(k, CHECK_NAME_(k, n ## __ ## f, F), n, f)
 
 #define CHECK_SUBFIELD_1(t, f1, f2) \
-    typedef int __checkF1 ## t ## __ ## f1 ## __ ## f2 \
-                [1 - (&((xen_ ## t ## _t *)0)->f1.f2 != \
-                   &((compat_ ## t ## _t *)0)->f1.f2) * 2]
+    CHECK_FIELD_COMMON(CHECK_NAME(t ## __ ## f1 ## __ ## f2, F1), t, f1.f2)
 #define CHECK_SUBFIELD_1_(k, n, f1, f2) \
-    typedef int __checkF1 ## k ## _ ## n ## __ ## f1 ## __ ## f2 \
-                [1 - (&((k xen_ ## n *)0)->f1.f2 != \
-                   &((k compat_ ## n *)0)->f1.f2) * 2]
+    CHECK_FIELD_COMMON_(k, CHECK_NAME_(k, n ## __ ## f1 ## __ ## f2, F1), \
+                        n, f1.f2)
 
 #define CHECK_SUBFIELD_2(t, f1, f2, f3) \
-    typedef int __checkF2 ## t ## __ ## f1 ## __ ## f2 ## __ ## f3 \
-                [1 - (&((xen_ ## t ## _t *)0)->f1.f2.f3 != \
-                   &((compat_ ## t ## _t *)0)->f1.f2.f3) * 2]
+    CHECK_FIELD_COMMON(CHECK_NAME(t ## __ ## f1 ## __ ## f2 ## __ ## f3, F2), \
+                       t, f1.f2.f3)
 #define CHECK_SUBFIELD_2_(k, n, f1, f2, f3) \
-    typedef int __checkF2 ## k ## _ ## n ## __ ## f1 ## __ ## f2 ## __ ## f3 \
-                [1 - (&((k xen_ ## n *)0)->f1.f2.f3 != \
-                   &((k compat_ ## n *)0)->f1.f2.f3) * 2]
+    CHECK_FIELD_COMMON_(k, CHECK_NAME_(k, n ## __ ## f1 ## __ ## f2 ## __ ## \
+                                       f3, F2), n, f1.f2.f3)
 
 int hypercall_xlat_continuation(unsigned int *id, unsigned int mask, ...);
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Fix compat mode type checking macros for gcc 4.5, Xen patchbot-unstable <=