Itoyori  v0.0.1
util.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fstream>
4 
5 #include "ityr/common/util.hpp"
6 
7 namespace ityr::ori {
8 
9 namespace mode {
10 struct read_t {};
11 inline constexpr read_t read;
12 struct write_t {};
13 inline constexpr write_t write;
14 struct read_write_t {};
15 inline constexpr read_write_t read_write;
16 }
17 
18 inline std::string str(mode::read_t) {
19  return "read";
20 }
21 
22 inline std::string str(mode::write_t) {
23  return "write";
24 }
25 
26 inline std::string str(mode::read_write_t) {
27  return "read_write";
28 }
29 
30 using block_size_t = uint32_t;
31 
32 inline std::size_t sys_mmap_entry_limit() {
33  std::ifstream ifs("/proc/sys/vm/max_map_count");
34  if (!ifs) {
35  common::die("Cannot open /proc/sys/vm/max_map_count");
36  }
37  std::size_t sys_limit;
38  ifs >> sys_limit;
39  return sys_limit;
40 }
41 
42 }
ITYR_CONCAT(mode_, ITYR_PROFILER_MODE) mode
Definition: profiler.hpp:257
constexpr read_write_t read_write
Definition: util.hpp:15
constexpr read_t read
Definition: util.hpp:11
constexpr write_t write
Definition: util.hpp:13
Definition: block_region_set.hpp:9
std::string str(mode::read_t)
Definition: util.hpp:18
std::size_t sys_mmap_entry_limit()
Definition: util.hpp:32
uint32_t block_size_t
Definition: util.hpp:30
Definition: util.hpp:10
Definition: util.hpp:14
Definition: util.hpp:12