Lines Matching +full:- +full:- +full:with +full:- +full:coroutine

2  * emscripten fiber coroutine initialization code
3 * based on coroutine-ucontext.c
19 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24 #include "qemu/coroutine-tls.h"
29 Coroutine base;
42 * Per-thread coroutine bookkeeping
44 QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
50 Coroutine *co = co_; in coroutine_trampoline()
53 co->entry(co->entry_arg); in coroutine_trampoline()
54 qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); in coroutine_trampoline()
58 Coroutine *qemu_coroutine_new(void) in qemu_coroutine_new()
64 co->stack_size = COROUTINE_STACK_SIZE; in qemu_coroutine_new()
65 co->stack = qemu_alloc_stack(&co->stack_size); in qemu_coroutine_new()
67 co->asyncify_stack_size = COROUTINE_STACK_SIZE; in qemu_coroutine_new()
68 co->asyncify_stack = g_malloc0(co->asyncify_stack_size); in qemu_coroutine_new()
69 emscripten_fiber_init(&co->fiber, coroutine_trampoline, &co->base, in qemu_coroutine_new()
70 co->stack, co->stack_size, co->asyncify_stack, in qemu_coroutine_new()
71 co->asyncify_stack_size); in qemu_coroutine_new()
73 return &co->base; in qemu_coroutine_new()
76 void qemu_coroutine_delete(Coroutine *co_) in qemu_coroutine_delete()
80 qemu_free_stack(co->stack, co->stack_size); in qemu_coroutine_delete()
81 g_free(co->asyncify_stack); in qemu_coroutine_delete()
85 CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, in qemu_coroutine_switch()
92 to->action = action; in qemu_coroutine_switch()
93 emscripten_fiber_swap(&from->fiber, &to->fiber); in qemu_coroutine_switch()
94 return from->action; in qemu_coroutine_switch()
97 Coroutine *qemu_coroutine_self(void) in qemu_coroutine_self()
99 Coroutine *self = get_current(); in qemu_coroutine_self()
105 leaderp->asyncify_stack = g_malloc0(leader_asyncify_stack_size); in qemu_coroutine_self()
106 leaderp->asyncify_stack_size = leader_asyncify_stack_size; in qemu_coroutine_self()
108 &leaderp->fiber, in qemu_coroutine_self()
109 leaderp->asyncify_stack, in qemu_coroutine_self()
110 leaderp->asyncify_stack_size); in qemu_coroutine_self()
111 leaderp->stack = leaderp->fiber.stack_limit; in qemu_coroutine_self()
112 leaderp->stack_size = in qemu_coroutine_self()
113 leaderp->fiber.stack_base - leaderp->fiber.stack_limit; in qemu_coroutine_self()
116 self = &leaderp->base; in qemu_coroutine_self()
124 Coroutine *self = get_current(); in qemu_in_coroutine()
126 return self && self->caller; in qemu_in_coroutine()