Reduce the size of tcb by four bytes.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
This commit is contained in:
wangzhi16
2024-12-25 19:43:24 +08:00
committed by Xiang Xiao
parent 3b26c6df51
commit 893c5e92c2
70 changed files with 369 additions and 266 deletions

View File

@@ -35,6 +35,7 @@
#include "arm.h" #include "arm.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -90,8 +91,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* Otherwise, we are (1) signaling a task is not running /* Otherwise, we are (1) signaling a task is not running

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -59,9 +60,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
#ifndef CONFIG_SUPPRESS_INTERRUPTS #ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always /* Then make sure that interrupts are enabled. Signal handlers must always
@@ -73,7 +74,7 @@ void arm_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -93,7 +94,9 @@ void arm_sigdeliver(void)
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */ /* Then restore the correct state for this thread of execution. */

View File

@@ -34,6 +34,7 @@
#include <nuttx/board.h> #include <nuttx/board.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include <sched/sched.h> #include <sched/sched.h>
#include <signal/signal.h>
#include "arm_internal.h" #include "arm_internal.h"
#include "exc_return.h" #include "exc_return.h"
@@ -86,7 +87,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs); irq_dispatch(irq, regs);
#endif #endif
if (tcb->sigdeliver) if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{ {
/* Pendsv able to access running tcb with no critical section */ /* Pendsv able to access running tcb with no critical section */

View File

@@ -37,6 +37,7 @@
#include "psr.h" #include "psr.h"
#include "exc_return.h" #include "exc_return.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
#include "irq/irq.h" #include "irq/irq.h"
#include "nvic.h" #include "nvic.h"
@@ -96,8 +97,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section! * REVISIT: Signal handle will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV) else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{ {

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -36,6 +36,7 @@
#include "arm.h" #include "arm.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
#include "irq/irq.h" #include "irq/irq.h"
@@ -94,8 +95,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section! * REVISIT: Signal handler will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else else
{ {

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */ /* Then restore the correct state for this thread of execution. */

View File

@@ -410,7 +410,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */ /* Copy "info" into user stack */
if (rtcb->sigdeliver) if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{ {
usp = rtcb->xcp.saved_regs[REG_SP]; usp = rtcb->xcp.saved_regs[REG_SP];
} }

View File

@@ -34,6 +34,7 @@
#include <nuttx/board.h> #include <nuttx/board.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include <sched/sched.h> #include <sched/sched.h>
#include <signal/signal.h>
#include "arm_internal.h" #include "arm_internal.h"
#include "exc_return.h" #include "exc_return.h"
@@ -86,7 +87,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs); irq_dispatch(irq, regs);
#endif #endif
if (tcb->sigdeliver) if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{ {
/* Pendsv able to access running tcb with no critical section */ /* Pendsv able to access running tcb with no critical section */

View File

@@ -38,6 +38,7 @@
#include "psr.h" #include "psr.h"
#include "exc_return.h" #include "exc_return.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
#include "irq/irq.h" #include "irq/irq.h"
#include "nvic.h" #include "nvic.h"
@@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section! * REVISIT: Signal handle will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV) else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{ {

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -35,6 +35,7 @@
#include "arm.h" #include "arm.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -92,8 +93,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section! * REVISIT: Signal handler will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else else
{ {

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -147,7 +148,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */ /* Then restore the correct state for this thread of execution. */

View File

@@ -407,7 +407,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */ /* Copy "info" into user stack */
if (rtcb->sigdeliver) if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{ {
usp = rtcb->xcp.saved_regs[REG_SP]; usp = rtcb->xcp.saved_regs[REG_SP];
} }

View File

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

View File

@@ -38,6 +38,7 @@
#include "psr.h" #include "psr.h"
#include "exc_return.h" #include "exc_return.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
#include "irq/irq.h" #include "irq/irq.h"
#include "nvic.h" #include "nvic.h"
@@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handle will run in a critical section! * REVISIT: Signal handle will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV) else if (tcb == rtcb && ipsr != NVIC_IRQ_PENDSV)
{ {

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -35,6 +35,7 @@
#include "arm.h" #include "arm.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -92,8 +93,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section! * REVISIT: Signal handler will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else else
{ {

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -69,9 +70,9 @@ void arm_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -147,7 +148,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */ /* Then restore the correct state for this thread of execution. */

View File

@@ -407,7 +407,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */ /* Copy "info" into user stack */
if (rtcb->sigdeliver) if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{ {
usp = rtcb->xcp.saved_regs[REG_SP]; usp = rtcb->xcp.saved_regs[REG_SP];
} }

View File

@@ -35,6 +35,7 @@
#include "tc32.h" #include "tc32.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h" #include "arm_internal.h"
/**************************************************************************** /****************************************************************************
@@ -90,8 +91,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* Otherwise, we are (1) signaling a task is not running /* Otherwise, we are (1) signaling a task is not running

View File

@@ -35,6 +35,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm64_internal.h" #include "arm64_internal.h"
#include "arm64_arch.h" #include "arm64_arch.h"
#include "irq/irq.h" #include "irq/irq.h"
@@ -130,8 +131,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section! * REVISIT: Signal handler will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else else
{ {

View File

@@ -35,6 +35,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "arm64_internal.h" #include "arm64_internal.h"
#include "arm64_arch.h" #include "arm64_arch.h"
#include "irq/irq.h" #include "irq/irq.h"
@@ -69,9 +70,9 @@ void arm64_sigdeliver(void)
flags = (rtcb->xcp.saved_regs[REG_SPSR] & SPSR_DAIF_MASK); flags = (rtcb->xcp.saved_regs[REG_SPSR] & SPSR_DAIF_MASK);
#endif #endif
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -103,7 +104,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -150,7 +151,9 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
rtcb->xcp.regs = rtcb->xcp.saved_regs; rtcb->xcp.regs = rtcb->xcp.saved_regs;
/* Then restore the correct state for this thread of execution. */ /* Then restore the correct state for this thread of execution. */

View File

@@ -35,6 +35,7 @@
#include <avr/io.h> #include <avr/io.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "avr_internal.h" #include "avr_internal.h"
/**************************************************************************** /****************************************************************************
@@ -98,8 +99,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "avr_internal.h" #include "avr_internal.h"
/**************************************************************************** /****************************************************************************
@@ -60,9 +61,9 @@ void avr_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -78,7 +79,7 @@ void avr_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -98,13 +99,16 @@ void avr_sigdeliver(void)
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
regs[REG_PC0] = rtcb->xcp.saved_pc0; regs[REG_PC0] = rtcb->xcp.saved_pc0;
regs[REG_PC1] = rtcb->xcp.saved_pc1; regs[REG_PC1] = rtcb->xcp.saved_pc1;
#if defined(REG_PC2) #if defined(REG_PC2)
regs[REG_PC2] = rtcb->xcp.saved_pc2; regs[REG_PC2] = rtcb->xcp.saved_pc2;
#endif #endif
regs[REG_SREG] = rtcb->xcp.saved_sreg; regs[REG_SREG] = rtcb->xcp.saved_sreg;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. This is an /* Then restore the correct state for this thread of execution. This is an
* unusual case that must be handled by up_fullcontextresore. This case is * unusual case that must be handled by up_fullcontextresore. This case is

View File

@@ -89,7 +89,7 @@ void up_initial_state(struct tcb_s *tcb)
#else #else
/* No pending signal delivery */ /* No pending signal delivery */
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Clear the frame pointer and link register since this is the outermost /* Clear the frame pointer and link register since this is the outermost
* frame. * frame.

View File

@@ -35,6 +35,7 @@
#include <arch/avr32/avr32.h> #include <arch/avr32/avr32.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "avr_internal.h" #include "avr_internal.h"
/**************************************************************************** /****************************************************************************
@@ -96,8 +97,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "avr_internal.h" #include "avr_internal.h"
/**************************************************************************** /****************************************************************************
@@ -64,9 +65,9 @@ void avr_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -82,7 +83,7 @@ void avr_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -102,9 +103,12 @@ void avr_sigdeliver(void)
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
regs[REG_PC] = rtcb->xcp.saved_pc; regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_SR] = rtcb->xcp.saved_sr; regs[REG_SR] = rtcb->xcp.saved_sr;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. This is an /* Then restore the correct state for this thread of execution. This is an
* unusual case that must be handled by up_fullcontextresore. This case is * unusual case that must be handled by up_fullcontextresore. This case is

View File

@@ -33,6 +33,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "ceva_internal.h" #include "ceva_internal.h"
#ifndef CONFIG_DISABLE_SIGNALS #ifndef CONFIG_DISABLE_SIGNALS
@@ -100,8 +101,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.

View File

@@ -54,7 +54,6 @@ void ceva_sigdeliver(void)
{ {
struct tcb_s *rtcb = this_task(); struct tcb_s *rtcb = this_task();
uint32_t *regs = rtcb->xcp.saved_regs; uint32_t *regs = rtcb->xcp.saved_regs;
sig_deliver_t sigdeliver;
/* Save the errno. This must be preserved throughout the signal handling /* Save the errno. This must be preserved throughout the signal handling
* so that the user code final gets the correct errno value (probably * so that the user code final gets the correct errno value (probably
@@ -63,21 +62,20 @@ void ceva_sigdeliver(void)
int saved_errno = rtcb->pterrno; int saved_errno = rtcb->pterrno;
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Get a local copy of the sigdeliver function pointer. We do this so that /* We do this so that we can nullify the TCB_FLAG_SIGDELIVER in the TCB
* we can nullify the sigdeliver function pointer in the TCB and accept * and accept more signal deliveries while processing the current pending
* more signal deliveries while processing the current pending signals. * signals.
*/ */
sigdeliver = rtcb->sigdeliver; rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
rtcb->sigdeliver = NULL;
/* Deliver the signal */ /* Deliver the signal */
sigdeliver(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original

View File

@@ -36,6 +36,7 @@
#include <arch/mips32/cp0.h> #include <arch/mips32/cp0.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "mips_internal.h" #include "mips_internal.h"
/**************************************************************************** /****************************************************************************
@@ -99,8 +100,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -39,6 +39,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "mips_internal.h" #include "mips_internal.h"
/**************************************************************************** /****************************************************************************
@@ -62,9 +63,9 @@ void mips_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -80,7 +81,7 @@ void mips_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -104,7 +105,10 @@ void mips_sigdeliver(void)
regs[REG_EPC] = rtcb->xcp.saved_epc; regs[REG_EPC] = rtcb->xcp.saved_epc;
regs[REG_STATUS] = rtcb->xcp.saved_status; regs[REG_STATUS] = rtcb->xcp.saved_status;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -35,6 +35,7 @@
#include <arch/lm32/irq.h> #include <arch/lm32/irq.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "lm32.h" #include "lm32.h"
/**************************************************************************** /****************************************************************************
@@ -96,8 +97,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -38,6 +38,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "lm32.h" #include "lm32.h"
/**************************************************************************** /****************************************************************************
@@ -61,9 +62,9 @@ void lm32_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -79,7 +80,7 @@ void lm32_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -103,7 +104,10 @@ void lm32_sigdeliver(void)
regs[REG_EPC] = rtcb->xcp.saved_epc; regs[REG_EPC] = rtcb->xcp.saved_epc;
regs[REG_INT_CTX] = rtcb->xcp.saved_int_ctx; regs[REG_INT_CTX] = rtcb->xcp.saved_int_ctx;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -36,6 +36,7 @@
#include <arch/minerva/csrdefs.h> #include <arch/minerva/csrdefs.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "minerva.h" #include "minerva.h"
/**************************************************************************** /****************************************************************************
@@ -97,8 +98,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task

View File

@@ -59,13 +59,12 @@ void minerva_sigdeliver(void)
{ {
struct tcb_s *rtcb = this_task(); struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS]; uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the real return state on the stack. */ /* Save the real return state on the stack. */
@@ -73,13 +72,12 @@ void minerva_sigdeliver(void)
regs[REG_CSR_MEPC] = rtcb->xcp.saved_epc; regs[REG_CSR_MEPC] = rtcb->xcp.saved_epc;
regs[REG_CSR_MSTATUS] = rtcb->xcp.saved_int_ctx; regs[REG_CSR_MSTATUS] = rtcb->xcp.saved_int_ctx;
/* Get a local copy of the sigdeliver function pointer. We do this so that /* We do this so that we can nullify the TCB_FLAG_SIGDELIVER in the TCB
* we can nullify the sigdeliver function pointer in the TCB and accept * and accept more signal deliveries while processing the current pending
* more signal deliveries while processing the current pending signals. * signals.
*/ */
sigdeliver = rtcb->sigdeliver; rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
rtcb->sigdeliver = NULL;
# ifndef CONFIG_SUPPRESS_INTERRUPTS # ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always /* Then make sure that interrupts are enabled. Signal handlers must always
@@ -91,7 +89,7 @@ void minerva_sigdeliver(void)
/* Deliver the signals */ /* Deliver the signals */
sigdeliver(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original

View File

@@ -34,6 +34,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "or1k_internal.h" #include "or1k_internal.h"
/**************************************************************************** /****************************************************************************
@@ -95,8 +96,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -34,6 +34,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h" #include "renesas_internal.h"
/**************************************************************************** /****************************************************************************
@@ -95,8 +96,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -36,6 +36,7 @@
#include <nuttx/board.h> #include <nuttx/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h" #include "renesas_internal.h"
/**************************************************************************** /****************************************************************************
@@ -59,9 +60,9 @@ void renesas_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -77,7 +78,7 @@ void renesas_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(sig_rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -100,7 +101,10 @@ void renesas_sigdeliver(void)
regs[REG_PC] = rtcb->xcp.saved_pc[0]; regs[REG_PC] = rtcb->xcp.saved_pc[0];
regs[REG_PC + 1] = rtcb->xcp.saved_pc[1]; regs[REG_PC + 1] = rtcb->xcp.saved_pc[1];
regs[REG_FLG] = rtcb->xcp.saved_flg; regs[REG_FLG] = rtcb->xcp.saved_flg;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -34,6 +34,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h" #include "renesas_internal.h"
/**************************************************************************** /****************************************************************************
@@ -95,8 +96,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -37,6 +37,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h" #include "renesas_internal.h"
/**************************************************************************** /****************************************************************************
@@ -57,13 +58,12 @@ void renesas_sigdeliver(void)
{ {
struct tcb_s *rtcb = this_task(); struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS]; uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the real return state on the stack. */ /* Save the real return state on the stack. */
@@ -77,8 +77,7 @@ void renesas_sigdeliver(void)
* signals. * signals.
*/ */
sigdeliver = rtcb->sigdeliver; rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
rtcb->sigdeliver = NULL;
#ifndef CONFIG_SUPPRESS_INTERRUPTS #ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always /* Then make sure that interrupts are enabled. Signal handlers must always
@@ -90,7 +89,7 @@ void renesas_sigdeliver(void)
/* Deliver the signals */ /* Deliver the signals */
sigdeliver(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original

View File

@@ -34,6 +34,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h" #include "renesas_internal.h"
/**************************************************************************** /****************************************************************************
@@ -95,8 +96,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

View File

@@ -36,6 +36,7 @@
#include <nuttx/board.h> #include <nuttx/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h" #include "renesas_internal.h"
/**************************************************************************** /****************************************************************************
@@ -59,9 +60,9 @@ void renesas_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -77,7 +78,7 @@ void renesas_sigdeliver(void)
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -97,9 +98,12 @@ void renesas_sigdeliver(void)
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
regs[REG_PC] = rtcb->xcp.saved_pc; regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_SR] = rtcb->xcp.saved_sr; regs[REG_SR] = rtcb->xcp.saved_sr;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */ /* Then restore the correct state for this thread of execution. */

View File

@@ -36,6 +36,7 @@
#include <nuttx/spinlock.h> #include <nuttx/spinlock.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "riscv_internal.h" #include "riscv_internal.h"
/**************************************************************************** /****************************************************************************
@@ -95,8 +96,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section! * REVISIT: Signal handler will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
else else
{ {

View File

@@ -39,6 +39,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "riscv_internal.h" #include "riscv_internal.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -70,9 +71,9 @@ void riscv_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
retry: retry:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
@@ -104,7 +105,7 @@ retry:
/* Deliver the signals */ /* Deliver the signals */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -149,7 +150,7 @@ retry:
* could be modified by a hostile program. * could be modified by a hostile program.
*/ */
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of /* Then restore the correct state for this thread of
* execution. * execution.

View File

@@ -32,6 +32,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -81,7 +82,7 @@ void up_schedule_sigaction(struct tcb_s *tcb)
if (tcb == this_task()) if (tcb == this_task())
{ {
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
} }

View File

@@ -35,6 +35,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "sim_internal.h" #include "sim_internal.h"
/**************************************************************************** /****************************************************************************
@@ -63,7 +64,7 @@ void sim_sigdeliver(void)
int16_t saved_irqcount; int16_t saved_irqcount;
irqstate_t flags; irqstate_t flags;
#endif #endif
if (NULL == (rtcb->sigdeliver)) if ((rtcb->flags & TCB_FLAG_SIGDELIVER) == 0)
{ {
return; return;
} }
@@ -76,9 +77,9 @@ void sim_sigdeliver(void)
flags = enter_critical_section(); flags = enter_critical_section();
#endif #endif
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* NOTE: we do not save the return state for sim */ /* NOTE: we do not save the return state for sim */
@@ -105,7 +106,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -137,7 +138,7 @@ retry:
/* Allows next handler to be scheduled */ /* Allows next handler to be scheduled */
rtcb->sigdeliver = NULL; rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* NOTE: we leave a critical section here for sim */ /* NOTE: we leave a critical section here for sim */

View File

@@ -34,6 +34,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "sparc_internal.h" #include "sparc_internal.h"
/**************************************************************************** /****************************************************************************
@@ -93,8 +94,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -192,8 +193,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
* REVISIT: Signal handler will run in a critical section! * REVISIT: Signal handler will run in a critical section!
*/ */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.

View File

@@ -38,6 +38,7 @@
#include <arch/board/board.h> #include <arch/board/board.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "sparc_internal.h" #include "sparc_internal.h"
/**************************************************************************** /****************************************************************************
@@ -78,9 +79,9 @@ void sparc_sigdeliver(void)
board_autoled_on(LED_SIGNAL); board_autoled_on(LED_SIGNAL);
sinfo("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n", sinfo("rtcb=%p sigpendactionq.head=%p\n",
rtcb, rtcb->sigdeliver, rtcb->sigpendactionq.head); rtcb, rtcb->sigpendactionq.head);
DEBUGASSERT(rtcb->sigdeliver != NULL); DEBUGASSERT((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0);
/* Save the return state on the stack. */ /* Save the return state on the stack. */
@@ -116,7 +117,7 @@ retry:
/* Deliver the signal */ /* Deliver the signal */
(rtcb->sigdeliver)(rtcb); nxsig_deliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may /* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original * alter errno), then disable interrupts again and restore the original
@@ -168,7 +169,7 @@ retry:
regs[REG_PC] = rtcb->xcp.saved_pc; regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_NPC] = rtcb->xcp.saved_npc; regs[REG_NPC] = rtcb->xcp.saved_npc;
regs[REG_PSR] = rtcb->xcp.saved_status; regs[REG_PSR] = rtcb->xcp.saved_status;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */ rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* Restore the saved 'irqcount' and recover the critical section /* Restore the saved 'irqcount' and recover the critical section

View File

@@ -36,6 +36,7 @@
#include <nuttx/spinlock.h> #include <nuttx/spinlock.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "signal/signal.h"
#include "tricore_internal.h" #include "tricore_internal.h"
/**************************************************************************** /****************************************************************************
@@ -94,8 +95,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
{ {
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
(tcb->sigdeliver)(tcb); nxsig_deliver(tcb);
tcb->sigdeliver = NULL; tcb->flags &= ~TCB_FLAG_SIGDELIVER;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the

Some files were not shown because too many files have changed in this diff Show More