1 //===------- Linux implementation of the remap_file_pages function --------===//
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
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
,
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
);
27 #error "remap_file_pages syscall is not available."
30 // A negative return value indicates an error with the magnitude of the
31 // value being the error code.
40 } // namespace LIBC_NAMESPACE_DECL