debuggers.hg

changeset 21055:a02b1c791c9b

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@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 08 19:11:00 2010 +0000 (2010-03-08)
parents 2fc43ea6b8de
children 2629c6a79d64
files xen/common/compat/memory.c xen/include/xen/compat.h
line diff
     1.1 --- a/xen/common/compat/memory.c	Mon Mar 08 19:10:27 2010 +0000
     1.2 +++ b/xen/common/compat/memory.c	Mon Mar 08 19:11:00 2010 +0000
     1.3 @@ -7,6 +7,12 @@
     1.4  #include <asm/current.h>
     1.5  #include <compat/memory.h>
     1.6  
     1.7 +#define xen_domid_t domid_t
     1.8 +#define compat_domid_t domid_compat_t
     1.9 +CHECK_TYPE(domid);
    1.10 +#undef compat_domid_t
    1.11 +#undef xen_domid_t
    1.12 +
    1.13  int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat)
    1.14  {
    1.15      int rc, split, op = cmd & MEMOP_CMD_MASK;
    1.16 @@ -169,13 +175,6 @@ int compat_memory_op(unsigned int cmd, X
    1.17          case XENMEM_current_reservation:
    1.18          case XENMEM_maximum_reservation:
    1.19          case XENMEM_maximum_gpfn:
    1.20 -        {
    1.21 -#define xen_domid_t domid_t
    1.22 -#define compat_domid_t domid_compat_t
    1.23 -            CHECK_TYPE(domid);
    1.24 -#undef compat_domid_t
    1.25 -#undef xen_domid_t
    1.26 -        }
    1.27          case XENMEM_maximum_ram_page:
    1.28              nat.hnd = compat;
    1.29              break;
     2.1 --- a/xen/include/xen/compat.h	Mon Mar 08 19:10:27 2010 +0000
     2.2 +++ b/xen/include/xen/compat.h	Mon Mar 08 19:11:00 2010 +0000
     2.3 @@ -128,44 +128,61 @@
     2.4  })
     2.5  
     2.6  
     2.7 +#define CHECK_NAME(name, tag) __check ## tag ## name
     2.8 +#define CHECK_NAME_(k, n, tag) __check ## tag ## k ## _ ## n
     2.9 +
    2.10  #define CHECK_TYPE(name) \
    2.11 -    typedef int __checkT ## name[1 - ((xen_ ## name ## _t *)0 != \
    2.12 -                                   (compat_ ## name ## _t *)0) * 2]
    2.13 +static inline int CHECK_NAME(name, T)(xen_ ## name ## _t *x, \
    2.14 +                                      compat_ ## name ## _t *c) \
    2.15 +{ \
    2.16 +    return x == c; \
    2.17 +}
    2.18  #define CHECK_TYPE_(k, n) \
    2.19 -    typedef int __checkT ## k ## _ ## n[1 - ((k xen_ ## n *)0 != \
    2.20 -                                          (k compat_ ## n *)0) * 2]
    2.21 +static inline int CHECK_NAME_(k, n, T)(k xen_ ## n *x, \
    2.22 +                                       k compat_ ## n *c) \
    2.23 +{ \
    2.24 +    return x == c; \
    2.25 +}
    2.26  
    2.27  #define CHECK_SIZE(name) \
    2.28 -    typedef int __checkS ## name[1 - (sizeof(xen_ ## name ## _t) != \
    2.29 -                                   sizeof(compat_ ## name ## _t)) * 2]
    2.30 +    typedef int CHECK_NAME(name, S)[1 - (sizeof(xen_ ## name ## _t) != \
    2.31 +                                         sizeof(compat_ ## name ## _t)) * 2]
    2.32  #define CHECK_SIZE_(k, n) \
    2.33 -    typedef int __checkS ## k ## _ ## n[1 - (sizeof(k xen_ ## n) != \
    2.34 +    typedef int CHECK_NAME_(k, n, S)[1 - (sizeof(k xen_ ## n) != \
    2.35                                            sizeof(k compat_ ## n)) * 2]
    2.36  
    2.37 +#define CHECK_FIELD_COMMON(name, t, f) \
    2.38 +static inline int name(xen_ ## t ## _t *x, compat_ ## t ## _t *c) \
    2.39 +{ \
    2.40 +    BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \
    2.41 +                 offsetof(compat_ ## t ## _t, f)); \
    2.42 +    return &x->f == &c->f; \
    2.43 +}
    2.44 +#define CHECK_FIELD_COMMON_(k, name, n, f) \
    2.45 +static inline int name(k xen_ ## n *x, k compat_ ## n *c) \
    2.46 +{ \
    2.47 +    BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \
    2.48 +                 offsetof(k compat_ ## n, f)); \
    2.49 +    return &x->f == &c->f; \
    2.50 +}
    2.51 +
    2.52  #define CHECK_FIELD(t, f) \
    2.53 -    typedef int __checkF ## t ## __ ## f[1 - (&((xen_ ## t ## _t *)0)->f != \
    2.54 -                                           &((compat_ ## t ## _t *)0)->f) * 2]
    2.55 +    CHECK_FIELD_COMMON(CHECK_NAME(t ## __ ## f, F), t, f)
    2.56  #define CHECK_FIELD_(k, n, f) \
    2.57 -    typedef int __checkF ## k ## _ ## n ## __ ## f[1 - (&((k xen_ ## n *)0)->f != \
    2.58 -                                                     &((k compat_ ## n *)0)->f) * 2]
    2.59 +    CHECK_FIELD_COMMON_(k, CHECK_NAME_(k, n ## __ ## f, F), n, f)
    2.60  
    2.61  #define CHECK_SUBFIELD_1(t, f1, f2) \
    2.62 -    typedef int __checkF1 ## t ## __ ## f1 ## __ ## f2 \
    2.63 -                [1 - (&((xen_ ## t ## _t *)0)->f1.f2 != \
    2.64 -                   &((compat_ ## t ## _t *)0)->f1.f2) * 2]
    2.65 +    CHECK_FIELD_COMMON(CHECK_NAME(t ## __ ## f1 ## __ ## f2, F1), t, f1.f2)
    2.66  #define CHECK_SUBFIELD_1_(k, n, f1, f2) \
    2.67 -    typedef int __checkF1 ## k ## _ ## n ## __ ## f1 ## __ ## f2 \
    2.68 -                [1 - (&((k xen_ ## n *)0)->f1.f2 != \
    2.69 -                   &((k compat_ ## n *)0)->f1.f2) * 2]
    2.70 +    CHECK_FIELD_COMMON_(k, CHECK_NAME_(k, n ## __ ## f1 ## __ ## f2, F1), \
    2.71 +                        n, f1.f2)
    2.72  
    2.73  #define CHECK_SUBFIELD_2(t, f1, f2, f3) \
    2.74 -    typedef int __checkF2 ## t ## __ ## f1 ## __ ## f2 ## __ ## f3 \
    2.75 -                [1 - (&((xen_ ## t ## _t *)0)->f1.f2.f3 != \
    2.76 -                   &((compat_ ## t ## _t *)0)->f1.f2.f3) * 2]
    2.77 +    CHECK_FIELD_COMMON(CHECK_NAME(t ## __ ## f1 ## __ ## f2 ## __ ## f3, F2), \
    2.78 +                       t, f1.f2.f3)
    2.79  #define CHECK_SUBFIELD_2_(k, n, f1, f2, f3) \
    2.80 -    typedef int __checkF2 ## k ## _ ## n ## __ ## f1 ## __ ## f2 ## __ ## f3 \
    2.81 -                [1 - (&((k xen_ ## n *)0)->f1.f2.f3 != \
    2.82 -                   &((k compat_ ## n *)0)->f1.f2.f3) * 2]
    2.83 +    CHECK_FIELD_COMMON_(k, CHECK_NAME_(k, n ## __ ## f1 ## __ ## f2 ## __ ## \
    2.84 +                                       f3, F2), n, f1.f2.f3)
    2.85  
    2.86  int hypercall_xlat_continuation(unsigned int *id, unsigned int mask, ...);
    2.87