arch/arm: Implement TLS support

Signed-off-by: Huang Qi <no1wudi@qq.com>
This commit is contained in:
Huang Qi
2021-12-03 21:35:39 +08:00
committed by Xiang Xiao
parent 3e8a3c9cc2
commit 58e0781e2e
72 changed files with 899 additions and 6 deletions
+8
View File
@@ -600,6 +600,14 @@ config SCHED_USER_IDENTITY
Those can then be managed using the interfaces. Child tasks will
inherit the UID and GID of its parent.
config SCHED_THREAD_LOCAL
bool "Support __thread/thread_local keyword"
default n
depends on ARCH_HAVE_THREAD_LOCAL
---help---
This option enables architecture-sepecific TLS supports (__thread/thread_local keyword)
Note: Toolchain must be compiled with '--enable-tls' enabled
endmenu # Tasks and Scheduling
menu "Pthread Options"
+3 -1
View File
@@ -580,7 +580,9 @@ void nx_start(void)
up_initial_state(&g_idletcb[i].cmn);
/* Initialize the thread local storage */
/* Initialize the thread local storage
* Note: Don't copy tdata and tss for idle task to improve footprint
*/
info = up_stack_frame(&g_idletcb[i].cmn, sizeof(struct tls_info_s));
DEBUGASSERT(info == g_idletcb[i].cmn.stack_alloc_ptr);
+4 -2
View File
@@ -315,7 +315,7 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
/* Allocate the stack for the TCB */
ret = up_create_stack((FAR struct tcb_s *)ptcb,
sizeof(struct tls_info_s) + attr->stacksize,
up_tls_size() + attr->stacksize,
TCB_FLAG_TTYPE_PTHREAD);
}
@@ -327,7 +327,7 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
/* Initialize thread local storage */
info = up_stack_frame(&ptcb->cmn, sizeof(struct tls_info_s));
info = up_stack_frame(&ptcb->cmn, up_tls_size());
if (info == NULL)
{
errcode = ENOMEM;
@@ -336,6 +336,8 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
DEBUGASSERT(info == ptcb->cmn.stack_alloc_ptr);
up_tls_initialize(info);
/* Attach per-task info in group to TLS */
info->tl_task = ptcb->cmn.group->tg_info;
+4 -2
View File
@@ -122,7 +122,7 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
/* Allocate the stack for the TCB */
ret = up_create_stack(&tcb->cmn,
sizeof(struct tls_info_s) + stack_size,
up_tls_size() + stack_size,
ttype);
}
@@ -133,7 +133,7 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
/* Initialize thread local storage */
info = up_stack_frame(&tcb->cmn, sizeof(struct tls_info_s));
info = up_stack_frame(&tcb->cmn, up_tls_size());
if (info == NULL)
{
ret = -ENOMEM;
@@ -144,6 +144,8 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
info->tl_task = tcb->cmn.group->tg_info;
up_tls_initialize(info);
/* Initialize the task control block */
ret = nxtask_setup_scheduler(tcb, priority, nxtask_start,
+3 -1
View File
@@ -173,7 +173,7 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
/* Setup thread local storage */
info = up_stack_frame(&child->cmn, sizeof(struct tls_info_s));
info = up_stack_frame(&child->cmn, up_tls_size());
if (info == NULL)
{
ret = -ENOMEM;
@@ -184,6 +184,8 @@ FAR struct task_tcb_s *nxtask_setup_vfork(start_t retaddr)
memcpy(info, parent->cmn.stack_alloc_ptr, sizeof(struct tls_info_s));
info->tl_task = child->cmn.group->tg_info;
up_tls_initialize(info);
/* Get the priority of the parent task */
#ifdef CONFIG_PRIORITY_INHERITANCE