errno: use staic errno to replace tl_errno before tls initialization

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2021-09-09 21:03:42 +08:00 committed by Xiang Xiao
parent 34397094d7
commit d8ea482b58
2 changed files with 8 additions and 2 deletions

View File

@ -42,7 +42,7 @@
#define set_errno(e) \
do \
{ \
errno = (int)(e); \
errno = (int)(e); \
} \
while (0)
#define get_errno() errno

View File

@ -29,6 +29,12 @@
#include <arch/tls.h>
/****************************************************************************
* Private Data
****************************************************************************/
static int g_errno;
/****************************************************************************
* Public Functions
****************************************************************************/
@ -57,5 +63,5 @@ FAR int *__errno(void)
/* And return the return refernce to the error number */
return &tlsinfo->tl_errno;
return tlsinfo ? &tlsinfo->tl_errno : &g_errno;
}