Apply same fix for ARMv7-M to other architectures

This commit is contained in:
Gregory Nutt
2015-09-30 11:21:04 -06:00
parent 08baf2fcc3
commit 26347891ac
14 changed files with 146 additions and 148 deletions
+20 -20
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/x86/src/i486/up_schedulesigaction.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -98,20 +98,20 @@
void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
{
/* Refuse to handle nested signal actions */
irqstate_t flags;
sdbg("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver);
/* Make sure that interrupts are disabled */
flags = irqsave();
/* Refuse to handle nested signal actions */
if (!tcb->xcp.sigdeliver)
{
irqstate_t flags;
/* Make sure that interrupts are disabled */
flags = irqsave();
/* First, handle some special cases when the signal is being delivered
* to the currently executing task.
* to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
@@ -119,7 +119,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb == (struct tcb_s*)g_readytorun.head)
{
/* CASE 1: We are not in an interrupt handler and a task is
* signalling itself for some reason.
* signalling itself for some reason.
*/
if (!current_regs)
@@ -130,21 +130,21 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
}
/* CASE 2: We are in an interrupt handler AND the interrupted task
* is the same as the one that must receive the signal, then we will
* have to modify the return state as well as the state in the TCB.
* is the same as the one that must receive the signal, then we will
* have to modify the return state as well as the state in the TCB.
*
* Hmmm... there looks like a latent bug here: The following logic
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch to
* another task has occurred so that current_regs does not refer to
* the thread at g_readytorun.head!
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch to
* another task has occurred so that current_regs does not refer to
* the thread at g_readytorun.head!
*/
else
{
/* Save the return lr and cpsr and one scratch register. These
* will be restored by the signal trampoline after the signals
* have been delivered.
* will be restored by the signal trampoline after the signals
* have been delivered.
*/
tcb->xcp.sigdeliver = sigdeliver;
@@ -190,9 +190,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs[REG_EIP] = (uint32_t)up_sigdeliver;
tcb->xcp.regs[REG_EFLAGS] = 0;
}
irqrestore(flags);
}
irqrestore(flags);
}
#endif /* !CONFIG_DISABLE_SIGNALS */