1353944Sdim//===-- sanitizer_mac_libcdep.cpp -----------------------------------------===//
2353944Sdim//
3353944Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353944Sdim// See https://llvm.org/LICENSE.txt for license information.
5353944Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6353944Sdim//
7353944Sdim//===----------------------------------------------------------------------===//
8353944Sdim//
9353944Sdim// This file is shared between various sanitizers' runtime libraries and
10353944Sdim// implements OSX-specific functions.
11353944Sdim//===----------------------------------------------------------------------===//
12353944Sdim
13353944Sdim#include "sanitizer_platform.h"
14353944Sdim#if SANITIZER_MAC
15353944Sdim#include "sanitizer_mac.h"
16353944Sdim
17353944Sdim#include <sys/mman.h>
18353944Sdim
19353944Sdimnamespace __sanitizer {
20353944Sdim
21353944Sdimvoid RestrictMemoryToMaxAddress(uptr max_address) {
22353944Sdim  uptr size_to_mmap = GetMaxUserVirtualAddress() + 1 - max_address;
23353944Sdim  void *res = MmapFixedNoAccess(max_address, size_to_mmap, "high gap");
24353944Sdim  CHECK(res != MAP_FAILED);
25353944Sdim}
26353944Sdim
27353944Sdim}  // namespace __sanitizer
28353944Sdim
29353944Sdim#endif  // SANITIZER_MAC
30