xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH V3] xl: create VFB for PV guest when VNC is specified
Date: Tue, 17 Dec 2013 11:36:29 +0000	[thread overview]
Message-ID: <52B0373D.1080602@citrix.com> (raw)
In-Reply-To: <20131217112809.GC26994@zion.uk.xensource.com>

On 17/12/13 11:28, Wei Liu wrote:
> On Mon, Dec 16, 2013 at 05:46:04PM +0000, Ian Campbell wrote:
> [...]
>>> Changes in V2:
>>> * use macros to reduce code duplication
>>> * vfb=[] take precedence over top level VNC options
>>> ---
>>>  tools/libxl/xl_cmdimpl.c |   89 ++++++++++++++++++++++++++++++++++++----------
>>>  1 file changed, 70 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
>>> index bd26bcc..6a22e17 100644
>>> --- a/tools/libxl/xl_cmdimpl.c
>>> +++ b/tools/libxl/xl_cmdimpl.c
>>> @@ -315,6 +315,13 @@ static void *xrealloc(void *ptr, size_t sz) {
>>>      return r;
>>>  }
>>>  
>>> +#define ARRAY_EXTEND(array,count)                                       \
>>> +    do {                                                                \
>>> +        (array) = xrealloc((array),                                     \
>>> +                           sizeof(typeof(*(array))) * ((count) + 1));   \
>> sizeof(typeof(*array)) == sizeof(*array), doesn't it?
>>
>>> +        (count) = (count) + 1;                                          \
>> (count++)
>>
>> I suppose in a macro like this it is tricky to arrange to only evaluate
>> the arguments once, since you need to read and write, but I think you
>> can arrange to evaluate array exactly once instead of 3 times and count
>> just once.
>>
> I came up with this. Is it what you asked for?
>
> #define ARRAY_EXTEND(type_ptr,ptr,type_count,count,ret)                 \
>     do {                                                                \
>         type_ptr **__ptr = &(ptr);                                      \
>         type_count *__count = &(count);                                 \
>         *__ptr = xrealloc(*__ptr,                                       \
>                           sizeof(**__ptr) * (*__count + 1));            \
>         (ret) = *__ptr + *__count;                                      \
>         (*__count)++;                                                   \
>     } while (0)
>
> Wei.

Use typeof() rather than passing the types in directly.  It is a GCC
extension, which tries its best not to evaluate its argument.

Alternatively, the __auto_type gcc keyword sould seem to do what you
want as well.

~Andrew

  reply	other threads:[~2013-12-17 11:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16 17:39 [PATCH V3] xl: create VFB for PV guest when VNC is specified Wei Liu
2013-12-16 17:46 ` Ian Campbell
2013-12-17 11:28   ` Wei Liu
2013-12-17 11:36     ` Andrew Cooper [this message]
2013-12-17 11:40       ` Wei Liu
2013-12-17 11:41         ` Ian Campbell
2013-12-17 11:49           ` Wei Liu
2013-12-17 15:02             ` Ian Jackson
2013-12-17 15:16               ` Wei Liu
2013-12-17 16:15                 ` Ian Jackson
2013-12-17 16:40                   ` Ian Campbell
2013-12-17 16:52                     ` Wei Liu
2013-12-17 18:04                       ` Ian Jackson
2013-12-17 21:51                         ` Wei Liu
2013-12-17 14:44   ` Ian Jackson

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=52B0373D.1080602@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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).