mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
arch/arm: Implement TLS support
Signed-off-by: Huang Qi <no1wudi@qq.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user