17 : fd_(file_open(fpath)),
18 size_(file_size(fd_)) {}
26 : fd_(fm.fd_), size_(fm.size_) { fm.fd_ = -1; }
35 std::size_t
size()
const {
return size_; }
37 void map_to_vm(
void* addr, std::size_t
size, std::size_t offset)
const {
43 void* ret = mmap(addr,
size, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd_, offset);
44 if (ret == MAP_FAILED) {
46 common::die(
"[ityr::ori::file_mem] mmap(%p, %lu, ...) failed", addr,
size);
57 static int file_open(
const std::string& fpath) {
58 int fd = open(fpath.c_str(), O_RDONLY);
61 common::die(
"[ityr::ori::file_mem] open() failed");
66 static void file_close(
int fd) {
67 if (close(fd) == -1) {
69 common::die(
"[ityr::ori::file_mem] close() failed");
73 static std::size_t file_size(
int fd) {
75 if (fstat(fd, &sb) == -1) {
Definition: file_mem.hpp:12
void map_to_vm(void *addr, std::size_t size, std::size_t offset) const
Definition: file_mem.hpp:37
file_mem(const file_mem &)=delete
file_mem & operator=(const file_mem &)=delete
file_mem & operator=(file_mem &&fm)
Definition: file_mem.hpp:27
file_mem(const std::string &fpath)
Definition: file_mem.hpp:16
file_mem()
Definition: file_mem.hpp:14
~file_mem()
Definition: file_mem.hpp:20
std::size_t size() const
Definition: file_mem.hpp:35
file_mem(file_mem &&fm)
Definition: file_mem.hpp:25
#define ITYR_CHECK(cond)
Definition: util.hpp:48
std::size_t get_page_size()
Definition: util.hpp:170
Definition: block_region_set.hpp:9