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

Re: [Xen-devel] 32/64-bit hypercall interface - padding

On Tuesday 04 October 2005 16:57, Jimi Xenidis wrote:
> Nice idea but not sufficient cuz the pointer could be in the worng
> place you probably want
>   struct {
>         char _pad[sizeof (u64) - sizeof (long)];
>         vcpu_guest_context_t *ptr;
>  } ctxt;

Good catch. And this goes one step further to hide it:

#define PAD_POINTER char _pad[sizeof(u64) - sizeof(void*)]
typedef struct {
    union {
        vcpu_guest_context_t *ptr;
    } ctxt;
} dom0_setdomaininfo_t;

Or this:

#define PAD_POINTER(type, name) \
    union { \
        char _pad[sizeof(u64) - sizeof(void*)]; \
        type *ptr; \
    } name;
typedef struct {
    PAD_POINTER(vcpu_guest_context_t, ctxt);
} dom0_setdomaininfo_t;

That looks nice, but it may confuse tools like cscope. Of course, so would the 
original XENIF_PTR macro idea. So I think I like the first better.

Hollis Blanchard
IBM Linux Technology Center

Xen-devel mailing list



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