|
|
@ -9,12 +9,12 @@ namespace hv
|
|
|
|
memory_map::memory_map(std::uint64_t size, int&& fd) noexcept
|
|
|
|
memory_map::memory_map(std::uint64_t size, int&& fd) noexcept
|
|
|
|
: is_cow(false), size(size), fd(fd), block0(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0))
|
|
|
|
: is_cow(false), size(size), fd(fd), block0(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!block0) throw "memory_map failed";
|
|
|
|
if(!block0) std::terminate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memory_map::memory_map(std::uint64_t size, int&& fd, bool _cow) noexcept
|
|
|
|
memory_map::memory_map(std::uint64_t size, int&& fd, bool _cow) noexcept
|
|
|
|
: is_cow(true), size(size), fd(fd), block0(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))
|
|
|
|
: is_cow(true), size(size), fd(fd), block0(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!block0) throw "memory_map::cow failed";
|
|
|
|
if(!block0) std::terminate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
memory_map::memory_map(std::uint64_t size, const char* file) noexcept
|
|
|
|
memory_map::memory_map(std::uint64_t size, const char* file) noexcept
|
|
|
|
: memory_map(size, open(file, O_RDWR)) {}
|
|
|
|
: memory_map(size, open(file, O_RDWR)) {}
|
|
|
|