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 "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* Otherwise, we are (1) signaling a task is not running

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -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
@ -93,7 +94,9 @@ void arm_sigdeliver(void)
* 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. */

View file

@ -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"
@ -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 */

View file

@ -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"
@ -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)
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -103,7 +104,7 @@ retry:
/* 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
@ -150,7 +151,9 @@ retry:
* 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.

View file

@ -36,6 +36,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.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!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -103,7 +104,7 @@ retry:
/* 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
@ -150,7 +151,9 @@ retry:
* 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. */

View file

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

View file

@ -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"
@ -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 */

View file

@ -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"
@ -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)
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -103,7 +104,7 @@ retry:
/* 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
@ -150,7 +151,9 @@ retry:
* 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.

View file

@ -35,6 +35,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.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!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -103,7 +104,7 @@ retry:
/* 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
@ -147,7 +148,9 @@ retry:
* 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. */

View file

@ -407,7 +407,7 @@ uint32_t *arm_syscall(uint32_t *regs)
/* Copy "info" into user stack */
if (rtcb->sigdeliver)
if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
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);
#endif
if (tcb->sigdeliver)
if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
/* Pendsv able to access running tcb with no critical section */

View file

@ -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"
@ -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)
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -103,7 +104,7 @@ retry:
/* 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
@ -150,7 +151,9 @@ retry:
* 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.

View file

@ -35,6 +35,7 @@
#include "arm.h"
#include "sched/sched.h"
#include "signal/signal.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!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm_internal.h"
/****************************************************************************
@ -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
@ -103,7 +104,7 @@ retry:
/* 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
@ -147,7 +148,9 @@ retry:
* 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. */

View file

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

View file

@ -35,6 +35,7 @@
#include "tc32.h"
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* Otherwise, we are (1) signaling a task is not running

View file

@ -35,6 +35,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm64_internal.h"
#include "arm64_arch.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!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -35,6 +35,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "arm64_internal.h"
#include "arm64_arch.h"
#include "irq/irq.h"
@ -69,9 +70,9 @@ void arm64_sigdeliver(void)
flags = (rtcb->xcp.saved_regs[REG_SPSR] & SPSR_DAIF_MASK);
#endif
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
@ -103,7 +104,7 @@ retry:
/* 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
@ -150,7 +151,9 @@ retry:
* 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;
/* Then restore the correct state for this thread of execution. */

View file

@ -35,6 +35,7 @@
#include <avr/io.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "avr_internal.h"
/****************************************************************************
@ -60,9 +61,9 @@ void avr_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);
/* Save the return state on the stack. */
@ -78,7 +79,7 @@ void avr_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
@ -98,13 +99,16 @@ void avr_sigdeliver(void)
* could be modified by a hostile program.
*/
regs[REG_PC0] = rtcb->xcp.saved_pc0;
regs[REG_PC1] = rtcb->xcp.saved_pc1;
regs[REG_PC0] = rtcb->xcp.saved_pc0;
regs[REG_PC1] = rtcb->xcp.saved_pc1;
#if defined(REG_PC2)
regs[REG_PC2] = rtcb->xcp.saved_pc2;
regs[REG_PC2] = rtcb->xcp.saved_pc2;
#endif
regs[REG_SREG] = rtcb->xcp.saved_sreg;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
regs[REG_SREG] = rtcb->xcp.saved_sreg;
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* 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

View file

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

View file

@ -35,6 +35,7 @@
#include <arch/avr32/avr32.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "avr_internal.h"
/****************************************************************************
@ -64,9 +65,9 @@ void avr_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);
/* Save the return state on the stack. */
@ -82,7 +83,7 @@ void avr_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
@ -102,9 +103,12 @@ void avr_sigdeliver(void)
* could be modified by a hostile program.
*/
regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_SR] = rtcb->xcp.saved_sr;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_SR] = rtcb->xcp.saved_sr;
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* 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

View file

@ -33,6 +33,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "ceva_internal.h"
#ifndef CONFIG_DISABLE_SIGNALS
@ -100,8 +101,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;
}
/* 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();
uint32_t *regs = rtcb->xcp.saved_regs;
sig_deliver_t sigdeliver;
/* Save the errno. This must be preserved throughout the signal handling
* 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;
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);
/* Get a local copy of the sigdeliver function pointer. We do this so that
* we can nullify the sigdeliver function pointer in the TCB and accept
* more signal deliveries while processing the current pending signals.
/* We do this so that we can nullify the TCB_FLAG_SIGDELIVER in the TCB
* and accept more signal deliveries while processing the current pending
* signals.
*/
sigdeliver = rtcb->sigdeliver;
rtcb->sigdeliver = NULL;
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Deliver the signal */
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

View file

@ -36,6 +36,7 @@
#include <arch/mips32/cp0.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -39,6 +39,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "mips_internal.h"
/****************************************************************************
@ -62,9 +63,9 @@ void mips_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);
/* Save the return state on the stack. */
@ -80,7 +81,7 @@ void mips_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
@ -104,7 +105,10 @@ void mips_sigdeliver(void)
regs[REG_EPC] = rtcb->xcp.saved_epc;
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
* execution.

View file

@ -35,6 +35,7 @@
#include <arch/lm32/irq.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "lm32.h"
/****************************************************************************
@ -96,8 +97,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;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -38,6 +38,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "lm32.h"
/****************************************************************************
@ -61,9 +62,9 @@ void lm32_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);
/* Save the return state on the stack. */
@ -79,7 +80,7 @@ void lm32_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
@ -103,7 +104,10 @@ void lm32_sigdeliver(void)
regs[REG_EPC] = rtcb->xcp.saved_epc;
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
* execution.

View file

@ -36,6 +36,7 @@
#include <arch/minerva/csrdefs.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "minerva.h"
/****************************************************************************
@ -97,8 +98,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;
}
/* 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();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;
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);
/* 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_MSTATUS] = rtcb->xcp.saved_int_ctx;
/* Get a local copy of the sigdeliver function pointer. We do this so that
* we can nullify the sigdeliver function pointer in the TCB and accept
* more signal deliveries while processing the current pending signals.
/* We do this so that we can nullify the TCB_FLAG_SIGDELIVER in the TCB
* and accept more signal deliveries while processing the current pending
* signals.
*/
sigdeliver = rtcb->sigdeliver;
rtcb->sigdeliver = NULL;
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
# ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always
@ -91,7 +89,7 @@ void minerva_sigdeliver(void)
/* Deliver the signals */
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

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -36,6 +36,7 @@
#include <nuttx/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h"
/****************************************************************************
@ -59,9 +60,9 @@ void renesas_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);
/* Save the return state on the stack. */
@ -77,7 +78,7 @@ void renesas_sigdeliver(void)
/* Deliver the signal */
(sig_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
@ -100,7 +101,10 @@ void renesas_sigdeliver(void)
regs[REG_PC] = rtcb->xcp.saved_pc[0];
regs[REG_PC + 1] = rtcb->xcp.saved_pc[1];
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
* execution.

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h"
/****************************************************************************
@ -57,13 +58,12 @@ void renesas_sigdeliver(void)
{
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;
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);
/* Save the real return state on the stack. */
@ -77,8 +77,7 @@ void renesas_sigdeliver(void)
* signals.
*/
sigdeliver = rtcb->sigdeliver;
rtcb->sigdeliver = NULL;
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
#ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Then make sure that interrupts are enabled. Signal handlers must always
@ -90,7 +89,7 @@ void renesas_sigdeliver(void)
/* Deliver the signals */
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

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -36,6 +36,7 @@
#include <nuttx/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "renesas_internal.h"
/****************************************************************************
@ -59,9 +60,9 @@ void renesas_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);
/* Save the return state on the stack. */
@ -77,7 +78,7 @@ void renesas_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
@ -97,9 +98,12 @@ void renesas_sigdeliver(void)
* could be modified by a hostile program.
*/
regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_SR] = rtcb->xcp.saved_sr;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_SR] = rtcb->xcp.saved_sr;
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -36,6 +36,7 @@
#include <nuttx/spinlock.h>
#include "sched/sched.h"
#include "signal/signal.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!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
else
{

View file

@ -39,6 +39,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "riscv_internal.h"
/****************************************************************************
* Public Functions
@ -70,9 +71,9 @@ void riscv_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
@ -104,7 +105,7 @@ retry:
/* Deliver the signals */
(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
@ -149,7 +150,7 @@ retry:
* 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
* execution.

View file

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

View file

@ -35,6 +35,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "sim_internal.h"
/****************************************************************************
@ -63,7 +64,7 @@ void sim_sigdeliver(void)
int16_t saved_irqcount;
irqstate_t flags;
#endif
if (NULL == (rtcb->sigdeliver))
if ((rtcb->flags & TCB_FLAG_SIGDELIVER) == 0)
{
return;
}
@ -76,9 +77,9 @@ void sim_sigdeliver(void)
flags = enter_critical_section();
#endif
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);
/* NOTE: we do not save the return state for sim */
@ -105,7 +106,7 @@ retry:
/* 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
@ -137,7 +138,7 @@ retry:
/* Allows next handler to be scheduled */
rtcb->sigdeliver = NULL;
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* NOTE: we leave a critical section here for sim */

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* 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!
*/
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: The task that needs to receive the signal is running.

View file

@ -38,6 +38,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "sparc_internal.h"
/****************************************************************************
@ -78,9 +79,9 @@ void sparc_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);
/* Save the return state on the stack. */
@ -116,7 +117,7 @@ retry:
/* 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
@ -168,7 +169,7 @@ retry:
regs[REG_PC] = rtcb->xcp.saved_pc;
regs[REG_NPC] = rtcb->xcp.saved_npc;
regs[REG_PSR] = rtcb->xcp.saved_status;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
#ifdef CONFIG_SMP
/* Restore the saved 'irqcount' and recover the critical section

View file

@ -36,6 +36,7 @@
#include <nuttx/spinlock.h>
#include "sched/sched.h"
#include "signal/signal.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. */
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* CASE 2: We are in an interrupt handler AND the

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "tricore_internal.h"
/****************************************************************************
@ -60,9 +61,9 @@ void tricore_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:
@ -76,7 +77,7 @@ retry:
/* 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
@ -108,7 +109,7 @@ retry:
* 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
* execution.

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "x86_internal.h"
/****************************************************************************
@ -91,8 +92,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;
}
/* CASE 2: We are in an interrupt handler AND the interrupted task

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "x86_internal.h"
/****************************************************************************
@ -60,9 +61,9 @@ void x86_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);
/* Save the return state on the stack. */
@ -78,7 +79,7 @@ void x86_sigdeliver(void)
/* Deliver the signals */
(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
@ -100,7 +101,10 @@ void x86_sigdeliver(void)
regs[REG_EIP] = rtcb->xcp.saved_eip;
regs[REG_EFLAGS] = rtcb->xcp.saved_eflags;
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. */

View file

@ -34,6 +34,7 @@
#include <nuttx/arch.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "x86_64_internal.h"
/****************************************************************************
@ -83,8 +84,8 @@ void up_schedule_sigaction(struct tcb_s *tcb)
if (tcb == this_task() && !up_interrupt_context())
{
(tcb->sigdeliver)(tcb);
tcb->sigdeliver = NULL;
nxsig_deliver(tcb);
tcb->flags &= ~TCB_FLAG_SIGDELIVER;
}
/* Otherwise, we are (1) signaling a task is not running from an

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "x86_64_internal.h"
/****************************************************************************
@ -70,9 +71,9 @@ void x86_64_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);
/* Align regs to 64 byte boundary for XSAVE */
@ -115,7 +116,7 @@ void x86_64_sigdeliver(void)
/* Deliver the signals */
(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
@ -143,7 +144,10 @@ void x86_64_sigdeliver(void)
regs[REG_RIP] = rtcb->xcp.saved_rip;
regs[REG_RSP] = rtcb->xcp.saved_rsp;
regs[REG_RFLAGS] = rtcb->xcp.saved_rflags;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
#ifdef CONFIG_SMP
/* Restore the saved 'irqcount' and recover the critical section

View file

@ -36,6 +36,7 @@
#include "irq/irq.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "chip.h"
#include "xtensa.h"
@ -95,8 +96,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
{

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "xtensa.h"
/****************************************************************************
@ -69,9 +70,9 @@ void xtensa_sig_deliver(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
@ -104,7 +105,7 @@ retry:
/* Deliver the signals */
(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
@ -148,7 +149,9 @@ retry:
* 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.
*/

View file

@ -34,6 +34,7 @@
#include <nuttx/irq.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "z16_internal.h"
/****************************************************************************
@ -95,8 +96,8 @@ void up_schedule_sigaction(FAR 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;
}
/* CASE 2: We are in an interrupt handler AND the interrupted

View file

@ -37,6 +37,7 @@
#include <arch/board/board.h>
#include "sched/sched.h"
#include "signal/signal.h"
#include "z16_internal.h"
/****************************************************************************
@ -61,9 +62,9 @@ void z16_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);
/* Save the return state on the stack. */
@ -79,7 +80,7 @@ void z16_sigdeliver(void)
/* Deliver the signals */
(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
@ -101,7 +102,7 @@ void z16_sigdeliver(void)
regs32[REG_PC / 2] = rtcb->xcp.saved_pc;
regs[REG_FLAGS] = rtcb->xcp.saved_i;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -35,6 +35,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -119,8 +120,8 @@ void up_schedule_sigaction(FAR 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;
}
/* CASE 2: We are in an interrupt handler AND the interrupted task

View file

@ -39,6 +39,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -62,9 +63,9 @@ void z80_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);
/* Save the return state on the stack. */
@ -80,7 +81,7 @@ void z80_sigdeliver(void)
/* Deliver the signals */
(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
@ -100,9 +101,12 @@ void z80_sigdeliver(void)
* could be modified by a hostile program.
*/
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_I] = rtcb->xcp.saved_i;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_I] = rtcb->xcp.saved_i;
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Modify the saved return state with the actual saved values in the
* TCB. This depends on the fact that nested signal handling is

View file

@ -38,6 +38,7 @@
#include "switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -122,8 +123,8 @@ void up_schedule_sigaction(FAR 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;
}
/* CASE 2: We are in an interrupt handler AND the interrupted task

View file

@ -36,6 +36,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -59,9 +60,9 @@ void z80_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);
/* Save the return state on the stack. */
@ -77,7 +78,7 @@ void z80_sigdeliver(void)
/* Deliver the signals */
(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
@ -97,9 +98,12 @@ void z80_sigdeliver(void)
* could be modified by a hostile program.
*/
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_I] = rtcb->xcp.saved_i;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_I] = rtcb->xcp.saved_i;
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -35,6 +35,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -119,8 +120,8 @@ void up_schedule_sigaction(FAR 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;
}
/* CASE 2: We are in an interrupt handler AND the interrupted task

View file

@ -36,6 +36,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -78,9 +79,9 @@ void z80_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);
/* Save the return state on the stack. */
@ -96,7 +97,7 @@ void z80_sigdeliver(void)
/* Deliver the signals */
(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
@ -118,7 +119,10 @@ void z80_sigdeliver(void)
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_IRQCTL] = rtcb->xcp.saved_irqctl;
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. */

View file

@ -36,6 +36,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -120,8 +121,8 @@ void up_schedule_sigaction(FAR 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;
}
/* CASE 2: We are in an interrupt handler AND the interrupted task

View file

@ -36,6 +36,7 @@
#include "chip/switch.h"
#include "sched/sched.h"
#include "signal/signal.h"
#include "z80_internal.h"
/****************************************************************************
@ -59,9 +60,9 @@ void z80_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);
/* Save the return state on the stack. */
@ -77,7 +78,7 @@ void z80_sigdeliver(void)
/* Deliver the signals */
(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
@ -97,9 +98,12 @@ void z80_sigdeliver(void)
* could be modified by a hostile program.
*/
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_I] = rtcb->xcp.saved_i;
rtcb->sigdeliver = NULL; /* Allows next handler to be scheduled */
regs[XCPT_PC] = rtcb->xcp.saved_pc;
regs[XCPT_I] = rtcb->xcp.saved_i;
/* Allows next handler to be scheduled */
rtcb->flags &= ~TCB_FLAG_SIGDELIVER;
/* Then restore the correct state for this thread of execution. */

View file

@ -68,7 +68,7 @@ static bool syslog_safe_to_block(void)
/* It's not safe to block if a signal is being delivered */
rtcb = nxsched_self();
if (rtcb->sigdeliver != NULL)
if ((rtcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
return false;
}

View file

@ -118,22 +118,23 @@
# define TCB_FLAG_TTYPE_TASK (0 << TCB_FLAG_TTYPE_SHIFT) /* Normal user task */
# define TCB_FLAG_TTYPE_PTHREAD (1 << TCB_FLAG_TTYPE_SHIFT) /* User pthread */
# define TCB_FLAG_TTYPE_KERNEL (2 << TCB_FLAG_TTYPE_SHIFT) /* Kernel thread */
#define TCB_FLAG_POLICY_SHIFT (3) /* Bit 3-4: Scheduling policy */
#define TCB_FLAG_POLICY_SHIFT (2) /* Bit 2-3: Scheduling policy */
#define TCB_FLAG_POLICY_MASK (3 << TCB_FLAG_POLICY_SHIFT)
# define TCB_FLAG_SCHED_FIFO (0 << TCB_FLAG_POLICY_SHIFT) /* FIFO scheding policy */
# define TCB_FLAG_SCHED_RR (1 << TCB_FLAG_POLICY_SHIFT) /* Round robin scheding policy */
# define TCB_FLAG_SCHED_SPORADIC (2 << TCB_FLAG_POLICY_SHIFT) /* Sporadic scheding policy */
#define TCB_FLAG_CPU_LOCKED (1 << 5) /* Bit 5: Locked to this CPU */
#define TCB_FLAG_SIGNAL_ACTION (1 << 6) /* Bit 6: In a signal handler */
#define TCB_FLAG_SYSCALL (1 << 7) /* Bit 7: In a system call */
#define TCB_FLAG_EXIT_PROCESSING (1 << 8) /* Bit 8: Exitting */
#define TCB_FLAG_FREE_STACK (1 << 9) /* Bit 9: Free stack after exit */
#define TCB_FLAG_HEAP_CHECK (1 << 10) /* Bit 10: Heap check */
#define TCB_FLAG_HEAP_DUMP (1 << 11) /* Bit 11: Heap dump */
#define TCB_FLAG_DETACHED (1 << 12) /* Bit 12: Pthread detached */
#define TCB_FLAG_FORCED_CANCEL (1 << 13) /* Bit 13: Pthread cancel is forced */
#define TCB_FLAG_JOIN_COMPLETED (1 << 14) /* Bit 14: Pthread join completed */
#define TCB_FLAG_FREE_TCB (1 << 15) /* Bit 15: Free tcb after exit */
#define TCB_FLAG_CPU_LOCKED (1 << 4) /* Bit 4: Locked to this CPU */
#define TCB_FLAG_SIGNAL_ACTION (1 << 5) /* Bit 5: In a signal handler */
#define TCB_FLAG_SYSCALL (1 << 6) /* Bit 6: In a system call */
#define TCB_FLAG_EXIT_PROCESSING (1 << 7) /* Bit 7: Exitting */
#define TCB_FLAG_FREE_STACK (1 << 8) /* Bit 8: Free stack after exit */
#define TCB_FLAG_HEAP_CHECK (1 << 9) /* Bit 9: Heap check */
#define TCB_FLAG_HEAP_DUMP (1 << 10) /* Bit 10: Heap dump */
#define TCB_FLAG_DETACHED (1 << 11) /* Bit 11: Pthread detached */
#define TCB_FLAG_FORCED_CANCEL (1 << 12) /* Bit 12: Pthread cancel is forced */
#define TCB_FLAG_JOIN_COMPLETED (1 << 13) /* Bit 13: Pthread join completed */
#define TCB_FLAG_FREE_TCB (1 << 14) /* Bit 14: Free tcb after exit */
#define TCB_FLAG_SIGDELIVER (1 << 15) /* Bit 15: Deliver pending signals */
/* Values for struct task_group tg_flags */
@ -303,7 +304,6 @@ typedef enum tstate_e tstate_t;
/* The following is the form of a thread start-up function */
typedef CODE void (*start_t)(void);
typedef CODE void (*sig_deliver_t)(FAR struct tcb_s *tcb);
/* This is the entry point into the main thread of the task or into a created
* pthread within the task.
@ -721,11 +721,6 @@ struct tcb_s
struct xcptcontext xcp; /* Interrupt register save area */
/* The following function pointer is non-zero if there are pending signals
* to be processed.
*/
sig_deliver_t sigdeliver;
#if CONFIG_TASK_NAME_SIZE > 0
char name[CONFIG_TASK_NAME_SIZE + 1]; /* Task name (with NUL terminator) */
#endif

View file

@ -86,7 +86,7 @@ static int sig_handler(FAR void *cookie)
tcb->flags &= ~TCB_FLAG_CPU_LOCKED;
}
if (tcb->sigdeliver)
if ((tcb->flags & TCB_FLAG_SIGDELIVER) != 0)
{
up_schedule_sigaction(tcb);
}
@ -160,13 +160,13 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info)
* up_schedule_sigaction()
*/
if (!stcb->sigdeliver)
if ((stcb->flags & TCB_FLAG_SIGDELIVER) == 0)
{
#ifdef CONFIG_SMP
int cpu = stcb->cpu;
int me = this_cpu();
stcb->sigdeliver = nxsig_deliver;
stcb->flags |= TCB_FLAG_SIGDELIVER;
if (cpu != me && stcb->task_state == TSTATE_TASK_RUNNING)
{
struct sig_arg_s arg;
@ -190,7 +190,7 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb, siginfo_t *info)
else
#endif
{
stcb->sigdeliver = nxsig_deliver;
stcb->flags |= TCB_FLAG_SIGDELIVER;
up_schedule_sigaction(stcb);
}
}