From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56928 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgZnC-00036C-In for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:30:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgZn9-0001mW-Ur for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:29:58 -0500 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:47126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgZn9-0001m1-NT 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 mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0M9TtVI009472 for ; Sat, 22 Jan 2011 09:29:55 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 p0M9TvRp1503340 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 p0M9TsJK028208 for ; Sat, 22 Jan 2011 02:29:54 -0700 From: Stefan Hajnoczi Date: Sat, 22 Jan 2011 09:29:23 +0000 Message-Id: <1295688567-25496-9-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 08/12] coroutine: Add qemu_in_coroutine() 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 The qemu_in_coroutine() function checks whether or not we are currently in a user coroutine. This can be used to distinguish between executing normal vcpu or iothread code from executing a coroutine. Signed-off-by: Stefan Hajnoczi --- qemu-coroutine.c | 5 +++++ qemu-coroutine.h | 7 +++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/qemu-coroutine.c b/qemu-coroutine.c index e55b7c6..9318600 100644 --- a/qemu-coroutine.c +++ b/qemu-coroutine.c @@ -43,3 +43,8 @@ Coroutine * coroutine_fn qemu_coroutine_self(void) { return (Coroutine*)coroutine_self(); } + +bool qemu_in_coroutine(void) +{ + return !coroutine_is_leader(coroutine_self()); +} diff --git a/qemu-coroutine.h b/qemu-coroutine.h index 41f90bb..1fad3bf 100644 --- a/qemu-coroutine.h +++ b/qemu-coroutine.h @@ -14,6 +14,8 @@ #ifndef QEMU_COROUTINE_H #define QEMU_COROUTINE_H +#include + /** * Mark a function that executes in coroutine context * @@ -78,4 +80,9 @@ void * coroutine_fn qemu_coroutine_yield(void *opaque); */ Coroutine * coroutine_fn qemu_coroutine_self(void); +/** + * Return whether or not currently inside a coroutine + */ +bool qemu_in_coroutine(void); + #endif /* QEMU_COROUTINE_H */ -- 1.7.2.3