sched/tls: add nxsched_get_stackargs
Thread args have already been saved to stack after the TLS section by nxtask_setup_stackargs. This is to retrieve it for use. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
parent
5a7cf6ccad
commit
1d169fe325
|
@ -219,6 +219,7 @@ struct tls_info_s
|
|||
int16_t tl_cpcount; /* Nested cancellation point count */
|
||||
#endif
|
||||
|
||||
uint16_t tl_size; /* Actual size with alignments */
|
||||
int tl_errno; /* Per-thread error number */
|
||||
};
|
||||
|
||||
|
|
|
@ -393,5 +393,6 @@ bool nxsched_verify_tcb(FAR struct tcb_s *tcb);
|
|||
|
||||
struct tls_info_s; /* Forward declare */
|
||||
FAR struct tls_info_s *nxsched_get_tls(FAR struct tcb_s *tcb);
|
||||
FAR char **nxsched_get_stackargs(FAR struct tcb_s *tcb);
|
||||
|
||||
#endif /* __SCHED_SCHED_SCHED_H */
|
||||
|
|
|
@ -53,3 +53,25 @@ FAR struct tls_info_s *nxsched_get_tls(FAR struct tcb_s *tcb)
|
|||
|
||||
return (FAR struct tls_info_s *)tcb->stack_alloc_ptr;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_get_stackargs
|
||||
*
|
||||
* Description:
|
||||
* Get args from thread's stack w/o security checks. The args are setup in
|
||||
* nxtask_setup_stackargs().
|
||||
*
|
||||
* Input Parameters:
|
||||
* tcb - The tcb to query.
|
||||
*
|
||||
* Returned Value:
|
||||
* Pointer to a list of stack arguments ended by a NULL pointer.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR char **nxsched_get_stackargs(FAR struct tcb_s *tcb)
|
||||
{
|
||||
/* The args data follows the TLS data */
|
||||
|
||||
return (FAR char**)(tcb->stack_alloc_ptr + nxsched_get_tls(tcb)->tl_size);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ int tls_init_info(FAR struct tcb_s *tcb)
|
|||
|
||||
up_tls_initialize(info);
|
||||
|
||||
/* Derive tl_size w/o arch knowledge */
|
||||
|
||||
info->tl_size = tcb->stack_base_ptr - tcb->stack_alloc_ptr;
|
||||
|
||||
/* Attach per-task info in group to TLS */
|
||||
|
||||
info->tl_task = tcb->group->tg_info;
|
||||
|
|
Loading…
Reference in New Issue