mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 00:15:55 +08: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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user