27 #ifndef PSTORE_OS_MEMORY_MAPPER_HPP 28 #define PSTORE_OS_MEMORY_MAPPER_HPP 37 std::shared_ptr<std::uint8_t>
aligned_valloc (std::size_t size,
unsigned align);
51 virtual unsigned get ()
const = 0;
60 unsigned get ()
const override {
return size_; }
63 unsigned size_ = sysconf ();
64 static unsigned sysconf ();
78 std::shared_ptr<void>
const & data () {
return ptr_; }
81 std::shared_ptr<void const> data ()
const {
return ptr_; }
90 std::uint64_t
offset ()
const {
return offset_; }
93 std::uint64_t
size ()
const {
return size_; }
97 std::uint64_t
end ()
const {
return offset () + size (); }
110 virtual void read_only (
void * addr, std::size_t len);
119 std::uint64_t
const offset, std::uint64_t
const size)
120 : ptr_{std::move (ptr)}
121 , is_writable_{is_writable}
134 void read_only_impl (
void * addr, std::size_t len);
137 std::shared_ptr<void> ptr_;
142 std::uint64_t offset_;
168 std::uint64_t length);
173 std::uint64_t offset, std::uint64_t length);
180 std::uint64_t
const offset, std::uint64_t
const length)
185 std::uint64_t
const offset) {
186 auto const p = std::static_pointer_cast<std::uint8_t> (file.
data ());
187 return std::shared_ptr<std::uint8_t> (p, p.get () + offset);
192 #endif // PSTORE_OS_MEMORY_MAPPER_HPP std::uint64_t end() const
A convenience method which returns the file offset of the end of the memory represented by this objec...
Definition: memory_mapper.hpp:97
std::uint64_t size() const
Returns the size of the memory region owned by this object.
Definition: memory_mapper.hpp:93
Cross platform file management functions and classes.
memory_mapper provides an operating system independent interface for memory mapping of files...
Definition: memory_mapper.hpp:157
Definition: memory_mapper.hpp:68
Implements a portable file access API.
Definition: file.hpp:566
std::uint64_t offset() const
Returns the file offset of the start of the memory represented by this object.
Definition: memory_mapper.hpp:90
An interface for accessing the fundamental virtual memory page size on the host.
Definition: memory_mapper.hpp:40
Definition: memory_mapper.hpp:55
Implements an in-memory file which provides a file-like API to a chunk of pre-allocated memory...
Definition: file.hpp:483
bool is_writable() const
Returns true if the memory is to be writable.
Definition: memory_mapper.hpp:87
Definition: nonpod2.cpp:40
std::shared_ptr< void > data()
Returns the underlying memory managed by the file object.
Definition: file.hpp:519
std::shared_ptr< std::uint8_t > aligned_valloc(std::size_t size, unsigned align)
Allocates memory whose start address is a multiple of 'align'.
Definition: memory_mapper_posix.cpp:68
Definition: memory_mapper.hpp:177
memory_mapper_base(std::shared_ptr< void > ptr, bool const is_writable, std::uint64_t const offset, std::uint64_t const size)
Definition: memory_mapper.hpp:118