libc/tls: Make tls_get_info as the pulibc function instead up_tls_info

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-05-27 10:05:43 +08:00 committed by Petro Karashchenko
parent 33a6aa2f48
commit 3e32b605fe
17 changed files with 26 additions and 34 deletions

@ -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>

@ -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
*

@ -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

@ -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 */

@ -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

@ -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 */

@ -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);

@ -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

@ -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. */

@ -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. */

@ -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)

@ -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;
}

@ -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;

@ -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) */

@ -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);

@ -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"

@ -32,6 +32,7 @@
#include <nuttx/arch.h>
#include <nuttx/sched.h>
#include <nuttx/tls.h>
#include "group/group.h"
#include "sched/sched.h"