Patchwork [RFC,07/12] coroutine: Add coroutine_is_leader()

login
register
mail settings
Submitter Stefan Hajnoczi
Date Jan. 22, 2011, 9:29 a.m.
Message ID <1295688567-25496-8-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/79979/
State New
Headers show

Comments

Stefan Hajnoczi - Jan. 22, 2011, 9:29 a.m.
Make it possible to check whether a coroutine is the default main
coroutine (the "leader") or not.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 coroutine.h          |    2 ++
 coroutine_ucontext.c |    5 +++++
 2 files changed, 7 insertions(+), 0 deletions(-)

Patch

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;