You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2021/03/25 16:36:49 UTC
[incubator-nuttx] 03/03: pthread: Adds typedef pthread_trampoline_t
and fixes other build errors.
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
commit e79a731bcf67363dc5a926c08e725b7b51333de7
Author: Anthony Merlino <an...@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/Make.defs | 6 ++++++
libs/libc/pthread/pthread_create.c | 4 +++-
sched/pthread/pthread_create.c | 35 +++++++++++++++++------------------
syscall/syscall.csv | 2 +-
8 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h
index 59398c9..43df89d 100644
--- a/include/nuttx/pthread.h
+++ b/include/nuttx/pthread.h
@@ -133,7 +133,7 @@ EXTERN const pthread_attr_t g_default_pthread_attr;
* attributes.
*
* Input Parameters:
- * startup
+ * trampoline
* thread
* attr
* pthread_entry
@@ -145,7 +145,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 0fab6b3..b78e574 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -768,7 +768,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 1474f93..fb8a458 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -225,6 +225,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 8128776..c3f3dea 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -305,7 +305,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/Make.defs b/libs/libc/pthread/Make.defs
index c625afa..3cdf77e 100644
--- a/libs/libc/pthread/Make.defs
+++ b/libs/libc/pthread/Make.defs
@@ -38,6 +38,8 @@ CSRCS += pthread_barrierattr_init.c pthread_barrierattr_destroy.c
CSRCS += pthread_barrierattr_getpshared.c pthread_barrierattr_setpshared.c
CSRCS += pthread_barrierinit.c pthread_barrierdestroy.c pthread_barrierwait.c
CSRCS += pthread_condattr_init.c pthread_condattr_destroy.c
+CSRCS += pthread_condattr_setclock.c pthread_condattr_getclock.c
+CSRCS += pthread_condinit.c pthread_conddestroy.c pthread_condtimedwait.c
CSRCS += pthread_create.c
CSRCS += pthread_get_stackaddr_np.c pthread_get_stacksize_np.c
CSRCS += pthread_mutexattr_init.c pthread_mutexattr_destroy.c
@@ -59,6 +61,10 @@ ifeq ($(CONFIG_PTHREAD_SPINLOCKS),y)
CSRCS += pthread_spinlock.c
endif
+ifeq ($(CONFIG_BUILD_PROTECTED),y)
+CSRCS += pthread_startup.c
+endif
+
endif # CONFIG_DISABLE_PTHREAD
# Add the pthread directory to the build
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 58ef313..dfd7859 100644
--- a/sched/pthread/pthread_create.c
+++ b/sched/pthread/pthread_create.c
@@ -75,16 +75,17 @@ const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER;
* 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
@@ -98,8 +99,8 @@ static inline void pthread_tcb_setup(FAR struct pthread_tcb_s *tcb,
* type wrapped by pthread_addr_t is unknown.
*/
- tcb->startup = startup;
- tcb->arg = arg;
+ ptcb->trampoline = trampoline;
+ ptcb->arg = arg;
}
/****************************************************************************
@@ -151,7 +152,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);
@@ -181,19 +181,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);
}
/****************************************************************************
@@ -208,7 +207,7 @@ static void pthread_start(void)
* attributes.
*
* Input Parameters:
- * startup
+ * trampoline
* thread
* attr
* start_routine
@@ -220,9 +219,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;
@@ -233,7 +232,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 */
@@ -410,7 +409,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;
@@ -435,7 +434,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 93766a9..a032259 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -66,7 +66,7 @@
"munmap","sys/mman.h","defined(CONFIG_FS_RAMMAP)","int","FAR void *","size_t"
"nx_mkfifo","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0","int","FAR const char *","mode_t","size_t"
"nx_pipe","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0","int","int [2]|FAR int *","size_t","int"
-"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 *"
"nxsched_get_stackinfo","nuttx/sched.h","","int","pid_t","FAR struct stackinfo_s *"