168d75effSDimitry Andric //===-- sanitizer_mac_libcdep.cpp -----------------------------------------===// 268d75effSDimitry Andric // 368d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 468d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 568d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 668d75effSDimitry Andric // 768d75effSDimitry Andric //===----------------------------------------------------------------------===// 868d75effSDimitry Andric // 968d75effSDimitry Andric // This file is shared between various sanitizers' runtime libraries and 1068d75effSDimitry Andric // implements OSX-specific functions. 1168d75effSDimitry Andric //===----------------------------------------------------------------------===// 1268d75effSDimitry Andric 1368d75effSDimitry Andric #include "sanitizer_platform.h" 14*81ad6265SDimitry Andric #if SANITIZER_APPLE 1568d75effSDimitry Andric #include "sanitizer_mac.h" 1668d75effSDimitry Andric 1768d75effSDimitry Andric #include <sys/mman.h> 1868d75effSDimitry Andric 1968d75effSDimitry Andric namespace __sanitizer { 2068d75effSDimitry Andric RestrictMemoryToMaxAddress(uptr max_address)2168d75effSDimitry Andricvoid RestrictMemoryToMaxAddress(uptr max_address) { 2268d75effSDimitry Andric uptr size_to_mmap = GetMaxUserVirtualAddress() + 1 - max_address; 2368d75effSDimitry Andric void *res = MmapFixedNoAccess(max_address, size_to_mmap, "high gap"); 2468d75effSDimitry Andric CHECK(res != MAP_FAILED); 2568d75effSDimitry Andric } 2668d75effSDimitry Andric 2768d75effSDimitry Andric } // namespace __sanitizer 2868d75effSDimitry Andric 29*81ad6265SDimitry Andric #endif // SANITIZER_APPLE 30