1048041f1SSchrodinger ZHU Yifan //===---------- Linux implementation of the mincore function --------------===// 2048041f1SSchrodinger ZHU Yifan // 3048041f1SSchrodinger ZHU Yifan // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4048041f1SSchrodinger ZHU Yifan // See https://llvm.org/LICENSE.txt for license information. 5048041f1SSchrodinger ZHU Yifan // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6048041f1SSchrodinger ZHU Yifan // 7048041f1SSchrodinger ZHU Yifan //===----------------------------------------------------------------------===// 8048041f1SSchrodinger ZHU Yifan 9048041f1SSchrodinger ZHU Yifan #include "src/sys/mman/mincore.h" 10048041f1SSchrodinger ZHU Yifan 11048041f1SSchrodinger ZHU Yifan #include "src/__support/OSUtil/syscall.h" // For internal syscall function. 12048041f1SSchrodinger ZHU Yifan 13*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 14048041f1SSchrodinger ZHU Yifan #include "src/errno/libc_errno.h" 15048041f1SSchrodinger ZHU Yifan #include <sys/syscall.h> // For syscall numbers. 16048041f1SSchrodinger ZHU Yifan 17*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 18048041f1SSchrodinger ZHU Yifan 19048041f1SSchrodinger ZHU Yifan LLVM_LIBC_FUNCTION(int, mincore, (void *addr, size_t len, unsigned char *vec)) { 20048041f1SSchrodinger ZHU Yifan long ret = syscall_impl(SYS_mincore, reinterpret_cast<long>(addr), len, 21048041f1SSchrodinger ZHU Yifan reinterpret_cast<long>(vec)); 22048041f1SSchrodinger ZHU Yifan if (ret < 0) { 23048041f1SSchrodinger ZHU Yifan libc_errno = static_cast<int>(-ret); 24048041f1SSchrodinger ZHU Yifan return -1; 25048041f1SSchrodinger ZHU Yifan } 26048041f1SSchrodinger ZHU Yifan return 0; 27048041f1SSchrodinger ZHU Yifan } 28048041f1SSchrodinger ZHU Yifan 29*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 30