You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/09/12 03:48:37 UTC
[incubator-nuttx] branch master updated: errno: use staic errno to
replace tl_errno before tls initialization
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d8ea482 errno: use staic errno to replace tl_errno before tls initialization
d8ea482 is described below
commit d8ea482b58afd29c44380553afda6d782ed0f709
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Thu Sep 9 21:03:42 2021 +0800
errno: use staic errno to replace tl_errno before tls initialization
Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
include/errno.h | 2 +-
libs/libc/errno/lib_errno.c | 8 +++++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/errno.h b/include/errno.h
index 9caf44d..b88ee3a 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -42,7 +42,7 @@
#define set_errno(e) \
do \
{ \
- errno = (int)(e); \
+ errno = (int)(e); \
} \
while (0)
#define get_errno() errno
diff --git a/libs/libc/errno/lib_errno.c b/libs/libc/errno/lib_errno.c
index 92582d6..101f5dd 100644
--- a/libs/libc/errno/lib_errno.c
+++ b/libs/libc/errno/lib_errno.c
@@ -30,6 +30,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;
}