From 11c8f3125dadebd183d1add32e615d5292ccaff7 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 5 Jun 2022 19:17:33 +0800 Subject: [PATCH] sched/tls: Wrap up_info_size into tls_info_size Signed-off-by: Xiang Xiao --- include/nuttx/arch.h | 2 -- libs/libc/tls/tls_getinfo.c | 1 - libs/libc/unistd/lib_getoptvars.c | 3 --- sched/group/group_leave.c | 1 - sched/pthread/pthread_cancel.c | 1 - sched/pthread/pthread_exit.c | 1 - sched/task/task_vfork.c | 3 --- sched/tls/task_initinfo.c | 1 - sched/tls/task_uninitinfo.c | 1 - sched/tls/tls.h | 18 ++++++++++++++++++ sched/tls/tls_dupinfo.c | 7 ++----- sched/tls/tls_initinfo.c | 5 +---- 12 files changed, 21 insertions(+), 23 deletions(-) diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index ca4962ba88..302767b5cd 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 68b580a932..faeb3da96b 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 cc0fde2cd5..49f3b6a559 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 d4bda7d599..fa203f69ca 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/pthread/pthread_cancel.c b/sched/pthread/pthread_cancel.c index 368240b7c3..a3560801b4 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 e63dbc7ff2..3e6ad1fa89 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 a56f8c195d..1ab640e895 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 4ccf1e9f7e..0ff904e73f 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 f4dca8903e..bd7e028b4b 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 e9adeacda0..2e584b3959 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 a22efd3d0c..b8c0dda3bb 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 0b7e08ab99..78ac2a1dc8 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;