tls: Move task_tls_alloc and task_tls_destruct to libc
so task_tls_destruct can be called from usrspace, which is required by: https://github.com/apache/nuttx/pull/10288 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
cb8df39207
commit
47faeeb360
21 changed files with 23 additions and 30 deletions
|
@ -96,7 +96,7 @@ NXSYMBOLS(pthread_cond_init)
|
|||
NXSYMBOLS(pthread_cond_signal)
|
||||
NXSYMBOLS(pthread_cond_wait)
|
||||
NXSYMBOLS(pthread_create)
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
NXSYMBOLS(pthread_getspecific)
|
||||
NXSYMBOLS(pthread_key_create)
|
||||
#endif
|
||||
|
@ -105,7 +105,7 @@ NXSYMBOLS(pthread_mutex_destroy)
|
|||
NXSYMBOLS(pthread_mutex_init)
|
||||
NXSYMBOLS(pthread_mutex_lock)
|
||||
NXSYMBOLS(pthread_mutex_unlock)
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
NXSYMBOLS(pthread_setspecific)
|
||||
#endif
|
||||
NXSYMBOLS(pthread_sigmask)
|
||||
|
|
|
@ -118,5 +118,4 @@ CONFIG_SYSTEM_NSH=y
|
|||
CONFIG_SYSTEM_NSH_PROGNAME="init"
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TLS_TASK_NELEM=4
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
|
|
|
@ -120,5 +120,4 @@ CONFIG_SYSTEM_NSH_PROGNAME="init"
|
|||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TESTING_GETPRIME=y
|
||||
CONFIG_TESTING_SMP=y
|
||||
CONFIG_TLS_TASK_NELEM=4
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
|
|
|
@ -120,7 +120,7 @@ struct task_info_s
|
|||
#if CONFIG_TLS_TASK_NELEM > 0
|
||||
uintptr_t ta_telem[CONFIG_TLS_TASK_NELEM]; /* Task local storage elements */
|
||||
#endif
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
tls_dtor_t ta_tlsdtor[CONFIG_TLS_NELEM]; /* List of TLS destructors */
|
||||
#endif
|
||||
#ifndef CONFIG_BUILD_KERNEL
|
||||
|
@ -192,7 +192,7 @@ struct tls_info_s
|
|||
{
|
||||
FAR struct task_info_s * tl_task;
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
uintptr_t tl_elem[CONFIG_TLS_NELEM]; /* TLS elements */
|
||||
#endif
|
||||
|
||||
|
@ -326,7 +326,7 @@ FAR struct tls_info_s *tls_get_info(void);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
void tls_destruct(void);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -112,10 +112,6 @@ SYSCALL_LOOKUP(task_setcancelstate, 2)
|
|||
SYSCALL_LOOKUP(task_testcancel, 0)
|
||||
#endif
|
||||
|
||||
#if CONFIG_TLS_TASK_NELEM > 0
|
||||
SYSCALL_LOOKUP(task_tls_alloc, 1)
|
||||
#endif
|
||||
|
||||
/* The following can be individually enabled */
|
||||
|
||||
#ifdef CONFIG_ARCH_HAVE_FORK
|
||||
|
|
|
@ -64,7 +64,7 @@ void pthread_exit(FAR void *exit_value)
|
|||
pthread_cleanup_popall(tls_get_info());
|
||||
#endif
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
tls_destruct();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
|
@ -100,7 +100,7 @@ void exit(int status)
|
|||
pthread_cleanup_popall(tls_get_info());
|
||||
#endif
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
tls_destruct();
|
||||
#endif
|
||||
|
||||
|
@ -149,7 +149,7 @@ void quick_exit(int status)
|
|||
pthread_cleanup_popall(tls_get_info());
|
||||
#endif
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
tls_destruct();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
set(SRCS task_getinfo.c tls_getinfo.c)
|
||||
|
||||
if(NOT CONFIG_TLS_TASK_NELEM EQUAL 0)
|
||||
list(APPEND SRCS task_tls.c)
|
||||
list(APPEND SRCS task_tls.c task_tls_destruct.c)
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_TLS_NELEM EQUAL 0)
|
||||
|
|
|
@ -44,6 +44,7 @@ config TLS_LOG2_MAXSTACK
|
|||
|
||||
config TLS_NELEM
|
||||
int "Number of TLS elements"
|
||||
depends on !DISABLE_PTHREAD
|
||||
default 0
|
||||
range 0 255
|
||||
---help---
|
||||
|
@ -56,6 +57,7 @@ config TLS_NELEM
|
|||
|
||||
config TLS_TASK_NELEM
|
||||
int "Number of Task Local Storage elements"
|
||||
depends on !BUILD_KERNEL
|
||||
default 0
|
||||
range 0 255
|
||||
---help---
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
CSRCS += task_getinfo.c tls_getinfo.c
|
||||
|
||||
ifneq ($(CONFIG_TLS_TASK_NELEM),0)
|
||||
CSRCS += task_tls.c
|
||||
CSRCS += task_tls.c task_tls_destruct.c
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_TLS_NELEM),0)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <errno.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#if CONFIG_TLS_TASK_NELEM > 0
|
||||
#if defined(CONFIG_TLS_TASK_NELEM) && CONFIG_TLS_TASK_NELEM > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* sched/task/task_tls_alloc.c
|
||||
* libs/libc/tls/task_tls_destruct.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -34,7 +34,7 @@
|
|||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_TLS_TASK_NELEM > 0
|
||||
#if defined(CONFIG_TLS_TASK_NELEM) && CONFIG_TLS_TASK_NELEM > 0
|
||||
|
||||
static mutex_t g_tlslock = NXMUTEX_INITIALIZER;
|
||||
static tls_dtor_t g_tlsdtor[CONFIG_TLS_TASK_NELEM];
|
||||
|
@ -57,7 +57,7 @@ static void tls_dtor(FAR void *arg)
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: task_tls_allocs
|
||||
* Name: task_tls_alloc
|
||||
*
|
||||
* Description:
|
||||
* Allocate a global-unique task local storage data index
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#if CONFIG_TLS_NELEM > 0
|
||||
#if defined(CONFIG_TLS_NELEM) && CONFIG_TLS_NELEM > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
|
@ -128,7 +128,7 @@ static void group_remove(FAR struct task_group_s *group)
|
|||
|
||||
static inline void group_release(FAR struct task_group_s *group)
|
||||
{
|
||||
#if CONFIG_TLS_TASK_NELEM > 0
|
||||
#if defined(CONFIG_TLS_TASK_NELEM) && CONFIG_TLS_TASK_NELEM > 0
|
||||
task_tls_destruct();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@ list(
|
|||
task_cancelpt.c
|
||||
task_terminate.c
|
||||
task_gettid.c
|
||||
exit.c
|
||||
task_tls_alloc.c)
|
||||
exit.c)
|
||||
|
||||
if(CONFIG_SCHED_HAVE_PARENT)
|
||||
list(APPEND SRCS task_getppid.c task_reparent.c)
|
||||
|
|
|
@ -23,7 +23,6 @@ CSRCS += task_start.c task_delete.c task_exit.c task_exithook.c
|
|||
CSRCS += task_getgroup.c task_getpid.c task_prctl.c task_recover.c
|
||||
CSRCS += task_restart.c task_spawnparms.c task_setcancelstate.c
|
||||
CSRCS += task_cancelpt.c task_terminate.c task_gettid.c exit.c
|
||||
CSRCS += task_tls_alloc.c
|
||||
|
||||
ifeq ($(CONFIG_SCHED_HAVE_PARENT),y)
|
||||
CSRCS += task_getppid.c task_reparent.c
|
||||
|
|
|
@ -189,7 +189,6 @@
|
|||
"task_setcanceltype","sched.h","defined(CONFIG_CANCELLATION_POINTS)","int","int","FAR int *"
|
||||
"task_spawn","nuttx/spawn.h","!defined(CONFIG_BUILD_KERNEL)","int","FAR const char *","main_t","FAR const posix_spawn_file_actions_t *","FAR const posix_spawnattr_t *","FAR char * const []|FAR char * const *","FAR char * const []|FAR char * const *"
|
||||
"task_testcancel","sched.h","defined(CONFIG_CANCELLATION_POINTS)","void"
|
||||
"task_tls_alloc","nuttx/tls.h","CONFIG_TLS_TASK_NELEM > 0","int","tls_dtor_t"
|
||||
"tgkill","signal.h","","int","pid_t","pid_t","int"
|
||||
"time","time.h","","time_t","FAR time_t *"
|
||||
"timer_create","time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","clockid_t","FAR struct sigevent *","FAR timer_t *"
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 2.
|
Loading…
Reference in a new issue