xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] fix compat mode type checking macros for gcc 4.5
Date: Mon, 08 Mar 2010 15:58:59 +0000	[thread overview]
Message-ID: <4B952CD30200007800033442@vpn.id2.novell.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5211 bytes --]

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@novell.com>

--- 2010-03-02.orig/xen/common/compat/memory.c	2009-07-06 15:07:20.000000000 +0200
+++ 2010-03-02/xen/common/compat/memory.c	2010-03-05 13:42:15.000000000 +0100
@@ -7,6 +7,12 @@
 #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)
 {
     int rc, split, op = cmd & MEMOP_CMD_MASK;
@@ -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;
--- 2010-03-02.orig/xen/include/xen/compat.h	2009-03-04 12:16:26.000000000 +0100
+++ 2010-03-02/xen/include/xen/compat.h	2010-03-05 13:44:11.000000000 +0100
@@ -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, ...);
 



[-- Attachment #2: compat-checks-gcc-4.5.patch --]
[-- Type: text/plain, Size: 5207 bytes --]

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@novell.com>

--- 2010-03-02.orig/xen/common/compat/memory.c	2009-07-06 15:07:20.000000000 +0200
+++ 2010-03-02/xen/common/compat/memory.c	2010-03-05 13:42:15.000000000 +0100
@@ -7,6 +7,12 @@
 #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)
 {
     int rc, split, op = cmd & MEMOP_CMD_MASK;
@@ -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;
--- 2010-03-02.orig/xen/include/xen/compat.h	2009-03-04 12:16:26.000000000 +0100
+++ 2010-03-02/xen/include/xen/compat.h	2010-03-05 13:44:11.000000000 +0100
@@ -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, ...);
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2010-03-08 15:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B952CD30200007800033442@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).