[Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (#121656)
[llvm-project.git] / libc / src / sys / mman / linux / remap_file_pages.cpp
blobf616e1915ecc5e88293a0c95943c252acbf0c087
1 //===------- Linux implementation of the remap_file_pages function --------===//
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/sys/mman/remap_file_pages.h"
11 #include "src/__support/OSUtil/syscall.h" // For internal syscall function.
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 #include "src/errno/libc_errno.h"
15 #include <sys/syscall.h> // For syscall numbers.
17 namespace LIBC_NAMESPACE_DECL {
19 LLVM_LIBC_FUNCTION(int, remap_file_pages,
20 (void *addr, size_t size, int prot, size_t pgoff,
21 int flags)) {
22 #ifdef SYS_remap_file_pages
23 int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_remap_file_pages,
24 reinterpret_cast<long>(addr),
25 size, prot, pgoff, flags);
26 #else
27 #error "remap_file_pages syscall is not available."
28 #endif
30 // A negative return value indicates an error with the magnitude of the
31 // value being the error code.
32 if (ret < 0) {
33 libc_errno = -ret;
34 return -1;
37 return 0;
40 } // namespace LIBC_NAMESPACE_DECL