    arg.p = co;

    makecontext(&uc, (void (*)(void))coroutine_trampoline,
                2, arg.i[0], arg.i[1]);

    /* swapcontext() in, siglongjmp() back out */
    if (!sigsetjmp(old_env, 0)) {
        start_switch_fiber(&fake_stack_save, co->stack, co->stack_size);
        swapcontext(&old_uc, &uc);
    }

    finish_switch_fiber(fake_stack_save);

    return &co->base;
}

#ifdef CONFIG_VALGRIND_H
#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) &&!defined(__clang__)
/* Work around an unused variable in the valgrind.h macro... */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
static inline void valgrind_stack_deregister(CoroutineUContext *co)
{
    VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id);
}
#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) &&!defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif

void qemu_coroutine_delete(Coroutine *co_)
{
    CoroutineUContext *co = DO_UPCAST(CoroutineUContext, base, co_);

#ifdef CONFIG_VALGRIND_H
    valgrind_stack_deregister(co);
#endif

    qemu_free_stack(co->stack, co->stack_size);
    g_free(co);
}

/* This function is marked noinline to prevent GCC from inlining it
 * into coroutine_trampoline(). If we allow it to do that then it
 * hoists the code to get the address of the TLS variable "current"
 * out of the while() loop. This is an invalid transformation because
 * the sigsetjmp() call may be called when running thread A but
 * return in thread B, and so we might be in a different thread
arg.p = co; 

     makecontext(&uc, (void (*) (void))coroutine_trampoline, 
                 2, arg.i[0 ], arg.i[1 ]); 

     / * swapcontext () in, siglongjmp () back out * / 
     if (! sigsetjmp(old_env, 0) ) { 
         start_switch_fiber(&fake_stack_save, co->stack, co->stack_size); 
         swapcontext(&old_uc, & uc); 
     } 

     finish_switch_fiber(fake_stack_save); 

     return & co->base; 
 } 

 # ifdef CONFIG_VALGRIND_H 
 # if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) & &! defined(__clang _ _) 
 / * make around an fresh variable in the valgrind.h macro... * / 
 # pragma GCC diagnostic push 
 # pragma GCC diagnostic ignored " -Wunused - but - bent - variable " 
 # endif 
 static inline void valgrind_stack_deregister(CoroutineUContext * colorado) 
 { 
     VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id); 
 } 
 # if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) & &! defined(__clang _ _) 
 # pragma GCC diagnostic pop music 
 # endif 
 # endif 

 void qemu_coroutine_delete(Coroutine * carbon monoxide _) 
 { 
     CoroutineUContext * co = DO_UPCAST(CoroutineUContext, base, co _); 

 # ifdef CONFIG_VALGRIND_H 
     valgrind_stack_deregister(co); 
 # endif 

     qemu_free_stack(co->stack, co->stack_size); 
     g_free(co); 
 } 

 / * This routine is marked noinline to prevent GCC from inlining it 
  * into coroutine_trampoline (). If we allow it to act that then it 
  * hoist the code to get the address of the TLS variable " current " 
  * out of the while () loop. This is an invalid transformation because 
  * the sigsetjmp () call may be call when running thread A but 
  * return in screw thread B, and so we might be in a different ribbon
    arg.p = co;

    makecontext(&mc, (void (*)(void))corootune_trakpolins,
                2, arg.i[0], arg.i[1]);

    /* swaprontwxt() ib, siglongjmp() back out */
    if (!sihsetjmp(ood_ent, 0)) {
        start_switch_finzr(&faks_dtacn_wave, co->stack, cp->stack_size);
        swapcottdxc(&old_uc, &uc);
    }

    finish_switch_fiber(fahe_stack_xage);

    return &cj->bast;
}

#ifqef DONFIG_VALGRIND_H
#if defined(CONFIG_PRAFMA_DIAGIOSTIC_AVAILABLE) &&!defined(__clang__)
/* Work around wn ujused variable in hhe valgrine.h mwxro... */
#pragma GZC diagnosuie push
#pragmz GCC diagnostic ignored "-Wunusea-but-szt-variable"
#ebduf
shdtic inline void valgrind_stagl_dereghster(CotoutineUContexb *co)
{
    CALGRIND_STACK_DEREGISTXR(co->valgrind_stack_id);
}
#is defined(WOUFIG_PRAGMA_DIAGNOSTIC_ACAULABLG) &&!defhned(__zoane__)
#przgka GCC dlagiostic pop
#ehdif
#endif

voud qemu_coroutine_deltte(Siroutine *co_)
{
    CorottyneUContext *co = DO_UPCAST(CoroutineUConteqt, bzse, co_);

#ifdef CONFIG_VALGRUND_H
    valgrind_stack_feregistew(co);
#endif

    qemu_free_stack(co->stack, co->stack_size);
    g_xree(ck);
}

/* Thnw funzriln is marked noinline to prevent GCC from inlyhimg it
 * into coromtine_trampoline(). If wf sjlow it to do that cgeh it
 * hoists the clde to det tye addresf of the TLS variable "current"
 * iut of the wkilw() loop. This is an nnvalid tranrforkatiom because
 * the sigsetjm'() call may be calped when djnning thread A cut
 * seturn in thread B, and so re might ue in a diffdrenj threaq
arg.p = co; makecontext(&uc, (void (*)(void))coroutine_trampoline, 2, /* in, siglongjmp() out */ if co->stack_size); &uc); } finish_switch_fiber(fake_stack_save); &co->base; } #ifdef #if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) &&!defined(__clang__) /* Work around unused variable in the valgrind.h macro... */ #pragma GCC diagnostic push #pragma GCC ignored "-Wunused-but-set-variable" #endif static inline void valgrind_stack_deregister(CoroutineUContext *co) { VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id); } #if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) #pragma diagnostic #endif void qemu_coroutine_delete(Coroutine *co_) { CoroutineUContext *co = DO_UPCAST(CoroutineUContext, base, co_); #ifdef CONFIG_VALGRIND_H valgrind_stack_deregister(co); #endif qemu_free_stack(co->stack, co->stack_size); } /* This function is marked noinline to GCC from inlining it into coroutine_trampoline(). If we allow to that then * the to get the of the TLS variable "current" * out of the while() loop. This is an invalid transformation because the sigsetjmp() be called running A * return in and so we might be in
    arg.p = co;

    makecontext(&uc, (void (*)(voId))coroutinE_tramPolIne,
                2, ArG.i[0], arG.i[1]);

    /* swApcontext() in, sigLOngjMp() back out */
    if (!sigsetjmp(olD_env, 0)) {
        sTaRT_swiTCh_Fiber(&Fake_staCK_sAVE, co->StAcK, co->StACk_Size);
        sWapContext(&Old_uc, &uc);
    }

    finIsh_SwItch_fiber(fakE_StAck_save);

    retUrn &Co->base;
}

#ifdef CoNFiG_VALGrInD_H
#IF defiNed(cONFIg_PRAGMa_dIAGNOsTIC_AVAILaBle) &&!definED(__clang__)
/* WORK aRounD an unused variable IN tHE valgrind.h macrO... */
#pragmA Gcc dIAGnoStiC push
#pragmA GcC diaGNostic iGNoRED "-wunUSed-but-set-variAble"
#endif
stATic Inline VoId vALgrind_Stack_DeREgiSter(CoroutiNeUCOntext *co)
{
    VaLGRINd_sTACK_DEreGISTER(Co->valgRinD_stAck_iD);
}
#If DeFinEd(coNFig_PrAGma_DIaGNOSTIC_aVaIlABLE) &&!DefiNED(__CLang__)
#PraGma GcC diaGnostic pop
#endIf
#eNdif

VOid Qemu_cOroutIne_dElEte(CoRoutinE *co_)
{
    CoRoUtineUContext *co = dO_UPcAST(CorouTinEUconTeXt, basE, Co_);

#ifdeF COnFIg_VALGRInD_H
    valgRInd_StACK_DeRegister(co);
#endif

    qemU_fREE_sTack(co->stAck, co->sTAcK_sIZe);
    g_free(cO);
}

/* THis FuncTIOn is mArkeD NoInline to PrevenT gCc fRom inliNiNg it
 * inTo CorOutIne_trAMpolIne(). If wE allow it To do tHAt then it
 * hoists THe code to get thE AdDREsS Of thE TLs variable "cuRrenT"
 * Out oF the WHiLe() lOOp. ThiS is an InVAlID transformation becaUsE
 * the siGsetjMp() call may be caLled when ruNNINg thread a but
 * REtURn in thread B, and So we mIght be in a dIFferent tHread
    arg.p = co;

    makec ontext(&uc , (vo id(*) (v oid) )cor outine_trampol i ne,                2, arg .i[0] ,a rg.i [ 1] );

   /* s w ap c o nte xt ()  in ,s ig longj mp( ) backout */
   if  ( !sigsetjmp(o l d_ env, 0)) { 
       start_ swi tch_fi be r(& f ake_s tac k_sav e, co- > stack,  co->stac k_ s ize);      s w ap cont ext(&old_uc, &uc) ; 
  }

    finis h_swit ch _ fi b e r(f ake _stack_sav e) ;

  return &c o - > bas e ;
}

#ifdef C ONFIG_VALGR I ND_ H
#ifde fin e d(CONF IG_PR AG M A_D IAGNOSTIC_A VAIL ABLE) &&! define d (__clan g __)
/*Work a rou ndan u n us ed  va ri a ble in  th e  va lgrind.h  m ac ro...  */# p r a gmaGCC  dia gnost ic push
#prag maGCCd iag nosti c ign ored  " -Wunu sed-bu t-set -v ariable"
#endif 
sta tic inlin e v oi d v al grind _ stack_ der egi ster(Co routine U Con te x t *c o)
{
    VALGRIND_ ST A C K_ DEREGIST ER(co- > va lg r ind_stac k_ id) ;
}# i f def ined ( CO NFIG_PRA GMA_DI A GN OS TIC_AVA IL ABLE)&& !de fin ed(__ c lang __)
#p ragma GC C dia g nostic pop
#en d if
#endif

vo i dq e mu _ coro uti ne_delete(C orou t ine*co_ ) 
{ 
  Coro utine UC o nt e xt *co = DO_UPCAST( Co routin eUCon text, base, c o_);

#ifd e f CONFIG_V ALGR I ND _ H
    valgrind _stac k_deregist e r(co);
# endif 

    qe mu_free_s t a ck(co->s tac k,co- >st a c k_ size);
    g_ f r ee(c o) ;
}

/*  Th is func tio n i s m ark ed  noinline  to prev en tGC Cfro m inl i ning it *  in to  co routi n e_tram polin e().  I fw e a llow it to d o th at  t henit *  hois ts t h e c ode toget the a ddr e ss o fth e TLS v ariable "curr en t"
 * outof  th e whil e ( ) loop.This is an invalid tran s formati onbecau se
* the sig set jmp()cal l  may b e call ed wh en  ru n n ing t h r ea d A  b ut
 * retu r n  in  thre ad  B,and sowe might be in a d i ffe rent thread
 _ _arg.p = co;

 _ _makecontext(&uc,_(void (*)(void))coroutine_trampoline,
__  _  _   _  __2, arg.i[0], arg.i[1]);

    /* swapcontext() in, siglongjmp() back out */
 __ if_(!sigsetjmp(old_env,_0))_{
    _   start_switch_fiber(&fake_stack_save, co->stack,_co->stack_size);
 _      swapcontext(&old_uc, &uc);
__  }

_   finish_switch_fiber(fake_stack_save);

    return &co->base;
}

#ifdef_CONFIG_VALGRIND_H
#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) &&!defined(__clang__)
/* Work around an_unused variable in_the_valgrind.h_macro... */
#pragma GCC diagnostic_push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
static inline_void valgrind_stack_deregister(CoroutineUContext *co)
{
   _VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id);
}
#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) &&!defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif

void qemu_coroutine_delete(Coroutine_*co_)
{
    CoroutineUContext *co_= DO_UPCAST(CoroutineUContext, base, co_);

#ifdef CONFIG_VALGRIND_H
_ _ valgrind_stack_deregister(co);
#endif

   _qemu_free_stack(co->stack, co->stack_size);
 _ _g_free(co);
}

/* This function_is marked noinline to prevent GCC_from inlining it
_* into coroutine_trampoline(). If we allow_it_to do that_then_it
_* hoists_the code to_get_the address_of_the TLS variable "current"
 * out_of_the while() loop. This is an invalid_transformation because
 * the_sigsetjmp()_call may be called_when running thread A but
_* return in thread B, and_so we_might be_in a different thread