int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) { struct rv rv = __getcontext (oucp); if (rv.first_return) __setcontext (ucp); return 0; }
int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) { extern void __swapcontext_ret (void); /* Save the current machine context to oucp. */ __getcontext (oucp); /* Modify oucp to skip the __setcontext call on reactivation. */ oucp->uc_mcontext.mc_gregs[MC_PC] = (long) __swapcontext_ret; oucp->uc_mcontext.mc_gregs[MC_NPC] = ((long) __swapcontext_ret) + 4; /* Restore the machine context in ucp. */ __setcontext (ucp, 1); return 0; }
int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp) { /* Save the current machine context to oucp. */ __getcontext (oucp); /* mark sc_sar flag to skip the setcontext call on reactivation. */ if (oucp->uc_mcontext.sc_sar == 0) { oucp->uc_mcontext.sc_sar++; /* Restore the machine context in ucp. */ __setcontext (ucp); } return 0; }