1. add lib_fork api in libs/libc, we need a fork() api to implement the fork relative method, such as pthread_atfork 2. rename the assembly fork entry function name to up_fork(), and rename the up_fork() to arch specific name, such as sim_fork()/arm_fork()/mips_fork() etc. Signed-off-by: guoshichao <guoshichao@xiaomi.com>
59 lines
2.0 KiB
C
59 lines
2.0 KiB
C
/****************************************************************************
|
|
* libs/libc/unistd/lib_fork.c
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
#include <nuttx/arch.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#if defined(CONFIG_ARCH_HAVE_FORK)
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: fork
|
|
*
|
|
* Description:
|
|
* The fork() function is a wrapper of up_fork() syscall
|
|
*
|
|
* Returned Value:
|
|
* Upon successful completion, fork() returns 0 to the child process and
|
|
* returns the process ID of the child process to the parent process.
|
|
* Otherwise, -1 is returned to the parent, no child process is created,
|
|
* and errno is set to indicate the error.
|
|
*
|
|
****************************************************************************/
|
|
|
|
pid_t fork(void)
|
|
{
|
|
pid_t pid;
|
|
pid = up_fork();
|
|
|
|
return pid;
|
|
}
|
|
|
|
#endif /* CONFIG_ARCH_HAVE_FORK */
|