pstore2
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
pstore::memory_mapper_base Class Referenceabstract
Inheritance diagram for pstore::memory_mapper_base:
Inheritance graph
[legend]

Public Member Functions

 memory_mapper_base (memory_mapper_base &&) noexcept=default
 
 memory_mapper_base (memory_mapper_base const &)=default
 
memory_mapper_baseoperator= (memory_mapper_base &&) noexcept=default
 
memory_mapper_baseoperator= (memory_mapper_base const &)=default
 
bool is_writable () const
 Returns true if the memory is to be writable. More...
 
std::uint64_t offset () const
 Returns the file offset of the start of the memory represented by this object.
 
std::uint64_t size () const
 Returns the size of the memory region owned by this object.
 
std::uint64_t end () const
 A convenience method which returns the file offset of the end of the memory represented by this object. More...
 
virtual void read_only (void *addr, std::size_t len)
 Marks the range of addresses given by addr and len as read-only. More...
 
std::shared_ptr< void > const & data ()
 Returns the base address of this memory-mapped region. More...
 
std::shared_ptr< void const > data () const
 

Static Public Member Functions

static unsigned long page_size (system_page_size_interface const &intf)
 

Protected Member Functions

 memory_mapper_base (std::shared_ptr< void > ptr, bool const is_writable, std::uint64_t const offset, std::uint64_t const size)
 

Constructor & Destructor Documentation

◆ memory_mapper_base()

pstore::memory_mapper_base::memory_mapper_base ( std::shared_ptr< void >  ptr,
bool const  is_writable,
std::uint64_t const  offset,
std::uint64_t const  size 
)
inlineprotected
Parameters
ptrA pointer to the mapped memory.
is_writableIf the mapped memory writeable? If true, then the underlying file, as given by the 'file' parameters, must be writable.
offsetThe starting offset within the container for the mapped region.
sizeThe number of mapped bytes.

Member Function Documentation

◆ data()

std::shared_ptr<void> const& pstore::memory_mapper_base::data ( )
inline

Returns the base address of this memory-mapped region.

Returns nullptr if unmap() has been called.

◆ end()

std::uint64_t pstore::memory_mapper_base::end ( ) const
inline

A convenience method which returns the file offset of the end of the memory represented by this object.

◆ is_writable()

bool pstore::memory_mapper_base::is_writable ( ) const
inline

Returns true if the memory is to be writable.

Note
The operating system may separately protect memory pages, so it's perfectly likely that a memory page may be read-only even if this method returns true.

◆ read_only()

void pstore::memory_mapper_base::read_only ( void *  addr,
std::size_t  len 
)
virtual

Marks the range of addresses given by addr and len as read-only.

This function validates the input parameter before calling read_only_impl() which is responsible for calling the real OS API.

Parameters
addrA pointer that describes the starting page of the region of pages whose protection attributes are to be changed.
lenThe size of the region whose protection attributes are to be changed
Note
The function is virtual for mocking.

The documentation for this class was generated from the following files: