xref: /freebsd/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_mac_libcdep.cpp (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1 //===-- sanitizer_mac_libcdep.cpp -----------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is shared between various sanitizers' runtime libraries and
10 // implements OSX-specific functions.
11 //===----------------------------------------------------------------------===//
12 
13 #include "sanitizer_platform.h"
14 #if SANITIZER_APPLE
15 #include "sanitizer_mac.h"
16 
17 #include <sys/mman.h>
18 
19 namespace __sanitizer {
20 
RestrictMemoryToMaxAddress(uptr max_address)21 void RestrictMemoryToMaxAddress(uptr max_address) {
22   uptr size_to_mmap = GetMaxUserVirtualAddress() + 1 - max_address;
23   void *res = MmapFixedNoAccess(max_address, size_to_mmap, "high gap");
24   CHECK(res != MAP_FAILED);
25 }
26 
27 }  // namespace __sanitizer
28 
29 #endif  // SANITIZER_APPLE
30