3#include <mutable/mutable-config.hpp>
29 int fd()
const {
return fd_; }
39 Memory create_memory(
void *addr, std::size_t size, std::size_t offset);
65 void *
addr()
const {
return addr_; }
67 std::size_t
size()
const {
return size_; }
71 T as()
const {
return reinterpret_cast<T>(addr()); }
83 void *addr_ =
nullptr;
84 std::size_t size_ = 0;
85 std::size_t offset_ = 0;
99 Memory(
void *addr, std::size_t size) : addr_(addr), size_(size) { }
109 void *
addr()
const {
return addr_; }
111 std::size_t
size()
const {
return size_; }
113 std::size_t
offset()
const {
return offset_; }
118 T as() {
return reinterpret_cast<T>(addr()); }
122 const T as()
const {
return reinterpret_cast<T>(addr()); }
125 void map(std::size_t size, std::size_t offset_src,
const AddressSpace &vm, std::size_t offset_dst)
const;
127 void dump(std::ostream &out)
const;
141 std::size_t offset_ = 0;
150 Memory allocate(std::size_t size)
override;
153 std::size_t
offset()
const {
return offset_; }
156 void deallocate(
Memory &&mem)
override;
void swap(PlanTableBase< Actual > &first, PlanTableBase< Actual > &second)
void deallocate(void *ptr, size_type size)
Deallocate the allocation at ptr of size size.
This class represents a reserved address space in virtual memory.
void * addr_
pointer to the beginning of the virtual address space
AddressSpace(const AddressSpace &)=delete
std::size_t size_
size in bytes of the address space
T as() const
Get a pointer to the beginning of the virtual address space, converted to type T.
void * addr() const
Returns a pointer to the beginning of the virtual address space.
std::size_t size() const
Returns the size in bytes of the virtual address space.
AddressSpace(AddressSpace &&other)
friend void swap(AddressSpace &first, AddressSpace &second)
This is the common interface for all memory allocators that support rewiring.
int fd_
file descriptor of the underlying memory file
virtual void deallocate(Memory &&mem)=0
Deallocates a memory object.
virtual Memory allocate(std::size_t size)=0
Creates a new memory object with size bytes of freshly allocated memory.
int fd() const
Return the file descriptor of the underlying memory file.
This is the simplest kind of allocator.
std::vector< std::size_t > allocations_
stack of allocations; allocations can be marked deallocated for later reclaiming
std::size_t offset() const
Returns the offset in the underlying memory file where the next allocation is placed.
Represents a mapping created by a memory::Allocator.
void * addr_
pointer to the virtual address space where this allocation is mapped to
friend void swap(Memory &first, Memory &second)
T as()
Returns a pointer to the beginning of the virtual address space where this allocation is mapped to,...
void * addr() const
Returns a pointer to the beginning of the virtual address space where this allocation is mapped to.
Memory(void *addr, std::size_t size)
Memory(const Memory &)=delete
std::size_t size_
the size of this allocation
Memory & operator=(Memory &&other)
std::size_t offset() const
Returns the offset in bytes of this allocation within its allocator.
Allocator * allocator_
the allocator that created this memory allocation
Allocator & allocator() const
Returns a reference to the allocator that created this allocation.
std::size_t size() const
Returns the size in bytes of this allocation.
std::size_t offset_
the offset of this allocation within its allocator
const T as() const
Returns a pointer to the beginning of the virtual address space where this allocation is mapped to,...