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

Re: [Xen-devel] [PATCH V3] xl: create VFB for PV guest when VNC is specified



On Tue, Dec 17, 2013 at 04:40:46PM +0000, Ian Campbell wrote:
> On Tue, 2013-12-17 at 16:15 +0000, Ian Jackson wrote:
> > Wei Liu writes ("Re: [Xen-devel] [PATCH V3] xl: create VFB for PV guest 
> > when VNC is specified"):
> > > On Tue, Dec 17, 2013 at 03:02:07PM +0000, Ian Jackson wrote:
> > > > Finally: IMO the macro should probably initialise the new element
> > > > itself.  So it will be more than just "ARRAY_EXTEND" because it will
> > > > have some knowledge of the kind of array it is, and might need to be
> > > > renamed.  Ian C, what do you think ?
> > > 
> > > Huh? Elements are initialized by different funcitons. You mean I need to
> > > add extra argument to the macro to pass in the initilization function?
> > 
> > Either that, or pass in just the core of the token eg "vkb" and use
> > token pasting to automatically create the right function name.
> > 
> > But please wait to see what Ian C says as he may disagree with me.
> 
> I'm happy either way. A more helpful macro is good but it is perhaps
> getting a bit complex, so I wouldn't blame Wei for wanting to keep it
> simpler by doing the init afterwards.
> 
> There's also an argument that this should be functionality provided in
> helpers generated by the IDL, but that certainly isn't 4.4 material...
> 

OK. Now it looks like this.

#define ARRAY_EXTEND_INIT(ptr,count,name)                               \
    ({                                                                  \
        typeof((ptr)) *_xl_array_ptr = &(ptr);                          \
        typeof((count)) *_xl_array_count = &(count);                    \
        typeof((count)) _xl_array_count_saved = *_xl_array_count;       \
        *_xl_array_ptr = xrealloc(*_xl_array_ptr,                       \
                                  sizeof(**_xl_array_ptr) *             \
                                  (*_xl_array_count + 1));              \
        (*_xl_array_count)++;                                           \
        libxl_device_##name##_init(*_xl_array_ptr + _xl_array_count_saved); \
        (*_xl_array_ptr + _xl_array_count_saved);                       \
    })

It 1) only evaluates its arguments once, 2) initializes the new element
with corresponding function, 3) returns the new element.

Longer local variables names are chosen in the hope that they don't
clash with other names...

Wei.

> Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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