From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58142 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pi7Jn-0006Pp-Va for qemu-devel@nongnu.org; Wed, 26 Jan 2011 10:30:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pi7JI-0007Ju-PM for qemu-devel@nongnu.org; Wed, 26 Jan 2011 10:29:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pi7JI-0007Jb-FF for qemu-devel@nongnu.org; Wed, 26 Jan 2011 10:29:28 -0500 Message-ID: <4D403DD3.9030209@redhat.com> Date: Wed, 26 Jan 2011 17:29:23 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC][PATCH 05/12] coroutine: Add coroutines References: <1295688567-25496-1-git-send-email-stefanha@linux.vnet.ibm.com> <1295688567-25496-6-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1295688567-25496-6-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , qemu-devel@nongnu.org On 01/22/2011 11:29 AM, Stefan Hajnoczi wrote: > Add functions to create coroutines and transfer control into a coroutine > and back out again. > > > + > +struct Coroutine { > + struct coroutine co; > +}; > + > > +/** > + * Coroutine entry point > + * > + * When the coroutine is entered for the first time, opaque is passed in as an > + * argument. > + * > + * When this function returns, the coroutine is destroyed automatically and the > + * return value is passed back to the caller who last entered the coroutine. > + */ > +typedef void * coroutine_fn CoroutineEntry(void *opaque); The more modern style is to use the Coroutine structure as argument, and let the coroutine function use container_of() to obtain access to its own data structures. Similarly it can store any return value there, avoiding casts to and from void pointers. -- error compiling committee.c: too many arguments to function