From b373894fbc1fed65aaa95a3f613507d17185dea1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 6 Feb 2016 16:49:34 -0600 Subject: [PATCH] MIPS: Replace explict references to g_readytorun with indirect references via the this_task() macro --- arch/mips/src/common/up_exit.c | 4 ++-- arch/mips/src/mips32/up_assert.c | 6 +++--- arch/mips/src/mips32/up_blocktask.c | 10 +++++----- arch/mips/src/mips32/up_dumpstate.c | 2 +- arch/mips/src/mips32/up_releasepending.c | 10 +++++----- arch/mips/src/mips32/up_reprioritizertr.c | 8 ++++---- arch/mips/src/mips32/up_schedulesigaction.c | 6 +++--- arch/mips/src/mips32/up_sigdeliver.c | 2 +- arch/mips/src/mips32/up_unblocktask.c | 12 ++++++------ arch/mips/src/mips32/up_vfork.c | 2 +- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/arch/mips/src/common/up_exit.c b/arch/mips/src/common/up_exit.c index 550dae0ab1..e3e30fa284 100644 --- a/arch/mips/src/common/up_exit.c +++ b/arch/mips/src/common/up_exit.c @@ -148,7 +148,7 @@ void _exit(int status) (void)irqsave(); - slldbg("TCB=%p exiting\n", g_readytorun.head); + slldbg("TCB=%p exiting\n", this_task()); #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG) slldbg("Other tasks:\n"); @@ -163,7 +163,7 @@ void _exit(int status) * head of the list. */ - tcb = (struct tcb_s *)g_readytorun.head; + tcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously running diff --git a/arch/mips/src/mips32/up_assert.c b/arch/mips/src/mips32/up_assert.c index c392bf5386..d473dba94f 100644 --- a/arch/mips/src/mips32/up_assert.c +++ b/arch/mips/src/mips32/up_assert.c @@ -105,7 +105,7 @@ static void _up_assert(int errorcode) { /* Are we in an interrupt handler or the idle task? */ - if (current_regs || ((struct tcb_s *)g_readytorun.head)->pid == 0) + if (current_regs || this_task()->pid == 0) { (void)irqsave(); for (; ; ) @@ -160,7 +160,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) void up_assert(const uint8_t *filename, int lineno) { #ifdef CONFIG_PRINT_TASKNAME - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); #endif board_autoled_on(LED_ASSERTION); @@ -182,7 +182,7 @@ void up_assert(const uint8_t *filename, int lineno) #endif #ifdef CONFIG_BOARD_CRASHDUMP - board_crashdump(up_getsp(), g_readytorun.head, filename, lineno); + board_crashdump(up_getsp(), this_task(), filename, lineno); #endif _up_assert(EXIT_FAILURE); diff --git a/arch/mips/src/mips32/up_blocktask.c b/arch/mips/src/mips32/up_blocktask.c index 1cccff6f97..bbc55ff795 100644 --- a/arch/mips/src/mips32/up_blocktask.c +++ b/arch/mips/src/mips32/up_blocktask.c @@ -77,7 +77,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); bool switch_needed; /* Verify that the context switch can be performed */ @@ -98,7 +98,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) sched_addblocked(tcb, (tstate_t)task_state); - /* If there are any pending tasks, then add them to the g_readytorun + /* If there are any pending tasks, then add them to the ready-to-run * task list now */ @@ -126,10 +126,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) up_savestate(rtcb->xcp.regs); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (struct tcb_s *)g_readytorun.head; + rtcb = this_task(); /* Reset scheduler parameters */ @@ -150,7 +150,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) * run list. */ - struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *nexttcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/mips/src/mips32/up_dumpstate.c b/arch/mips/src/mips32/up_dumpstate.c index eaa45246e2..5a059f8cec 100644 --- a/arch/mips/src/mips32/up_dumpstate.c +++ b/arch/mips/src/mips32/up_dumpstate.c @@ -154,7 +154,7 @@ static inline void up_registerdump(void) void up_dumpstate(void) { - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); uint32_t sp = up_getsp(); uint32_t ustackbase; uint32_t ustacksize; diff --git a/arch/mips/src/mips32/up_releasepending.c b/arch/mips/src/mips32/up_releasepending.c index bea7a2e904..2a18a23a0e 100644 --- a/arch/mips/src/mips32/up_releasepending.c +++ b/arch/mips/src/mips32/up_releasepending.c @@ -67,11 +67,11 @@ void up_release_pending(void) { - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); slldbg("From TCB=%p\n", rtcb); - /* Merge the g_pendingtasks list into the g_readytorun task list */ + /* Merge the g_pendingtasks list into the ready-to-run task list */ /* sched_lock(); */ if (sched_mergepending()) @@ -95,10 +95,10 @@ void up_release_pending(void) up_savestate(rtcb->xcp.regs); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (struct tcb_s *)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -119,7 +119,7 @@ void up_release_pending(void) * ready to run list. */ - struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *nexttcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/mips/src/mips32/up_reprioritizertr.c b/arch/mips/src/mips32/up_reprioritizertr.c index 506241b2f0..0fb1951d64 100644 --- a/arch/mips/src/mips32/up_reprioritizertr.c +++ b/arch/mips/src/mips32/up_reprioritizertr.c @@ -94,7 +94,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) } else { - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); bool switch_needed; slldbg("TCB=%p PRI=%d\n", tcb, priority); @@ -149,10 +149,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) up_savestate(rtcb->xcp.regs); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (struct tcb_s *)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -173,7 +173,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) * ready to run list. */ - struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *nexttcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/mips/src/mips32/up_schedulesigaction.c b/arch/mips/src/mips32/up_schedulesigaction.c index 064a68ac9f..78f2d9ff7d 100644 --- a/arch/mips/src/mips32/up_schedulesigaction.c +++ b/arch/mips/src/mips32/up_schedulesigaction.c @@ -120,9 +120,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * being delivered to the currently executing task. */ - sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs); + sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs); - if (tcb == (struct tcb_s *)g_readytorun.head) + if (tcb == this_task()) { /* CASE 1: We are not in an interrupt handler and * a task is signalling itself for some reason. @@ -144,7 +144,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) * logic would fail in the strange case where we are in an * interrupt handler, the thread is signalling itself, but * a context switch to another task has occurred so that - * current_regs does not refer to the thread at g_readytorun.head! + * current_regs does not refer to the thread of this_task()! */ else diff --git a/arch/mips/src/mips32/up_sigdeliver.c b/arch/mips/src/mips32/up_sigdeliver.c index 060298010c..23cd349208 100644 --- a/arch/mips/src/mips32/up_sigdeliver.c +++ b/arch/mips/src/mips32/up_sigdeliver.c @@ -83,7 +83,7 @@ void up_sigdeliver(void) { - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); uint32_t regs[XCPTCONTEXT_REGS]; sig_deliver_t sigdeliver; diff --git a/arch/mips/src/mips32/up_unblocktask.c b/arch/mips/src/mips32/up_unblocktask.c index 2fb84f4773..1e59218d41 100644 --- a/arch/mips/src/mips32/up_unblocktask.c +++ b/arch/mips/src/mips32/up_unblocktask.c @@ -73,7 +73,7 @@ void up_unblock_task(struct tcb_s *tcb) { - struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *rtcb = this_task(); /* Verify that the context switch can be performed */ @@ -85,7 +85,7 @@ void up_unblock_task(struct tcb_s *tcb) sched_removeblocked(tcb); /* Add the task in the correct location in the prioritized - * g_readytorun task list + * ready-to-run task list */ if (sched_addreadytorun(tcb)) @@ -109,10 +109,10 @@ void up_unblock_task(struct tcb_s *tcb) up_savestate(rtcb->xcp.regs); /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. + * of the ready-to-run task list. */ - rtcb = (struct tcb_s *)g_readytorun.head; + rtcb = this_task(); /* Update scheduler parameters */ @@ -131,10 +131,10 @@ void up_unblock_task(struct tcb_s *tcb) { /* Restore the exception context of the new task that is ready to * run (probably tcb). This is the new rtcb at the head of the - * g_readytorun task list. + * ready-to-run task list. */ - struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; + struct tcb_s *nexttcb = this_task(); #ifdef CONFIG_ARCH_ADDRENV /* Make sure that the address environment for the previously diff --git a/arch/mips/src/mips32/up_vfork.c b/arch/mips/src/mips32/up_vfork.c index f1b5c2a8fe..dda54ae179 100644 --- a/arch/mips/src/mips32/up_vfork.c +++ b/arch/mips/src/mips32/up_vfork.c @@ -113,7 +113,7 @@ pid_t up_vfork(const struct vfork_s *context) { - struct tcb_s *parent = (FAR struct tcb_s *)g_readytorun.head; + struct tcb_s *parent = this_task(); struct task_tcb_s *child; size_t stacksize; uint32_t newsp;