From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56969 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgZnF-00036e-3J for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:30:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgZn9-0001mQ-TJ for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:30:00 -0500 Received: from mtagate6.uk.ibm.com ([194.196.100.166]:39327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgZn9-0001ll-J9 for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:29:55 -0500 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate6.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0M9TsBd028710 for ; Sat, 22 Jan 2011 09:29:54 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0M9TvBk1384694 for ; Sat, 22 Jan 2011 09:29:57 GMT Received: from d06av07.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0M9TsZZ028186 for ; Sat, 22 Jan 2011 02:29:54 -0700 From: Stefan Hajnoczi Date: Sat, 22 Jan 2011 09:29:21 +0000 Message-Id: <1295688567-25496-7-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1295688567-25496-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1295688567-25496-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [RFC][PATCH 06/12] coroutine: Add qemu_coroutine_self() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi Add a function to get the current coroutine. There is always a current coroutine, either the "leader" (default main coroutine) or a specific coroutine created with qemu_coroutine_create(). Signed-off-by: Stefan Hajnoczi --- qemu-coroutine.c | 5 +++++ qemu-coroutine.h | 5 +++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/qemu-coroutine.c b/qemu-coroutine.c index dd2cd8e..e55b7c6 100644 --- a/qemu-coroutine.c +++ b/qemu-coroutine.c @@ -38,3 +38,8 @@ void * coroutine_fn qemu_coroutine_yield(void *opaque) { return coroutine_yield(opaque); } + +Coroutine * coroutine_fn qemu_coroutine_self(void) +{ + return (Coroutine*)coroutine_self(); +} diff --git a/qemu-coroutine.h b/qemu-coroutine.h index 22fe4ea..41f90bb 100644 --- a/qemu-coroutine.h +++ b/qemu-coroutine.h @@ -73,4 +73,9 @@ void *qemu_coroutine_enter(Coroutine *coroutine, void *opaque); */ void * coroutine_fn qemu_coroutine_yield(void *opaque); +/** + * Get the currently executing coroutine + */ +Coroutine * coroutine_fn qemu_coroutine_self(void); + #endif /* QEMU_COROUTINE_H */ -- 1.7.2.3