This is an automated email from the ASF dual-hosted git repository. gnutt pushed a commit to branch feature/pthread-user in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/feature/pthread-user by this push: new f2f7990 pthread: Adds typedef pthread_trampoline_t and fixes other build errors. f2f7990 is described below commit f2f7990a008e10e4c4a5450a7708ad344bef9908 Author: Anthony Merlino <anth...@vergeaero.com> AuthorDate: Wed Jul 1 15:37:26 2020 -0400 pthread: Adds typedef pthread_trampoline_t and fixes other build errors. --- include/nuttx/pthread.h | 4 ++-- include/nuttx/sched.h | 2 +- include/pthread.h | 2 ++ include/sys/syscall_lookup.h | 2 +- libs/libc/pthread/pthread_create.c | 4 +++- sched/pthread/pthread_create.c | 39 +++++++++++++++++++------------------- syscall/syscall.csv | 2 +- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h index f1a227d..8f33946 100644 --- a/include/nuttx/pthread.h +++ b/include/nuttx/pthread.h @@ -129,7 +129,7 @@ EXTERN const pthread_attr_t g_default_pthread_attr; * attributes. * * Input Parameters: - * startup + * trampoline * thread * attr * pthread_entry @@ -141,7 +141,7 @@ EXTERN const pthread_attr_t g_default_pthread_attr; * ****************************************************************************/ -int nx_pthread_create(pthread_startroutine_t startup, FAR pthread_t *thread, +int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, FAR const pthread_attr_t *attr, pthread_startroutine_t entry, pthread_addr_t arg); diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 6af52a1..a68ccec 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -800,7 +800,7 @@ struct pthread_tcb_s /* Task Management Fields *****************************************************/ - pthread_startroutine_t startup; /* User-space pthread startup function */ + pthread_trampoline_t trampoline; /* User-space pthread startup function */ pthread_addr_t arg; /* Startup argument */ FAR void *joininfo; /* Detach-able info to support join */ }; diff --git a/include/pthread.h b/include/pthread.h index 5832750..5b43f9c 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -220,6 +220,8 @@ typedef FAR void *pthread_addr_t; typedef CODE pthread_addr_t (*pthread_startroutine_t)(pthread_addr_t); typedef pthread_startroutine_t pthread_func_t; +typedef void (*pthread_trampoline_t)(pthread_startroutine_t, pthread_addr_t); + struct pthread_attr_s { uint8_t priority; /* Priority of the pthread */ diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h index f5b5758..3a2b7b6 100644 --- a/include/sys/syscall_lookup.h +++ b/include/sys/syscall_lookup.h @@ -296,7 +296,7 @@ SYSCALL_LOOKUP(telldir, 1) SYSCALL_LOOKUP(pthread_cond_broadcast, 1) SYSCALL_LOOKUP(pthread_cond_signal, 1) SYSCALL_LOOKUP(pthread_cond_wait, 2) - SYSCALL_LOOKUP(nx_pthread_create, 4) + SYSCALL_LOOKUP(nx_pthread_create, 5) SYSCALL_LOOKUP(pthread_detach, 1) SYSCALL_LOOKUP(pthread_exit, 1) SYSCALL_LOOKUP(pthread_getschedparam, 3) diff --git a/libs/libc/pthread/pthread_create.c b/libs/libc/pthread/pthread_create.c index d091333..e81c63e 100644 --- a/libs/libc/pthread/pthread_create.c +++ b/libs/libc/pthread/pthread_create.c @@ -24,7 +24,9 @@ #include <nuttx/config.h> -#include <pthread.h> +#include <debug.h> + +#include <nuttx/pthread.h> /**************************************************************************** * Private Functions diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index 4768f43..1eb2234 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -84,31 +84,32 @@ static const char g_pthreadname[] = "<pthread>"; * boolean argument). * * Input Parameters: - * tcb - Address of the new task's TCB - * startup - User space pthread startup function - * arg - The argument to provide to the pthread on startup. + * tcb - Address of the new task's TCB + * trampoline - User space pthread startup function + * arg - The argument to provide to the pthread on startup. * * Returned Value: * None * ****************************************************************************/ -static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *tcb, +static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *ptcb, + pthread_trampoline_t trampoline, pthread_addr_t arg) { #if CONFIG_TASK_NAME_SIZE > 0 /* Copy the pthread name into the TCB */ - strncpy(tcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE); - tcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; + strncpy(ptcb->cmn.name, g_pthreadname, CONFIG_TASK_NAME_SIZE); + ptcb->cmn.name[CONFIG_TASK_NAME_SIZE] = '\0'; #endif /* CONFIG_TASK_NAME_SIZE */ /* For pthreads, args are strictly pass-by-value; that actual * type wrapped by pthread_addr_t is unknown. */ - tcb->startup = startup; - tcb->arg = arg; + ptcb->trampoline = trampoline; + ptcb->arg = arg; } /**************************************************************************** @@ -160,7 +161,6 @@ static void pthread_start(void) FAR struct pthread_tcb_s *ptcb = (FAR struct pthread_tcb_s *)this_task(); FAR struct task_group_s *group = ptcb->cmn.group; FAR struct join_s *pjoin = (FAR struct join_s *)ptcb->joininfo; - pthread_addr_t exit_status; DEBUGASSERT(group != NULL && pjoin != NULL); @@ -190,19 +190,18 @@ static void pthread_start(void) * to switch to user-mode before calling into the pthread. */ - DEBUGASSERT(ptcb->startup != NULL && ptcb->cmn.entry.pthread != NULL); + DEBUGASSERT(ptcb->trampoline != NULL && ptcb->cmn.entry.pthread != NULL); #ifdef CONFIG_BUILD_FLAT - exit_status = ptcb->startup(ptcb->cmn.entry.pthread, ptcb->arg); + ptcb->trampoline(ptcb->cmn.entry.pthread, ptcb->arg); #else - up_pthread_start(ptcb->startup, ptcb->cmn.entry.pthread, ptcb->arg); - exit_status = NULL; + up_pthread_start(ptcb->trampoline, ptcb->cmn.entry.pthread, ptcb->arg); #endif /* The thread has returned (should never happen) */ DEBUGPANIC(); - pthread_exit(exit_status); + pthread_exit(NULL); } /**************************************************************************** @@ -217,7 +216,7 @@ static void pthread_start(void) * attributes. * * Input Parameters: - * startup + * trampoline * thread * attr * start_routine @@ -229,9 +228,9 @@ static void pthread_start(void) * ****************************************************************************/ -int nx_pthread_create(pthread_startroutine_t startup, FAR pthread_t *thread, +int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread, FAR const pthread_attr_t *attr, - pthread_startroutine_t entry, pthread_addr_t arg); + pthread_startroutine_t entry, pthread_addr_t arg) { FAR struct pthread_tcb_s *ptcb; FAR struct join_s *pjoin; @@ -242,7 +241,7 @@ int nx_pthread_create(pthread_startroutine_t startup, FAR pthread_t *thread, int ret; bool group_joined = false; - DEBUGASSERT(startup != NULL); + DEBUGASSERT(trampoline != NULL); /* If attributes were not supplied, use the default attributes */ @@ -414,7 +413,7 @@ int nx_pthread_create(pthread_startroutine_t startup, FAR pthread_t *thread, /* Initialize the task control block */ ret = pthread_setup_scheduler(ptcb, param.sched_priority, pthread_start, - start_routine); + entry); if (ret != OK) { errcode = EBUSY; @@ -439,7 +438,7 @@ int nx_pthread_create(pthread_startroutine_t startup, FAR pthread_t *thread, * passed by value */ - pthread_tcb_setup(ptcb, startup, arg); + pthread_tcb_setup(ptcb, trampoline, arg); /* Join the parent's task group */ diff --git a/syscall/syscall.csv b/syscall/syscall.csv index 64b51ca..a161cea 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -63,7 +63,7 @@ "munmap","sys/mman.h","defined(CONFIG_FS_RAMMAP)","int","FAR void *","size_t" "nx_mkfifo","nuttx/drivers/drivers.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char *","mode_t","size_t" "nx_pipe","nuttx/drivers/drivers.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|FAR int *","size_t" -"nx_pthread_create","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_t *","pthread_startroutine_t","FAR const pthread_attr_t *","pthread_startroutine_t","pthread_addr_t" +"nx_pthread_create","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_trampoline_t","FAR pthread_t *","FAR const pthread_attr_t *","pthread_startroutine_t","pthread_addr_t" "nx_task_spawn","nuttx/spawn.h","defined(CONFIG_LIB_SYSCALL) && !defined(CONFIG_BUILD_KERNEL)","int","FAR const struct spawn_syscall_parms_s *" "nx_vsyslog","nuttx/syslog/syslog.h","","int","int","FAR const IPTR char *","FAR va_list *" "on_exit","stdlib.h","defined(CONFIG_SCHED_ONEXIT)","int","CODE void (*)(int, FAR void *)","FAR void *"