Skip to content

Commit c311caa

Browse files
committed
sim: remove sim_saveusercontext() return value
Signed-off-by: ligd <liguiding1@xiaomi.com>
1 parent 6f2b120 commit c311caa

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

arch/sim/src/sim/sim_doirq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ void *sim_doirq(int irq, void *context)
4343

4444
xcpt_reg_t tmp[XCPTCONTEXT_REGS];
4545
void *regs = (void *)tmp;
46+
int ret;
4647

4748
/* CURRENT_REGS non-zero indicates that we are processing an interrupt.
4849
* CURRENT_REGS is also used to manage interrupt level context switches.
4950
*/
5051

51-
if (sim_saveusercontext(regs) == 0)
52+
sim_saveusercontext(regs, ret);
53+
if (ret == 0)
5254
{
5355
CURRENT_REGS = regs;
5456

arch/sim/src/sim/sim_internal.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,20 @@
8585
#define sim_savestate(regs) sim_copyfullstate(regs, (xcpt_reg_t *)CURRENT_REGS)
8686
#define sim_restorestate(regs) (CURRENT_REGS = regs)
8787

88-
#define sim_saveusercontext(saveregs) \
89-
({ \
90-
irqstate_t flags = up_irq_flags(); \
91-
xcpt_reg_t *env = saveregs; \
92-
uint32_t *val = (uint32_t *)&env[JB_FLAG]; \
88+
#define sim_saveusercontext(saveregs, ret) \
89+
do \
90+
{ \
91+
irqstate_t flags = up_irq_flags(); \
92+
xcpt_reg_t *env = saveregs; \
93+
uint32_t *val = (uint32_t *)&env[JB_FLAG]; \
9394
\
94-
val[0] = flags & UINT32_MAX; \
95-
val[1] = (flags >> 32) & UINT32_MAX; \
95+
val[0] = flags & UINT32_MAX; \
96+
val[1] = (flags >> 32) & UINT32_MAX; \
9697
\
97-
setjmp(saveregs); \
98-
})
98+
ret = setjmp(saveregs); \
99+
} \
100+
while (0)
101+
99102
#define sim_fullcontextrestore(restoreregs) \
100103
do \
101104
{ \

arch/sim/src/sim/sim_saveusercontext.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,9 @@
4848

4949
int up_saveusercontext(void *saveregs)
5050
{
51-
return sim_saveusercontext(saveregs);
51+
int ret;
52+
53+
sim_saveusercontext(saveregs, ret);
54+
55+
return ret;
5256
}

arch/sim/src/sim/sim_switchcontext.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353

5454
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
5555
{
56+
int ret;
57+
5658
sinfo("Unblocking TCB=%p\n", tcb);
5759

5860
/* Update scheduler parameters */
@@ -80,14 +82,17 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
8082
/* Then switch contexts */
8183

8284
sim_restorestate(tcb->xcp.regs);
85+
86+
return;
8387
}
8488

8589
/* Copy the exception context into the TCB of the task that was
8690
* previously active. if sim_saveusercontext returns a non-zero value,
8791
* then this is really the previously running task restarting!
8892
*/
8993

90-
else if (!sim_saveusercontext(rtcb->xcp.regs))
94+
sim_saveusercontext(rtcb->xcp.regs, ret);
95+
if (ret == 0)
9196
{
9297
sinfo("New Active Task TCB=%p\n", tcb);
9398

0 commit comments

Comments
 (0)