mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
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:
committed by
Petro Karashchenko
parent
33a6aa2f48
commit
3e32b605fe
@@ -44,7 +44,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/tls.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/environ.h>
|
#include <nuttx/environ.h>
|
||||||
|
|||||||
@@ -85,7 +85,6 @@
|
|||||||
#include <nuttx/compiler.h>
|
#include <nuttx/compiler.h>
|
||||||
#include <nuttx/cache.h>
|
#include <nuttx/cache.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/tls.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor definitions
|
* 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.
|
* 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
|
* Name: up_tls_size
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ void nx_pthread_exit(FAR void *exit_value) noreturn_function;
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||||
|
struct tls_info_s;
|
||||||
void pthread_cleanup_popall(FAR struct tls_info_s *tls);
|
void pthread_cleanup_popall(FAR struct tls_info_s *tls);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -33,18 +33,16 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/tls.h>
|
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/mm/shm.h>
|
#include <nuttx/mm/shm.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/net/net.h>
|
#include <nuttx/net/net.h>
|
||||||
|
|
||||||
#include <arch/arch.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -393,6 +391,8 @@ struct stackinfo_s
|
|||||||
* the struct task_group_s is free.
|
* the struct task_group_s is free.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct task_info_s;
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_PTHREAD
|
#ifndef CONFIG_DISABLE_PTHREAD
|
||||||
struct join_s; /* Forward reference */
|
struct join_s; /* Forward reference */
|
||||||
/* Defined in sched/pthread/pthread.h */
|
/* Defined in sched/pthread/pthread.h */
|
||||||
|
|||||||
+6
-1
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/atexit.h>
|
#include <nuttx/atexit.h>
|
||||||
|
|
||||||
#include <sys/types.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);
|
FAR struct tls_info_s *tls_get_info(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -57,7 +56,7 @@ FAR int *__errno(void)
|
|||||||
{
|
{
|
||||||
/* Get the TLS tls_info_s structure instance for this thread */
|
/* 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 */
|
/* And return the return refernce to the error number */
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
#include <nuttx/pthread.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)
|
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);
|
DEBUGASSERT(tls != NULL);
|
||||||
|
|
||||||
@@ -135,7 +134,7 @@ void pthread_cleanup_pop(int execute)
|
|||||||
|
|
||||||
void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
|
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 != NULL);
|
||||||
DEBUGASSERT(tls->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE);
|
DEBUGASSERT(tls->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/pthread.h>
|
#include <nuttx/pthread.h>
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ void pthread_exit(FAR void *exit_value)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||||
pthread_cleanup_popall(up_tls_info());
|
pthread_cleanup_popall(tls_get_info());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_TLS_NELEM > 0
|
#if CONFIG_TLS_NELEM > 0
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
#if CONFIG_TLS_NELEM > 0
|
#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 */
|
/* Get the TLS info structure from the current threads stack */
|
||||||
|
|
||||||
info = up_tls_info();
|
info = tls_get_info();
|
||||||
DEBUGASSERT(info != NULL);
|
DEBUGASSERT(info != NULL);
|
||||||
|
|
||||||
/* Get the element value from the TLS info. */
|
/* Get the element value from the TLS info. */
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
#if CONFIG_TLS_NELEM > 0
|
#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 */
|
/* Get the TLS info structure from the current threads stack */
|
||||||
|
|
||||||
info = up_tls_info();
|
info = tls_get_info();
|
||||||
DEBUGASSERT(info != NULL);
|
DEBUGASSERT(info != NULL);
|
||||||
|
|
||||||
/* Set the element value int the TLS info. */
|
/* 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
|
The number of unique Task Local Storage elements similar with
|
||||||
Thread Local Storage.
|
Thread Local Storage.
|
||||||
These can be accessed with task_tls_alloc/task_tls_get_value/task_tls_set_value.
|
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
|
NOTE that the 0 value of CONFIG_SCHED_TLS_NELEM disables these
|
||||||
TLS interfaces.
|
TLS interfaces.
|
||||||
|
|
||||||
endmenu # Thread Local Storage (TLS)
|
endmenu # Thread Local Storage (TLS)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -48,7 +47,7 @@
|
|||||||
|
|
||||||
FAR struct task_info_s *task_get_info(void)
|
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;
|
return info->tl_task;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
#if CONFIG_TLS_NELEM > 0
|
#if CONFIG_TLS_NELEM > 0
|
||||||
@@ -52,7 +51,7 @@
|
|||||||
void tls_destruct(void)
|
void tls_destruct(void)
|
||||||
{
|
{
|
||||||
FAR struct task_info_s *info = task_get_info();
|
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;
|
FAR void *tls_elem_ptr = NULL;
|
||||||
tls_dtor_t destructor;
|
tls_dtor_t destructor;
|
||||||
tls_ndxset_t tlsset;
|
tls_ndxset_t tlsset;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/tls.h>
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
#if !defined(CONFIG_TLS_ALIGNED) || defined(__KERNEL__)
|
#if !defined(up_tls_info) && !defined(CONFIG_TLS_ALIGNED)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@@ -72,4 +72,4 @@ FAR struct tls_info_s *tls_get_info(void)
|
|||||||
return info;
|
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);
|
pthread_exit(PTHREAD_CANCELED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Refer to up_tls_info() */
|
/* Refer to tls_get_info() */
|
||||||
|
|
||||||
#ifdef CONFIG_PTHREAD_CLEANUP
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
||||||
pthread_cleanup_popall(tcb->stack_alloc_ptr);
|
pthread_cleanup_popall(tcb->stack_alloc_ptr);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
#include <nuttx/signal.h>
|
#include <nuttx/signal.h>
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "pthread/pthread.h"
|
#include "pthread/pthread.h"
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
|
#include <nuttx/tls.h>
|
||||||
|
|
||||||
#include "group/group.h"
|
#include "group/group.h"
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user