Path: blob/main/contrib/llvm-project/compiler-rt/lib/scudo/standalone/mem_map_linux.h
35292 views
//===-- mem_map_linux.h -----------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef SCUDO_MEM_MAP_LINUX_H_9#define SCUDO_MEM_MAP_LINUX_H_1011#include "platform.h"1213#if SCUDO_LINUX1415#include "common.h"16#include "mem_map_base.h"1718namespace scudo {1920class MemMapLinux final : public MemMapBase<MemMapLinux> {21public:22constexpr MemMapLinux() = default;23MemMapLinux(uptr Base, uptr Capacity)24: MapBase(Base), MapCapacity(Capacity) {}2526// Impls for base functions.27bool mapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags = 0);28void unmapImpl(uptr Addr, uptr Size);29bool remapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags = 0);30void setMemoryPermissionImpl(uptr Addr, uptr Size, uptr Flags);31void releasePagesToOSImpl(uptr From, uptr Size) {32return releaseAndZeroPagesToOSImpl(From, Size);33}34void releaseAndZeroPagesToOSImpl(uptr From, uptr Size);35uptr getBaseImpl() { return MapBase; }36uptr getCapacityImpl() { return MapCapacity; }3738private:39uptr MapBase = 0;40uptr MapCapacity = 0;41};4243// This will be deprecated when every allocator has been supported by each44// platform's `MemMap` implementation.45class ReservedMemoryLinux final46: public ReservedMemory<ReservedMemoryLinux, MemMapLinux> {47public:48// The following two are the Impls for function in `MemMapBase`.49uptr getBaseImpl() { return MapBase; }50uptr getCapacityImpl() { return MapCapacity; }5152// These threes are specific to `ReservedMemory`.53bool createImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);54void releaseImpl();55MemMapT dispatchImpl(uptr Addr, uptr Size);5657private:58uptr MapBase = 0;59uptr MapCapacity = 0;60};6162} // namespace scudo6364#endif // SCUDO_LINUX6566#endif // SCUDO_MEM_MAP_LINUX_H_676869