#ifndef SCUDO_MEM_MAP_FUCHSIA_H_
#define SCUDO_MEM_MAP_FUCHSIA_H_
#include "mem_map_base.h"
#if SCUDO_FUCHSIA
#include <stdint.h>
#include <zircon/types.h>
namespace scudo {
class MemMapFuchsia final : public MemMapBase<MemMapFuchsia> {
public:
constexpr MemMapFuchsia() = default;
bool mapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);
void unmapImpl(uptr Addr, uptr Size);
bool remapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);
void setMemoryPermissionImpl(uptr Addr, uptr Size, uptr Flags);
void releasePagesToOSImpl(uptr From, uptr Size) {
return releaseAndZeroPagesToOSImpl(From, Size);
}
void releaseAndZeroPagesToOSImpl(uptr From, uptr Size);
uptr getBaseImpl() { return WindowBase; }
uptr getCapacityImpl() { return WindowSize; }
private:
friend class ReservedMemoryFuchsia;
MemMapFuchsia(uptr Base, uptr Capacity);
uptr MapAddr = 0;
uptr WindowBase = 0;
uptr WindowSize = 0;
zx_handle_t Vmo = ZX_HANDLE_INVALID;
};
class ReservedMemoryFuchsia final
: public ReservedMemory<ReservedMemoryFuchsia, MemMapFuchsia> {
public:
constexpr ReservedMemoryFuchsia() = default;
bool createImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);
void releaseImpl();
MemMapT dispatchImpl(uptr Addr, uptr Size);
uptr getBaseImpl() { return Base; }
uptr getCapacityImpl() { return Capacity; }
private:
uptr Base = 0;
uptr Capacity = 0;
};
}
#endif
#endif