diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index ca4962ba88640..302767b5cde03 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -1838,8 +1838,6 @@ int up_timer_start(FAR const struct timespec *ts); #ifdef CONFIG_SCHED_THREAD_LOCAL int up_tls_size(void); -#else -#define up_tls_size() sizeof(struct tls_info_s) #endif /**************************************************************************** diff --git a/libs/libc/tls/tls_getinfo.c b/libs/libc/tls/tls_getinfo.c index 68b580a932106..faeb3da96b009 100644 --- a/libs/libc/tls/tls_getinfo.c +++ b/libs/libc/tls/tls_getinfo.c @@ -27,7 +27,6 @@ #include #include -#include #include #if !defined(up_tls_info) && (defined(__KERNEL__) || !defined(CONFIG_TLS_ALIGNED)) diff --git a/libs/libc/unistd/lib_getoptvars.c b/libs/libc/unistd/lib_getoptvars.c index cc0fde2cd5abc..49f3b6a559cb9 100644 --- a/libs/libc/unistd/lib_getoptvars.c +++ b/libs/libc/unistd/lib_getoptvars.c @@ -23,11 +23,8 @@ ****************************************************************************/ #include - #include -#include - #include "unistd.h" /**************************************************************************** diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c index d4bda7d59965a..fa203f69cafe2 100644 --- a/sched/group/group_leave.c +++ b/sched/group/group_leave.c @@ -33,7 +33,6 @@ #include #include #include -#include #ifdef CONFIG_BINFMT_LOADABLE # include diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 9f5b04f0483a3..497bf298acfe9 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -43,7 +43,6 @@ #include #include #include -#include #include "sched/sched.h" #include "signal/signal.h" @@ -54,6 +53,7 @@ #include "irq/irq.h" #include "group/group.h" #include "init/init.h" +#include "tls/tls.h" /**************************************************************************** * Pre-processor Definitions @@ -517,7 +517,6 @@ void nx_start(void) for (i = 0; i < CONFIG_SMP_NCPUS; i++) { - FAR struct tls_info_s *info; int hashndx; /* Assign the process ID(s) of ZERO to the idle task(s) */ @@ -546,13 +545,9 @@ void nx_start(void) up_initial_state(&g_idletcb[i].cmn); - /* Initialize the thread local storage - * Note: Don't copy tdata and tss for idle task to improve footprint - */ + /* Initialize the thread local storage */ - info = up_stack_frame(&g_idletcb[i].cmn, sizeof(struct tls_info_s)); - DEBUGASSERT(info == g_idletcb[i].cmn.stack_alloc_ptr); - info->tl_task = g_idletcb[i].cmn.group->tg_info; + tls_init_info(&g_idletcb[i].cmn); /* Complete initialization of the IDLE group. Suppress retention * of child status in the IDLE group. diff --git a/sched/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c index 368240b7c3a49..a3560801b4b52 100644 --- a/sched/pthread/pthread_cancel.c +++ b/sched/pthread/pthread_cancel.c @@ -30,7 +30,6 @@ #include #include -#include #include #include "sched/sched.h" diff --git a/sched/pthread/pthread_exit.c b/sched/pthread/pthread_exit.c index e63dbc7ff2e2d..3e6ad1fa89511 100644 --- a/sched/pthread/pthread_exit.c +++ b/sched/pthread/pthread_exit.c @@ -35,7 +35,6 @@ #include #include -#include #include "sched/sched.h" #include "task/task.h" diff --git a/sched/task/task_vfork.c b/sched/task/task_vfork.c index a56f8c195d708..1ab640e8958f9 100644 --- a/sched/task/task_vfork.c +++ b/sched/task/task_vfork.c @@ -33,9 +33,6 @@ #include #include -#include -#include - #include "sched/sched.h" #include "environ/environ.h" #include "group/group.h" diff --git a/sched/tls/task_initinfo.c b/sched/tls/task_initinfo.c index 4ccf1e9f7eeaa..0ff904e73fc62 100644 --- a/sched/tls/task_initinfo.c +++ b/sched/tls/task_initinfo.c @@ -26,7 +26,6 @@ #include #include -#include #include "tls.h" diff --git a/sched/tls/task_uninitinfo.c b/sched/tls/task_uninitinfo.c index f4dca8903e395..bd7e028b4b295 100644 --- a/sched/tls/task_uninitinfo.c +++ b/sched/tls/task_uninitinfo.c @@ -24,7 +24,6 @@ #include #include -#include #include "tls.h" diff --git a/sched/tls/tls.h b/sched/tls/tls.h index e9adeacda0e37..2e584b395938c 100644 --- a/sched/tls/tls.h +++ b/sched/tls/tls.h @@ -26,11 +26,29 @@ ****************************************************************************/ #include +#include /**************************************************************************** * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: up_tls_size + * + * Description: + * Get TLS (sizeof(struct tls_info_s) + tdata + tbss) section size. + * + * Returned Value: + * Size of (sizeof(struct tls_info_s) + tdata + tbss). + * + ****************************************************************************/ + +#ifdef CONFIG_SCHED_THREAD_LOCAL +# define tls_info_size() up_tls_size() +#else +# define tls_info_size() sizeof(struct tls_info_s) +#endif + /**************************************************************************** * Name: task_init_info * diff --git a/sched/tls/tls_dupinfo.c b/sched/tls/tls_dupinfo.c index a22efd3d0c599..b8c0dda3bb698 100644 --- a/sched/tls/tls_dupinfo.c +++ b/sched/tls/tls_dupinfo.c @@ -26,9 +26,6 @@ #include #include -#include -#include - #include "tls.h" /**************************************************************************** @@ -56,7 +53,7 @@ int tls_dup_info(FAR struct tcb_s *dst, FAR struct tcb_s *src) /* Allocate thread local storage */ - info = up_stack_frame(dst, up_tls_size()); + info = up_stack_frame(dst, tls_info_size()); if (info == NULL) { return -ENOMEM; @@ -66,7 +63,7 @@ int tls_dup_info(FAR struct tcb_s *dst, FAR struct tcb_s *src) /* Copy thread local storage */ - memcpy(info, src->stack_alloc_ptr, sizeof(struct tls_info_s)); + memcpy(info, src->stack_alloc_ptr, tls_info_size()); /* Attach per-task info in group to TLS */ diff --git a/sched/tls/tls_initinfo.c b/sched/tls/tls_initinfo.c index 0b7e08ab996d0..78ac2a1dc8a16 100644 --- a/sched/tls/tls_initinfo.c +++ b/sched/tls/tls_initinfo.c @@ -25,9 +25,6 @@ #include #include -#include -#include - #include "tls.h" /**************************************************************************** @@ -54,7 +51,7 @@ int tls_init_info(FAR struct tcb_s *tcb) /* Allocate thread local storage */ - info = up_stack_frame(tcb, up_tls_size()); + info = up_stack_frame(tcb, tls_info_size()); if (info == NULL) { return -ENOMEM;