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 2022/02/27 17:13:06 UTC
[incubator-nuttx] branch master updated: fix up_tls_info define for BUILD_KERNEL
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 fbf05db fix up_tls_info define for BUILD_KERNEL
fbf05db is described below
commit fbf05db906b5a201febd2a4e08a59dc18282430d
Author: Oki Minabe <mi...@gmail.com>
AuthorDate: Sun Feb 27 17:24:50 2022 +0900
fix up_tls_info define for BUILD_KERNEL
Summary:
- In case of BUILD_KERNEL, NuttX uses USR mode sp and SVC mode sp.
- The kernel runs on SVC mode sp.
- While the kernel is running, up_getsp() cannot get the TLS address.
- The kernel requires tls_get_info() function.
- For the user land, up_getsp() can be used.
- tls_getinfo.c is always compiled and tls_get_info() function is
filtered by macros in the tls_getinfo.c.
Impact:
BUILD_KERNEL
Testing:
test program on custom Cortex-A9 board (BUILD_KERNEL)
ostest on sabre-6quad:smp (QEMU, BUILD_FLAT)
Signed-off-by: Oki Minabe <mi...@gmail.com>
---
include/nuttx/arch.h | 2 +-
include/nuttx/tls.h | 2 +-
libs/libc/tls/Make.defs | 6 +-----
libs/libc/tls/tls_getinfo.c | 6 +++---
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 5b22d5b..427307e 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -1780,7 +1780,7 @@ int up_timer_start(FAR const struct timespec *ts);
*/
#ifndef up_tls_info
-# ifdef CONFIG_TLS_ALIGNED
+# if defined(CONFIG_TLS_ALIGNED) && !defined(__KERNEL__)
# define up_tls_info() TLS_INFO((uintptr_t)up_getsp())
# else
# define up_tls_info() tls_get_info()
diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h
index 87794cc..de4cbcf 100644
--- a/include/nuttx/tls.h
+++ b/include/nuttx/tls.h
@@ -378,7 +378,7 @@ uintptr_t task_tls_get_value(int tlsindex);
*
****************************************************************************/
-#ifndef CONFIG_TLS_ALIGNED
+#if !defined(CONFIG_TLS_ALIGNED) || defined(__KERNEL__)
FAR struct tls_info_s *tls_get_info(void);
#endif
diff --git a/libs/libc/tls/Make.defs b/libs/libc/tls/Make.defs
index 8cc8e83..5cb0a7e 100644
--- a/libs/libc/tls/Make.defs
+++ b/libs/libc/tls/Make.defs
@@ -18,17 +18,13 @@
#
############################################################################
-CSRCS += task_getinfo.c
+CSRCS += task_getinfo.c tls_getinfo.c
ifneq ($(CONFIG_TLS_NELEM),0)
CSRCS += tls_alloc.c tls_free.c
CSRCS += tls_setvalue.c tls_getvalue.c tls_destruct.c
endif
-ifneq ($(CONFIG_TLS_ALIGNED),y)
-CSRCS += tls_getinfo.c
-endif
-
# Include tls build support
DEPPATH += --dep-path tls
diff --git a/libs/libc/tls/tls_getinfo.c b/libs/libc/tls/tls_getinfo.c
index 7425956..be111cc 100644
--- a/libs/libc/tls/tls_getinfo.c
+++ b/libs/libc/tls/tls_getinfo.c
@@ -30,7 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/tls.h>
-#ifndef CONFIG_TLS_ALIGNED
+#if !defined(CONFIG_TLS_ALIGNED) || defined(__KERNEL__)
/****************************************************************************
* Public Functions
@@ -42,7 +42,7 @@
* Description:
* Return a reference to the tls_info_s structure. This is used as part
* of the internal implementation of tls_get/set_elem() and ONLY for the
- * where CONFIG_TLS_ALIGNED is *not* defined
+ * where CONFIG_TLS_ALIGNED is *not* defined or __KERNEL__ is defined.
*
* Input Parameters:
* None
@@ -72,4 +72,4 @@ FAR struct tls_info_s *tls_get_info(void)
return info;
}
-#endif /* !CONFIG_TLS_ALIGNED */
+#endif /* !CONFIG_TLS_ALIGNED || __KERNEL__ */