no1wudi commented on a change in pull request #3626:
URL: https://github.com/apache/incubator-nuttx/pull/3626#discussion_r623106058
##########
File path: libs/libc/pthread/pthread_create.c
##########
@@ -24,70 +24,68 @@
#include <nuttx/config.h>
-#include <pthread.h>
-#include <assert.h>
+#include <debug.h>
-#include <nuttx/userspace.h>
-
-#if !defined(CONFIG_BUILD_FLAT) && !defined(__KERNEL__)
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
+#include <nuttx/pthread.h>
/****************************************************************************
- * Private Type Declarations
+ * Private Functions
****************************************************************************/
/****************************************************************************
- * Public Data
+ * Name: pthread_startup
+ *
+ * Description:
+ * This function is the user space pthread startup function. Its purpose
+ * is to catch the return from the pthread main function so that
+ * pthread_exit() can be called from user space
+ *
+ * Input Parameters:
+ * entry - The user-space address of the pthread entry point
+ * arg - Standard argument for the pthread entry point
+ *
+ * Returned Value:
+ * None. This function does not return.
+ *
****************************************************************************/
-/****************************************************************************
- * Private Data
- ****************************************************************************/
+static void pthread_startup(pthread_startroutine_t entry,
+ pthread_addr_t arg)
+{
+ DEBUGASSERT(entry != NULL);
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
+ /* Pass control to the thread entry point. Handle any returned value. */
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
+ pthread_exit(entry(arg));
+}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: pthread_startup
+ * Name: pthread_create
Review comment:
I will fix the document issue later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]