You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/06/03 20:57:00 UTC
[incubator-nuttx] 03/05: libc/tls: Make tls_get_info as the pulibc function instead up_tls_info
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 3e32b605feb8142b30277fa5f45cdc8eb0e5e2c0
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri May 27 10:05:43 2022 +0800
libc/tls: Make tls_get_info as the pulibc function instead up_tls_info
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
fs/procfs/fs_procfsproc.c | 2 +-
include/nuttx/arch.h | 9 ---------
include/nuttx/pthread.h | 1 +
include/nuttx/sched.h | 6 +++---
include/nuttx/tls.h | 7 ++++++-
libs/libc/errno/lib_errno.c | 3 +--
libs/libc/pthread/pthread_cleanup.c | 5 ++---
libs/libc/pthread/pthread_exit.c | 3 +--
libs/libc/pthread/pthread_getspecific.c | 3 +--
libs/libc/pthread/pthread_setspecific.c | 3 +--
libs/libc/tls/Kconfig | 4 ++--
libs/libc/tls/task_getinfo.c | 3 +--
libs/libc/tls/tls_destruct.c | 3 +--
libs/libc/tls/tls_getinfo.c | 4 ++--
sched/pthread/pthread_cancel.c | 2 +-
sched/task/task_setup.c | 1 +
sched/task/task_start.c | 1 +
17 files changed, 26 insertions(+), 34 deletions(-)
diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c
index 0d88d8e421..a01bfb48b4 100644
--- a/fs/procfs/fs_procfsproc.c
+++ b/fs/procfs/fs_procfsproc.c
@@ -44,7 +44,7 @@
#endif
#include <nuttx/irq.h>
-#include <nuttx/arch.h>
+#include <nuttx/tls.h>
#include <nuttx/sched.h>
#include <nuttx/kmalloc.h>
#include <nuttx/environ.h>
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 23055d57e2..ca4962ba88 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -85,7 +85,6 @@
#include <nuttx/compiler.h>
#include <nuttx/cache.h>
#include <nuttx/sched.h>
-#include <nuttx/tls.h>
/****************************************************************************
* Pre-processor definitions
@@ -1826,14 +1825,6 @@ int up_timer_start(FAR const struct timespec *ts);
* implementation provided here assume the arch has a "push down" stack.
*/
-#ifndef up_tls_info
-# 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()
-# endif
-#endif
-
/****************************************************************************
* Name: up_tls_size
*
diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h
index a9ebf508aa..257db022ec 100644
--- a/include/nuttx/pthread.h
+++ b/include/nuttx/pthread.h
@@ -184,6 +184,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
****************************************************************************/
#ifdef CONFIG_PTHREAD_CLEANUP
+struct tls_info_s;
void pthread_cleanup_popall(FAR struct tls_info_s *tls);
#endif
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 9738724487..99bec382e8 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -33,18 +33,16 @@
#include <sched.h>
#include <signal.h>
#include <semaphore.h>
+#include <pthread.h>
#include <time.h>
#include <nuttx/clock.h>
#include <nuttx/irq.h>
-#include <nuttx/tls.h>
#include <nuttx/wdog.h>
#include <nuttx/mm/shm.h>
#include <nuttx/fs/fs.h>
#include <nuttx/net/net.h>
-#include <arch/arch.h>
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -393,6 +391,8 @@ struct stackinfo_s
* the struct task_group_s is free.
*/
+struct task_info_s;
+
#ifndef CONFIG_DISABLE_PTHREAD
struct join_s; /* Forward reference */
/* Defined in sched/pthread/pthread.h */
diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h
index 846e7010e3..33d65ac445 100644
--- a/include/nuttx/tls.h
+++ b/include/nuttx/tls.h
@@ -27,6 +27,7 @@
#include <nuttx/config.h>
+#include <nuttx/arch.h>
#include <nuttx/atexit.h>
#include <sys/types.h>
@@ -301,7 +302,11 @@ uintptr_t task_tls_get_value(int tlsindex);
*
****************************************************************************/
-#if !defined(CONFIG_TLS_ALIGNED) || defined(__KERNEL__)
+#if defined(up_tls_info)
+# define tls_get_info() up_tls_info()
+#elif defined(CONFIG_TLS_ALIGNED)
+# define tls_get_info() TLS_INFO(up_getsp())
+#else
FAR struct tls_info_s *tls_get_info(void);
#endif
diff --git a/libs/libc/errno/lib_errno.c b/libs/libc/errno/lib_errno.c
index 87ecb0d5fe..684b2bff92 100644
--- a/libs/libc/errno/lib_errno.c
+++ b/libs/libc/errno/lib_errno.c
@@ -24,7 +24,6 @@
#include <nuttx/config.h>
-#include <nuttx/arch.h>
#include <nuttx/tls.h>
/****************************************************************************
@@ -57,7 +56,7 @@ FAR int *__errno(void)
{
/* Get the TLS tls_info_s structure instance for this thread */
- FAR struct tls_info_s *tlsinfo = up_tls_info();
+ FAR struct tls_info_s *tlsinfo = tls_get_info();
/* And return the return refernce to the error number */
diff --git a/libs/libc/pthread/pthread_cleanup.c b/libs/libc/pthread/pthread_cleanup.c
index b8aca803ad..2df925e68d 100644
--- a/libs/libc/pthread/pthread_cleanup.c
+++ b/libs/libc/pthread/pthread_cleanup.c
@@ -28,7 +28,6 @@
#include <sched.h>
#include <assert.h>
-#include <nuttx/arch.h>
#include <nuttx/sched.h>
#include <nuttx/tls.h>
#include <nuttx/pthread.h>
@@ -119,7 +118,7 @@ static void pthread_cleanup_pop_tls(FAR struct tls_info_s *tls, int execute)
void pthread_cleanup_pop(int execute)
{
- FAR struct tls_info_s *tls = up_tls_info();
+ FAR struct tls_info_s *tls = tls_get_info();
DEBUGASSERT(tls != NULL);
@@ -135,7 +134,7 @@ void pthread_cleanup_pop(int execute)
void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
{
- FAR struct tls_info_s *tls = up_tls_info();
+ FAR struct tls_info_s *tls = tls_get_info();
DEBUGASSERT(tls != NULL);
DEBUGASSERT(tls->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE);
diff --git a/libs/libc/pthread/pthread_exit.c b/libs/libc/pthread/pthread_exit.c
index c68ef6a7fa..0c0f0a214b 100644
--- a/libs/libc/pthread/pthread_exit.c
+++ b/libs/libc/pthread/pthread_exit.c
@@ -28,7 +28,6 @@
#include <debug.h>
#include <sched.h>
-#include <nuttx/arch.h>
#include <nuttx/pthread.h>
#include <nuttx/tls.h>
@@ -64,7 +63,7 @@ void pthread_exit(FAR void *exit_value)
#endif
#ifdef CONFIG_PTHREAD_CLEANUP
- pthread_cleanup_popall(up_tls_info());
+ pthread_cleanup_popall(tls_get_info());
#endif
#if CONFIG_TLS_NELEM > 0
diff --git a/libs/libc/pthread/pthread_getspecific.c b/libs/libc/pthread/pthread_getspecific.c
index 15bec11e68..318ba01270 100644
--- a/libs/libc/pthread/pthread_getspecific.c
+++ b/libs/libc/pthread/pthread_getspecific.c
@@ -27,7 +27,6 @@
#include <pthread.h>
#include <assert.h>
-#include <nuttx/arch.h>
#include <nuttx/tls.h>
#if CONFIG_TLS_NELEM > 0
@@ -71,7 +70,7 @@ FAR void *pthread_getspecific(pthread_key_t key)
{
/* Get the TLS info structure from the current threads stack */
- info = up_tls_info();
+ info = tls_get_info();
DEBUGASSERT(info != NULL);
/* Get the element value from the TLS info. */
diff --git a/libs/libc/pthread/pthread_setspecific.c b/libs/libc/pthread/pthread_setspecific.c
index c40d36a915..53c543a6da 100644
--- a/libs/libc/pthread/pthread_setspecific.c
+++ b/libs/libc/pthread/pthread_setspecific.c
@@ -27,7 +27,6 @@
#include <pthread.h>
#include <assert.h>
-#include <nuttx/arch.h>
#include <nuttx/tls.h>
#if CONFIG_TLS_NELEM > 0
@@ -81,7 +80,7 @@ int pthread_setspecific(pthread_key_t key, FAR const void *value)
{
/* Get the TLS info structure from the current threads stack */
- info = up_tls_info();
+ info = tls_get_info();
DEBUGASSERT(info != NULL);
/* Set the element value int the TLS info. */
diff --git a/libs/libc/tls/Kconfig b/libs/libc/tls/Kconfig
index 171605d022..511a3fb2e9 100644
--- a/libs/libc/tls/Kconfig
+++ b/libs/libc/tls/Kconfig
@@ -63,7 +63,7 @@ config TLS_TASK_NELEM
The number of unique Task Local Storage elements similar with
Thread Local Storage.
These can be accessed with task_tls_alloc/task_tls_get_value/task_tls_set_value.
- NOTE that the 0 value of CONFIG_SCHED_TLS_NELEM disables these
- TLS interfaces.
+ NOTE that the 0 value of CONFIG_SCHED_TLS_NELEM disables these
+ TLS interfaces.
endmenu # Thread Local Storage (TLS)
diff --git a/libs/libc/tls/task_getinfo.c b/libs/libc/tls/task_getinfo.c
index 34800f33f3..4bfad05c6e 100644
--- a/libs/libc/tls/task_getinfo.c
+++ b/libs/libc/tls/task_getinfo.c
@@ -24,7 +24,6 @@
#include <nuttx/config.h>
-#include <nuttx/arch.h>
#include <nuttx/tls.h>
/****************************************************************************
@@ -48,7 +47,7 @@
FAR struct task_info_s *task_get_info(void)
{
- FAR struct tls_info_s *info = up_tls_info();
+ FAR struct tls_info_s *info = tls_get_info();
return info->tl_task;
}
diff --git a/libs/libc/tls/tls_destruct.c b/libs/libc/tls/tls_destruct.c
index dfbfff53d5..b0ffc7bb28 100644
--- a/libs/libc/tls/tls_destruct.c
+++ b/libs/libc/tls/tls_destruct.c
@@ -26,7 +26,6 @@
#include <assert.h>
-#include <nuttx/arch.h>
#include <nuttx/tls.h>
#if CONFIG_TLS_NELEM > 0
@@ -52,7 +51,7 @@
void tls_destruct(void)
{
FAR struct task_info_s *info = task_get_info();
- FAR struct tls_info_s *tls = up_tls_info();
+ FAR struct tls_info_s *tls = tls_get_info();
FAR void *tls_elem_ptr = NULL;
tls_dtor_t destructor;
tls_ndxset_t tlsset;
diff --git a/libs/libc/tls/tls_getinfo.c b/libs/libc/tls/tls_getinfo.c
index be111ccfcf..01804fefc4 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>
-#if !defined(CONFIG_TLS_ALIGNED) || defined(__KERNEL__)
+#if !defined(up_tls_info) && !defined(CONFIG_TLS_ALIGNED)
/****************************************************************************
* Public Functions
@@ -72,4 +72,4 @@ FAR struct tls_info_s *tls_get_info(void)
return info;
}
-#endif /* !CONFIG_TLS_ALIGNED || __KERNEL__ */
+#endif /* !defined(up_tls_info) && !defined(CONFIG_TLS_ALIGNED) */
diff --git a/sched/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c
index e80fe647b4..368240b7c3 100644
--- a/sched/pthread/pthread_cancel.c
+++ b/sched/pthread/pthread_cancel.c
@@ -89,7 +89,7 @@ int pthread_cancel(pthread_t thread)
pthread_exit(PTHREAD_CANCELED);
}
- /* Refer to up_tls_info() */
+ /* Refer to tls_get_info() */
#ifdef CONFIG_PTHREAD_CLEANUP
pthread_cleanup_popall(tcb->stack_alloc_ptr);
diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c
index 36adfbb364..45965e879b 100644
--- a/sched/task/task_setup.c
+++ b/sched/task/task_setup.c
@@ -35,6 +35,7 @@
#include <nuttx/arch.h>
#include <nuttx/sched.h>
#include <nuttx/signal.h>
+#include <nuttx/tls.h>
#include "sched/sched.h"
#include "pthread/pthread.h"
diff --git a/sched/task/task_start.c b/sched/task/task_start.c
index 11af95dcd2..745531ab9b 100644
--- a/sched/task/task_start.c
+++ b/sched/task/task_start.c
@@ -32,6 +32,7 @@
#include <nuttx/arch.h>
#include <nuttx/sched.h>
+#include <nuttx/tls.h>
#include "group/group.h"
#include "sched/sched.h"