From 758668d11a00ddcd2df86dbf7be3a94aa8581384 Mon Sep 17 00:00:00 2001 From: ligd Date: Fri, 10 Feb 2023 16:12:46 +0800 Subject: [PATCH] sim: remove sim_saveusercontext() return value Signed-off-by: ligd --- arch/sim/src/sim/sim_doirq.c | 4 +++- arch/sim/src/sim/sim_internal.h | 21 ++++++++++++--------- arch/sim/src/sim/sim_saveusercontext.c | 6 +++++- arch/sim/src/sim/sim_switchcontext.c | 7 ++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/arch/sim/src/sim/sim_doirq.c b/arch/sim/src/sim/sim_doirq.c index a84c90622c..4cf7c1f68c 100644 --- a/arch/sim/src/sim/sim_doirq.c +++ b/arch/sim/src/sim/sim_doirq.c @@ -43,12 +43,14 @@ void *sim_doirq(int irq, void *context) xcpt_reg_t tmp[XCPTCONTEXT_REGS]; void *regs = (void *)tmp; + int ret; /* CURRENT_REGS non-zero indicates that we are processing an interrupt. * CURRENT_REGS is also used to manage interrupt level context switches. */ - if (sim_saveusercontext(regs) == 0) + sim_saveusercontext(regs, ret); + if (ret == 0) { CURRENT_REGS = regs; diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h index 71a91a8839..e498c987b5 100644 --- a/arch/sim/src/sim/sim_internal.h +++ b/arch/sim/src/sim/sim_internal.h @@ -85,17 +85,20 @@ #define sim_savestate(regs) sim_copyfullstate(regs, (xcpt_reg_t *)CURRENT_REGS) #define sim_restorestate(regs) (CURRENT_REGS = regs) -#define sim_saveusercontext(saveregs) \ - ({ \ - irqstate_t flags = up_irq_flags(); \ - xcpt_reg_t *env = saveregs; \ - uint32_t *val = (uint32_t *)&env[JB_FLAG]; \ +#define sim_saveusercontext(saveregs, ret) \ + do \ + { \ + irqstate_t flags = up_irq_flags(); \ + xcpt_reg_t *env = saveregs; \ + uint32_t *val = (uint32_t *)&env[JB_FLAG]; \ \ - val[0] = flags & UINT32_MAX; \ - val[1] = (flags >> 32) & UINT32_MAX; \ + val[0] = flags & UINT32_MAX; \ + val[1] = (flags >> 32) & UINT32_MAX; \ \ - setjmp(saveregs); \ - }) + ret = setjmp(saveregs); \ + } \ + while (0) + #define sim_fullcontextrestore(restoreregs) \ do \ { \ diff --git a/arch/sim/src/sim/sim_saveusercontext.c b/arch/sim/src/sim/sim_saveusercontext.c index df99e8a157..95b9a7292f 100644 --- a/arch/sim/src/sim/sim_saveusercontext.c +++ b/arch/sim/src/sim/sim_saveusercontext.c @@ -48,5 +48,9 @@ int up_saveusercontext(void *saveregs) { - return sim_saveusercontext(saveregs); + int ret; + + sim_saveusercontext(saveregs, ret); + + return ret; } diff --git a/arch/sim/src/sim/sim_switchcontext.c b/arch/sim/src/sim/sim_switchcontext.c index 3ecb284d71..182d1a375b 100644 --- a/arch/sim/src/sim/sim_switchcontext.c +++ b/arch/sim/src/sim/sim_switchcontext.c @@ -53,6 +53,8 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb) { + int ret; + sinfo("Unblocking TCB=%p\n", tcb); /* Update scheduler parameters */ @@ -80,6 +82,8 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb) /* Then switch contexts */ sim_restorestate(tcb->xcp.regs); + + return; } /* Copy the exception context into the TCB of the task that was @@ -87,7 +91,8 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb) * then this is really the previously running task restarting! */ - else if (!sim_saveusercontext(rtcb->xcp.regs)) + sim_saveusercontext(rtcb->xcp.regs, ret); + if (ret == 0) { sinfo("New Active Task TCB=%p\n", tcb);