13f965818SSiva Chandra Reddy //===-- Linux implementation of execv -------------------------------------===// 23f965818SSiva Chandra Reddy // 33f965818SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 43f965818SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 53f965818SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 63f965818SSiva Chandra Reddy // 73f965818SSiva Chandra Reddy //===----------------------------------------------------------------------===// 83f965818SSiva Chandra Reddy 93f965818SSiva Chandra Reddy #include "src/unistd/execv.h" 10*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 113f965818SSiva Chandra Reddy #include "src/unistd/environ.h" 123f965818SSiva Chandra Reddy 133f965818SSiva Chandra Reddy #include "src/__support/OSUtil/syscall.h" // For internal syscall function. 143f965818SSiva Chandra Reddy #include "src/__support/common.h" 153f965818SSiva Chandra Reddy 16803437dbSMichael Jones #include "src/errno/libc_errno.h" 173f965818SSiva Chandra Reddy #include <sys/syscall.h> // For syscall numbers. 183f965818SSiva Chandra Reddy 19*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 203f965818SSiva Chandra Reddy 213f965818SSiva Chandra Reddy LLVM_LIBC_FUNCTION(int, execv, (const char *path, char *const argv[])) { 22b6bc9d72SGuillaume Chatelet int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_execve, path, argv, 23b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::environ); 243f965818SSiva Chandra Reddy if (ret < 0) { 25204587a3SSiva Chandra Reddy libc_errno = -ret; 263f965818SSiva Chandra Reddy return -1; 273f965818SSiva Chandra Reddy } 283f965818SSiva Chandra Reddy 293f965818SSiva Chandra Reddy // Control will not reach here on success but have a return statement will 303f965818SSiva Chandra Reddy // keep the compilers happy. 313f965818SSiva Chandra Reddy return ret; 323f965818SSiva Chandra Reddy } 333f965818SSiva Chandra Reddy 34*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 35