aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2015-02-10 11:31:52 +0100
committerKevin Wolf <kwolf@redhat.com>2015-03-09 11:11:59 +0100
commitcd12bb567cdcd9665a5acdecd6ac8afd9a977003 (patch)
tree0e87c404f617b7a4d5ea9332b20384716b53268a
parent315a1309defd8ddf910c6c17e28cbbd7faf92f2e (diff)
coroutine: Clean up qemu_coroutine_enter()
qemu_coroutine_enter() is now the only user of coroutine_swap(). Both functions are short, so inline it. Also, using COROUTINE_YIELD is now even more confusing because this code is never called during qemu_coroutine_yield() any more. In fact, this value is never read back, so we can just introduce a new COROUTINE_ENTER which documents the purpose of the task switch better. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--include/block/coroutine_int.h1
-rw-r--r--qemu-coroutine.c36
2 files changed, 16 insertions, 21 deletions
diff --git a/include/block/coroutine_int.h b/include/block/coroutine_int.h
index f133d65af8..9aa1aae5d5 100644
--- a/include/block/coroutine_int.h
+++ b/include/block/coroutine_int.h
@@ -31,6 +31,7 @@
typedef enum {
COROUTINE_YIELD = 1,
COROUTINE_TERMINATE = 2,
+ COROUTINE_ENTER = 3,
} CoroutineAction;
struct Coroutine {
diff --git a/qemu-coroutine.c b/qemu-coroutine.c
index 5019b81dd5..c17a92b107 100644
--- a/qemu-coroutine.c
+++ b/qemu-coroutine.c
@@ -99,29 +99,10 @@ static void coroutine_delete(Coroutine *co)
qemu_coroutine_delete(co);
}
-static void coroutine_swap(Coroutine *from, Coroutine *to)
-{
- CoroutineAction ret;
-
- ret = qemu_coroutine_switch(from, to, COROUTINE_YIELD);
-
- qemu_co_queue_run_restart(to);
-
- switch (ret) {
- case COROUTINE_YIELD:
- return;
- case COROUTINE_TERMINATE:
- trace_qemu_coroutine_terminate(to);
- coroutine_delete(to);
- return;
- default:
- abort();
- }
-}
-
void qemu_coroutine_enter(Coroutine *co, void *opaque)
{
Coroutine *self = qemu_coroutine_self();
+ CoroutineAction ret;
trace_qemu_coroutine_enter(self, co, opaque);
@@ -132,7 +113,20 @@ void qemu_coroutine_enter(Coroutine *co, void *opaque)
co->caller = self;
co->entry_arg = opaque;
- coroutine_swap(self, co);
+ ret = qemu_coroutine_switch(self, co, COROUTINE_ENTER);
+
+ qemu_co_queue_run_restart(co);
+
+ switch (ret) {
+ case COROUTINE_YIELD:
+ return;
+ case COROUTINE_TERMINATE:
+ trace_qemu_coroutine_terminate(co);
+ coroutine_delete(co);
+ return;
+ default:
+ abort();
+ }
}
void coroutine_fn qemu_coroutine_yield(void)