pstore2
Public Member Functions | List of all members
pstore::memory_mapper Class Referencefinal

memory_mapper provides an operating system independent interface for memory mapping of files. More...

#include <memory_mapper.hpp>

Inheritance diagram for pstore::memory_mapper:
Inheritance graph
[legend]
Collaboration diagram for pstore::memory_mapper:
Collaboration graph
[legend]

Public Member Functions

 memory_mapper (file::file_handle &file, bool write_enabled, std::uint64_t offset, std::uint64_t length)
 
- Public Member Functions inherited from pstore::memory_mapper_base
 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
 

Additional Inherited Members

- Static Public Member Functions inherited from pstore::memory_mapper_base
static unsigned long page_size (system_page_size_interface const &intf)
 
- Protected Member Functions inherited from 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)
 

Detailed Description

memory_mapper provides an operating system independent interface for memory mapping of files.

The underlying constaints imposed by the OS are not affected. They are:

Linux: the 'offset' parameter must be a multiple of the value returned by sysconf(_SC_PAGESIZE) Windows: the 'offset' parameter must be a multiple of the allocation granularity given by SYSTEM_INFO structure filled in by a call to GetSystemInfo().

Constructor & Destructor Documentation

◆ memory_mapper()

pstore::memory_mapper::memory_mapper ( file::file_handle file,
bool  write_enabled,
std::uint64_t  offset,
std::uint64_t  length 
)
Parameters
fileThe file whose contents are to be mapped into memory.
write_enabledShould the mapped memory be writeable? If true, then the underlying file, as given by the 'file' parameter, must be writable.
offsetThe starting offset within the file for the mapped region. This value must be correctly aligned for the host OS.
lengthThe number of bytes to be mapped.

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