[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / unistd / linux / symlink.cpp
blob62a8b80c334a0c7b5accacb7d97a8f20d32c61aa
1 //===-- Linux implementation of symlink -----------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/unistd/symlink.h"
11 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12 #include "src/__support/common.h"
13 #include "src/errno/libc_errno.h"
15 #include <fcntl.h>
16 #include <sys/syscall.h> // For syscall numbers.
18 namespace __llvm_libc {
20 LLVM_LIBC_FUNCTION(int, symlink, (const char *path1, const char *path2)) {
21 #ifdef SYS_symlink
22 long ret = __llvm_libc::syscall_impl(SYS_symlink, path1, path2);
23 #elif defined(SYS_symlinkat)
24 long ret = __llvm_libc::syscall_impl(SYS_symlinkat, path1, AT_FDCWD, path2);
25 #else
26 #error "symlink or symlinkat syscalls not available."
27 #endif
28 if (ret < 0) {
29 libc_errno = -ret;
30 return -1;
32 return ret;
35 } // namespace __llvm_libc