From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51805 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pi7o5-0008M2-Ut for qemu-devel@nongnu.org; Wed, 26 Jan 2011 11:01:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pi7nk-0001yF-DX for qemu-devel@nongnu.org; Wed, 26 Jan 2011 11:01:17 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:41287) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pi7nk-0001xk-8F for qemu-devel@nongnu.org; Wed, 26 Jan 2011 11:00:56 -0500 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p0QFnlCn010712 for ; Wed, 26 Jan 2011 08:49:47 -0700 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0QG0rwc112148 for ; Wed, 26 Jan 2011 09:00:54 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0QG0qI1015597 for ; Wed, 26 Jan 2011 09:00:53 -0700 Message-ID: <4D404534.6040304@linux.vnet.ibm.com> Date: Wed, 26 Jan 2011 10:00:52 -0600 From: Anthony Liguori 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> <4D403DD3.9030209@redhat.com> In-Reply-To: <4D403DD3.9030209@redhat.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: Avi Kivity Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , qemu-devel@nongnu.org On 01/26/2011 09:29 AM, Avi Kivity wrote: > 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. This is old (shared) code from other projects. My plan is to split into a separate library instead of actually including this in QEMU. Regards, Anthony Liguori