mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
include/errno.h: skip set_errno in interrupt context
set_errno() should not modify the interrupted task's errno. Add a check using up_interrupt_context() and skip the assignment when called from an interrupt handler. Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
This commit is contained in:
parent
a8a492cb4f
commit
3c9a9d683f
1 changed files with 16 additions and 0 deletions
|
|
@ -29,6 +29,10 @@
|
|||
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
# include <nuttx/irq.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
|
@ -41,12 +45,24 @@
|
|||
*/
|
||||
|
||||
#define errno *__errno()
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
#define set_errno(e) \
|
||||
do \
|
||||
{ \
|
||||
if (!up_interrupt_context()) \
|
||||
{ \
|
||||
errno = (int)(e); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
#else
|
||||
#define set_errno(e) \
|
||||
do \
|
||||
{ \
|
||||
errno = (int)(e); \
|
||||
} \
|
||||
while (0)
|
||||
#endif
|
||||
#define get_errno() errno
|
||||
|
||||
/* Definitions of error numbers and the string that would be
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue