forked from ariadne/libucontext
riscv64: simplify the context swapping
parent
6763b5ba1e
commit
11a40293be
|
@ -37,10 +37,9 @@ libucontext_makecontext(libucontext_ucontext_t *ucp, void (*func)(void), int arg
|
|||
/* set up the ucontext structure */
|
||||
ucp->uc_mcontext.__gregs[REG_RA] = (libucontext_greg_t) libucontext_trampoline;
|
||||
ucp->uc_mcontext.__gregs[REG_S0] = 0;
|
||||
ucp->uc_mcontext.__gregs[REG_S1] = (libucontext_greg_t) func;
|
||||
ucp->uc_mcontext.__gregs[REG_S2] = (libucontext_greg_t) ucp->uc_link;
|
||||
ucp->uc_mcontext.__gregs[REG_S1] = (libucontext_greg_t) ucp->uc_link;
|
||||
ucp->uc_mcontext.__gregs[REG_SP] = (libucontext_greg_t) sp;
|
||||
ucp->uc_mcontext.__gregs[REG_PC] = 0;
|
||||
ucp->uc_mcontext.__gregs[REG_PC] = (libucontext_greg_t) func;
|
||||
|
||||
va_start(va, argc);
|
||||
|
||||
|
|
|
@ -50,6 +50,6 @@ FUNC(libucontext_setcontext)
|
|||
ld s10, REG_OFFSET(REG_S10)(t0)
|
||||
ld s11, REG_OFFSET(REG_S11)(t0)
|
||||
|
||||
/* done saving, return */
|
||||
ret
|
||||
/* done restoring, jump to new pc in S1 */
|
||||
jr t1
|
||||
END(libucontext_setcontext)
|
||||
|
|
|
@ -13,14 +13,11 @@
|
|||
#include "defs.h"
|
||||
|
||||
FUNC(libucontext_trampoline)
|
||||
/* call the function passed to makecontext() */
|
||||
jalr s1
|
||||
|
||||
/* check for linked context */
|
||||
beqz s2, no_linked_context
|
||||
beqz s1, no_linked_context
|
||||
|
||||
/* if one is set, invoke it */
|
||||
mv a0, s2
|
||||
mv a0, s1
|
||||
jal libucontext_setcontext
|
||||
|
||||
/* otherwise, exit. */
|
||||
|
|
|
@ -75,6 +75,6 @@ FUNC(libucontext_swapcontext)
|
|||
ld s10, REG_OFFSET(REG_S10)(t0)
|
||||
ld s11, REG_OFFSET(REG_S11)(t0)
|
||||
|
||||
/* done swapping, return */
|
||||
ret
|
||||
/* done swapping, jump to new PC in S1 */
|
||||
jr t1
|
||||
END(libucontext_swapcontext)
|
||||
|
|
Loading…
Reference in New Issue