Skip to content

Commit

Permalink
Reduce the size of tcb by four bytes.
Browse files Browse the repository at this point in the history
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
  • Loading branch information
wangzhi-art committed Dec 30, 2024
1 parent 12ddf5d commit decf6c3
Show file tree
Hide file tree
Showing 68 changed files with 292 additions and 227 deletions.
5 changes: 3 additions & 2 deletions arch/arm/src/arm/arm_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -90,8 +91,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{
/* In this case just deliver the signal now. */

(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}

/* Otherwise, we are (1) signaling a task is not running
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/src/arm/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <arch/board/board.h>

#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand All @@ -59,9 +60,9 @@ void arm_sigdeliver(void)

board_autoled_on(LED_SIGNAL);

sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);

#ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always
Expand All @@ -73,7 +74,7 @@ void arm_sigdeliver(void)

/* Deliver the signal */

(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);

/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
Expand All @@ -93,7 +94,7 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/

rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER; /* Allows next handler to be scheduled */

/* Then restore the correct state for this thread of execution. */

Expand Down
5 changes: 3 additions & 2 deletions arch/arm/src/armv6-m/arm_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "psr.h"
#include "exc_return.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
#include "nvic.h"
Expand Down Expand Up @@ -96,8 +97,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section!
*/

(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/src/armv6-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <arch/board/board.h>

#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -69,9 +70,9 @@ void arm_sigdeliver(void)

board_autoled_on(LED_SIGNAL);

sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);

retry:
#ifdef CONFIG_SMP
Expand Down Expand Up @@ -103,7 +104,7 @@ void arm_sigdeliver(void)

/* Deliver the signal */

(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);

/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
Expand Down Expand Up @@ -150,7 +151,7 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/

rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER; /* Allows next handler to be scheduled */

/* Then restore the correct state for this thread of
* execution.
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/src/armv7-a/arm_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"

Expand Down Expand Up @@ -94,8 +95,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section!
*/

(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/src/armv7-a/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <arch/board/board.h>

#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -69,9 +70,9 @@ void arm_sigdeliver(void)

board_autoled_on(LED_SIGNAL);

sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);

retry:
#ifdef CONFIG_SMP
Expand Down Expand Up @@ -103,7 +104,7 @@ void arm_sigdeliver(void)

/* Deliver the signal */

(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);

/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
Expand Down Expand Up @@ -150,7 +151,7 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/

rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER; /* Allows next handler to be scheduled */

/* Then restore the correct state for this thread of execution. */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-a/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ uint32_t *arm_syscall(uint32_t *regs)

/* Copy "info" into user stack */

if (rtcb->sigdeliver)
if (nxsig_deliver)
{
usp = rtcb->xcp.saved_regs[REG_SP];
}
Expand Down
3 changes: 2 additions & 1 deletion arch/arm/src/armv7-m/arm_doirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <sched/sched.h>
#include <signal/signal.h>

#include "arm_internal.h"
#include "exc_return.h"
Expand Down Expand Up @@ -86,7 +87,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)

irq_dispatch(irq, regs);
#endif
if (tcb->sigdeliver)
if (tcb->flags & TCB_FLAG_SIGDELIVER != 0)
{
/* Pendsv able to access running tcb with no critical section */

Expand Down
5 changes: 3 additions & 2 deletions arch/arm/src/armv7-m/arm_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "psr.h"
#include "exc_return.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
#include "nvic.h"
Expand Down Expand Up @@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section!
*/

(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/src/armv7-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <arch/board/board.h>

#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -69,9 +70,9 @@ void arm_sigdeliver(void)

board_autoled_on(LED_SIGNAL);

sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);

retry:
#ifdef CONFIG_SMP
Expand Down Expand Up @@ -103,7 +104,7 @@ void arm_sigdeliver(void)

/* Deliver the signal */

(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);

/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
Expand Down Expand Up @@ -150,7 +151,7 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/

rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER; /* Allows next handler to be scheduled */

/* Then restore the correct state for this thread of
* execution.
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/src/armv7-r/arm_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -92,8 +93,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section!
*/

(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/src/armv7-r/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <arch/board/board.h>

#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -69,9 +70,9 @@ void arm_sigdeliver(void)

board_autoled_on(LED_SIGNAL);

sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);

retry:
#ifdef CONFIG_SMP
Expand Down Expand Up @@ -103,7 +104,7 @@ void arm_sigdeliver(void)

/* Deliver the signal */

(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);

/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
Expand Down Expand Up @@ -147,7 +148,7 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/

rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER; /* Allows next handler to be scheduled */

/* Then restore the correct state for this thread of execution. */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-r/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ uint32_t *arm_syscall(uint32_t *regs)

/* Copy "info" into user stack */

if (rtcb->sigdeliver)
if (nxsig_deliver)
{
usp = rtcb->xcp.saved_regs[REG_SP];
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv8-m/arm_doirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)

irq_dispatch(irq, regs);
#endif
if (tcb->sigdeliver)
if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
/* Pendsv able to access running tcb with no critical section */

Expand Down
5 changes: 3 additions & 2 deletions arch/arm/src/armv8-m/arm_schedulesigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "psr.h"
#include "exc_return.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
#include "irq/irq.h"
#include "nvic.h"
Expand Down Expand Up @@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section!
*/

(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{
Expand Down
11 changes: 6 additions & 5 deletions arch/arm/src/armv8-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <arch/board/board.h>

#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"

/****************************************************************************
Expand Down Expand Up @@ -69,9 +70,9 @@ void arm_sigdeliver(void)

board_autoled_on(LED_SIGNAL);

sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL);
sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);

retry:
#ifdef CONFIG_SMP
Expand Down Expand Up @@ -103,7 +104,7 @@ void arm_sigdeliver(void)

/* Deliver the signal */

(rtcb->sigdeliver)(rtcb);
nxsig_deliver(rtcb);

/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
Expand Down Expand Up @@ -150,7 +151,7 @@ void arm_sigdeliver(void)
* could be modified by a hostile program.
*/

rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER; /* Allows next handler to be scheduled */

/* Then restore the correct state for this thread of
* execution.
Expand Down
Loading

0 comments on commit decf6c3

Please sign in to comment.