xiaoxiang781216 commented on a change in pull request #3517:
URL: https://github.com/apache/incubator-nuttx/pull/3517#discussion_r612099566



##########
File path: arch/risc-v/src/rv32im/riscv_vfork.c
##########
@@ -150,39 +148,18 @@ pid_t up_vfork(const struct vfork_s *context)
 
   sinfo("Parent=%p Child=%p\n", parent, child);
 
-  /* Get the size of the parent task's stack.  Due to alignment operations,
-   * the adjusted stack size may be smaller than the stack size originally
-   * requested.
-   */
-
-  stacksize = parent->adj_stack_size + CONFIG_STACK_ALIGNMENT - 1;
-
-  /* Allocate the stack for the TCB */
-
-  ret = up_create_stack((FAR struct tcb_s *)child, stacksize + argsize,
-                        parent->flags & TCB_FLAG_TTYPE_MASK);
-  if (ret != OK)
-    {
-      serr("ERROR: up_create_stack failed: %d\n", ret);
-      nxtask_abort_vfork(child, -ret);
-      return (pid_t)ERROR;
-    }
-
-  /* Allocate the memory and copy argument from parent task */
-
-  argv = up_stack_frame((FAR struct tcb_s *)child, argsize);
-  memcpy(argv, parent->adj_stack_ptr, argsize);
-
   /* How much of the parent's stack was utilized?  The RISC-V uses
    * a push-down stack so that the current stack pointer should
    * be lower than the initial, adjusted stack pointer.  The
    * stack usage should be the difference between those two.
    */
 
-  DEBUGASSERT((uint32_t)parent->adj_stack_ptr > context->sp);
-  stackutil = (uint32_t)parent->adj_stack_ptr - context->sp;
+  stacktop = (uint32_t)parent->adj_stack_ptr +
+                       parent->adj_stack_size;
+  DEBUGASSERT(stacktop > context->sp);
+  stackutil = stacktop - context->sp;
 
-  sinfo("stacksize:%d stackutil:%d\n", stacksize, stackutil);
+  sinfo("stackutil:%u\n", stackutil);

Review comment:
       Done.




-- 
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:
us...@infra.apache.org


Reply via email to