brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · c891f03 Raw
33 lines · cpp
1//===---------- Linux implementation of the POSIX mprotect 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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/sys/mman/mprotect.h"10 11#include "src/__support/OSUtil/syscall.h" // For internal syscall function.12#include "src/__support/common.h"13 14#include "src/__support/error_or.h"15#include "src/__support/libc_errno.h"16#include "src/__support/macros/config.h"17#include "src/sys/mman/linux/mprotect_common.h"18#include <sys/syscall.h> // For syscall numbers.19 20namespace LIBC_NAMESPACE_DECL {21 22LLVM_LIBC_FUNCTION(int, mprotect, (void *addr, size_t size, int prot)) {23  ErrorOr<int> result =24      LIBC_NAMESPACE::mprotect_common::mprotect_impl(addr, size, prot);25  if (!result.has_value()) {26    libc_errno = result.error();27    return -1;28  }29  return result.value();30}31 32} // namespace LIBC_NAMESPACE_DECL33