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

2  * ucontext coroutine initialization code
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 #include "qemu/coroutine-tls.h"
46 Coroutine base;
50 /* Need an unsafe stack for each coroutine */
68 * Per-thread coroutine bookkeeping
70 QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
91 co->tsan_co_fiber = __tsan_create_fiber(0); /* flags: sync on switch */ in on_new_fiber()
92 co->tsan_caller_fiber = __tsan_get_current_fiber(); in on_new_fiber()
107 if (!leaderp->stack) { in finish_switch_fiber()
108 leaderp->stack = (void *)bottom_old; in finish_switch_fiber()
109 leaderp->stack_size = size_old; in finish_switch_fiber()
138 co->tsan_caller_fiber : in start_switch_fiber_tsan()
139 co->tsan_co_fiber; in start_switch_fiber_tsan()
152 Coroutine *co; in coroutine_trampoline()
160 co = &self->base; in coroutine_trampoline()
163 if (!sigsetjmp(self->env, 0)) { in coroutine_trampoline()
167 leaderp->stack, leaderp->stack_size); in coroutine_trampoline()
169 siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); in coroutine_trampoline()
175 co->entry(co->entry_arg); in coroutine_trampoline()
176 qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); in coroutine_trampoline()
180 Coroutine *qemu_coroutine_new(void) in qemu_coroutine_new()
196 if (getcontext(&uc) == -1) { in qemu_coroutine_new()
201 co->stack_size = COROUTINE_STACK_SIZE; in qemu_coroutine_new()
202 co->stack = qemu_alloc_stack(&co->stack_size); in qemu_coroutine_new()
204 co->unsafe_stack_size = COROUTINE_STACK_SIZE; in qemu_coroutine_new()
205 co->unsafe_stack = qemu_alloc_stack(&co->unsafe_stack_size); in qemu_coroutine_new()
207 co->base.entry_arg = &old_env; /* stash away our jmp_buf */ in qemu_coroutine_new()
210 uc.uc_stack.ss_sp = co->stack; in qemu_coroutine_new()
211 uc.uc_stack.ss_size = co->stack_size; in qemu_coroutine_new()
215 co->valgrind_stack_id = in qemu_coroutine_new()
216 VALGRIND_STACK_REGISTER(co->stack, co->stack + co->stack_size); in qemu_coroutine_new()
227 start_switch_fiber_asan(&fake_stack_save, co->stack, co->stack_size); in qemu_coroutine_new()
236 * NOTE: we don't have to re-set the usp afterwards because we are in qemu_coroutine_new()
238 * The compiler already wrapped the corresponding sigsetjmp call with in qemu_coroutine_new()
240 * restores it right after (which is where we return with siglongjmp). in qemu_coroutine_new()
242 void *usp = co->unsafe_stack + co->unsafe_stack_size; in qemu_coroutine_new()
251 return &co->base; in qemu_coroutine_new()
258 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
262 VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id); in valgrind_stack_deregister()
275 start_switch_fiber_asan(NULL, to->stack, to->stack_size); in terminate_asan()
277 siglongjmp(to->env, COROUTINE_ENTER); in terminate_asan()
281 void qemu_coroutine_delete(Coroutine *co_) in qemu_coroutine_delete()
286 co_->entry_arg = qemu_coroutine_self(); in qemu_coroutine_delete()
287 co_->entry = terminate_asan; in qemu_coroutine_delete()
288 qemu_coroutine_switch(co_->entry_arg, co_, COROUTINE_ENTER); in qemu_coroutine_delete()
295 qemu_free_stack(co->stack, co->stack_size); in qemu_coroutine_delete()
297 qemu_free_stack(co->unsafe_stack, co->unsafe_stack_size); in qemu_coroutine_delete()
311 qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, in qemu_coroutine_switch()
321 ret = sigsetjmp(from->env, 0); in qemu_coroutine_switch()
326 to->stack, to->stack_size); in qemu_coroutine_switch()
329 siglongjmp(to->env, action); in qemu_coroutine_switch()
337 Coroutine *qemu_coroutine_self(void) in qemu_coroutine_self()
339 Coroutine *self = get_current(); in qemu_coroutine_self()
343 self = &leaderp->base; in qemu_coroutine_self()
347 if (!leaderp->tsan_co_fiber) { in qemu_coroutine_self()
348 leaderp->tsan_co_fiber = __tsan_get_current_fiber(); in qemu_coroutine_self()
356 Coroutine *self = get_current(); in qemu_in_coroutine()
358 return self && self->caller; in qemu_in_coroutine()