Path: blob/main/contrib/llvm-project/compiler-rt/lib/scudo/standalone/mem_map_fuchsia.h
35291 views
//===-- mem_map_fuchsia.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_FUCHSIA_H_9#define SCUDO_MEM_MAP_FUCHSIA_H_1011#include "mem_map_base.h"1213#if SCUDO_FUCHSIA1415#include <stdint.h>16#include <zircon/types.h>1718namespace scudo {1920class MemMapFuchsia final : public MemMapBase<MemMapFuchsia> {21public:22constexpr MemMapFuchsia() = default;2324// Impls for base functions.25bool mapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);26void unmapImpl(uptr Addr, uptr Size);27bool remapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);28void setMemoryPermissionImpl(uptr Addr, uptr Size, uptr Flags);29void releasePagesToOSImpl(uptr From, uptr Size) {30return releaseAndZeroPagesToOSImpl(From, Size);31}32void releaseAndZeroPagesToOSImpl(uptr From, uptr Size);33uptr getBaseImpl() { return WindowBase; }34uptr getCapacityImpl() { return WindowSize; }3536private:37friend class ReservedMemoryFuchsia;3839// Used by ReservedMemoryFuchsia::dispatch.40MemMapFuchsia(uptr Base, uptr Capacity);4142// Virtual memory address corresponding to VMO offset 0.43uptr MapAddr = 0;4445// Virtual memory base address and size of the VMO subrange that is still in46// use. unmapImpl() can shrink this range, either at the beginning or at the47// end.48uptr WindowBase = 0;49uptr WindowSize = 0;5051zx_handle_t Vmo = ZX_HANDLE_INVALID;52};5354class ReservedMemoryFuchsia final55: public ReservedMemory<ReservedMemoryFuchsia, MemMapFuchsia> {56public:57constexpr ReservedMemoryFuchsia() = default;5859bool createImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);60void releaseImpl();61MemMapT dispatchImpl(uptr Addr, uptr Size);62uptr getBaseImpl() { return Base; }63uptr getCapacityImpl() { return Capacity; }6465private:66uptr Base = 0;67uptr Capacity = 0;68};6970} // namespace scudo7172#endif // SCUDO_FUCHSIA7374#endif // SCUDO_MEM_MAP_FUCHSIA_H_757677