summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/coroutine.h4
-rw-r--r--gtk/coroutine_gthread.c4
-rw-r--r--gtk/coroutine_ucontext.c5
-rw-r--r--gtk/coroutine_winfibers.c5
4 files changed, 17 insertions, 1 deletions
diff --git a/gtk/coroutine.h b/gtk/coroutine.h
index 7e3bc28..15b90b4 100644
--- a/gtk/coroutine.h
+++ b/gtk/coroutine.h
@@ -55,7 +55,7 @@ struct coroutine
#endif
};
-#define IN_MAIN_CONTEXT (coroutine_self() == NULL || coroutine_self()->caller == NULL)
+#define IN_MAIN_CONTEXT (coroutine_self() == NULL || coroutine_is_main_context(coroutine_self()))
int coroutine_init(struct coroutine *co);
int coroutine_release(struct coroutine *co);
@@ -68,6 +68,8 @@ void *coroutine_yieldto(struct coroutine *to, void *arg);
void *coroutine_yield(void *arg);
+gboolean coroutine_is_main_context(struct coroutine *co);
+
#endif
/*
* Local variables:
diff --git a/gtk/coroutine_gthread.c b/gtk/coroutine_gthread.c
index 51d2d6f..ab30631 100644
--- a/gtk/coroutine_gthread.c
+++ b/gtk/coroutine_gthread.c
@@ -160,3 +160,7 @@ void *coroutine_yield(void *arg)
return coroutine_swap(coroutine_self(), to, arg);
}
+gboolean coroutine_is_main_context(struct coroutine *co)
+{
+ return (co == &leader);
+}
diff --git a/gtk/coroutine_ucontext.c b/gtk/coroutine_ucontext.c
index 889f0d6..f960cfb 100644
--- a/gtk/coroutine_ucontext.c
+++ b/gtk/coroutine_ucontext.c
@@ -130,6 +130,11 @@ void *coroutine_yield(void *arg)
coroutine_self()->caller = NULL;
return coroutine_swap(coroutine_self(), to, arg);
}
+
+gboolean coroutine_is_main_context(struct coroutine *co)
+{
+ return (co == &leader);
+}
/*
* Local variables:
* c-indent-level: 8
diff --git a/gtk/coroutine_winfibers.c b/gtk/coroutine_winfibers.c
index f4a4481..266b1de 100644
--- a/gtk/coroutine_winfibers.c
+++ b/gtk/coroutine_winfibers.c
@@ -111,6 +111,11 @@ void *coroutine_yield(void *arg)
coroutine_self()->caller = NULL;
return coroutine_swap(coroutine_self(), to, arg);
}
+
+gboolean coroutine_is_main_context(struct coroutine *co)
+{
+ return (co == &leader);
+}
/*
* Local variables:
* c-indent-level: 8