1fe1645e2SSchrodinger ZHU Yifan //===---------- Linux implementation of the msync function ----------------===// 2fe1645e2SSchrodinger ZHU Yifan // 3fe1645e2SSchrodinger ZHU Yifan // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4fe1645e2SSchrodinger ZHU Yifan // See https://llvm.org/LICENSE.txt for license information. 5fe1645e2SSchrodinger ZHU Yifan // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6fe1645e2SSchrodinger ZHU Yifan // 7fe1645e2SSchrodinger ZHU Yifan //===----------------------------------------------------------------------===// 8fe1645e2SSchrodinger ZHU Yifan 9fe1645e2SSchrodinger ZHU Yifan #include "src/sys/mman/msync.h" 10fe1645e2SSchrodinger ZHU Yifan 11fe1645e2SSchrodinger ZHU Yifan #include "src/__support/OSUtil/syscall.h" // For internal syscall function. 12fe1645e2SSchrodinger ZHU Yifan 13*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 14fe1645e2SSchrodinger ZHU Yifan #include "src/errno/libc_errno.h" 15fe1645e2SSchrodinger ZHU Yifan #include <sys/syscall.h> // For syscall numbers. 16fe1645e2SSchrodinger ZHU Yifan 17*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 18fe1645e2SSchrodinger ZHU Yifan LLVM_LIBC_FUNCTION(int, msync, (void *addr, size_t len, int flags)) { 19fe1645e2SSchrodinger ZHU Yifan long ret = syscall_impl(SYS_msync, cpp::bit_cast<long>(addr), len, flags); 20fe1645e2SSchrodinger ZHU Yifan if (ret < 0) { 21fe1645e2SSchrodinger ZHU Yifan libc_errno = static_cast<int>(-ret); 22fe1645e2SSchrodinger ZHU Yifan return -1; 23fe1645e2SSchrodinger ZHU Yifan } 24fe1645e2SSchrodinger ZHU Yifan return 0; 25fe1645e2SSchrodinger ZHU Yifan } 26*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 27