qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC v2 02/15] Rename qemu_coroutine_self to qemu_corou


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC v2 02/15] Rename qemu_coroutine_self to qemu_coroutine_self_int and add an annotated wrapper
Date: Wed, 14 Aug 2013 16:21:24 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Aug 09, 2013 at 07:43:52PM +0200, Charlie Shepherd wrote:
> @@ -133,3 +133,8 @@ void coroutine_fn qemu_coroutine_yield(void)
>      self->caller = NULL;
>      coroutine_swap(self, to);
>  }
> +
> +coroutine_fn Coroutine *qemu_coroutine_self(void)
> +{
> +    return qemu_coroutine_self_int();
> +}

The example in include/block/coroutine.h says:

 * For example:
 *
 *   static void coroutine_fn foo(void) {
 *       ....
 *   }

Not sure how happy compilers are with __attribute__ before the return
type, but I suggest consistently placing coroutine_fn after the return
type.

Also, a comment would be helpful here to explain the need for the
external/internal functions.  Otherwise the next person might undo this
again thinking it pointless :).

coroutine_fn Coroutine *qemu_coroutine_self(void)
{
    /* Call the internal version of this function, which is
     * non-coroutine_fn and can therefore be called from from
     * non-coroutine contexts.  Internally we know it's always possible
     * to pull a Coroutine* out of thin air (or thread-local storage).
     * External callers shouldn't assume they can always get a
     * Coroutine* since we may not be in coroutine context, hence the
     * external version of this function.
     */
    return qemu_coroutine_self_int(); 
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]