From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56917 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgZnB-00036A-AN for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:30:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgZn9-0001mH-Ie for qemu-devel@nongnu.org; Sat, 22 Jan 2011 04:29:57 -0500 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:56678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgZn9-0001lm-Az 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 mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0M9TsHT021917 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 p0M9Tvx91503338 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 p0M9TsNg028195 for ; Sat, 22 Jan 2011 02:29:54 -0700 From: Stefan Hajnoczi Date: Sat, 22 Jan 2011 09:29:22 +0000 Message-Id: <1295688567-25496-8-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 07/12] coroutine: Add coroutine_is_leader() 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 Make it possible to check whether a coroutine is the default main coroutine (the "leader") or not. Signed-off-by: Stefan Hajnoczi --- coroutine.h | 2 ++ coroutine_ucontext.c | 5 +++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/coroutine.h b/coroutine.h index 5316535..3aca19a 100644 --- a/coroutine.h +++ b/coroutine.h @@ -58,6 +58,8 @@ void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg); struct coroutine *coroutine_self(void); +int coroutine_is_leader(struct coroutine *co); + void *coroutine_yieldto(struct coroutine *to, void *arg); void *coroutine_yield(void *arg); diff --git a/coroutine_ucontext.c b/coroutine_ucontext.c index 289e5bd..b90a2f6 100644 --- a/coroutine_ucontext.c +++ b/coroutine_ucontext.c @@ -80,6 +80,11 @@ struct coroutine *coroutine_self(void) return current; } +int coroutine_is_leader(struct coroutine *co) +{ + return co == &leader; +} + void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg) { int ret; -- 1.7.2.3