8#ifndef MMAP_STATISTICS_H
9#define MMAP_STATISTICS_H
42 eb_statistics(
const char* file_up,
int nup,
const char* file_down,
int ndown)
50 m_fd_u = open(file_up, O_RDWR | O_CREAT | O_NOATIME, 0644);
52 m_fd_d = open(file_down, O_RDWR | O_CREAT | O_NOATIME, 0644);
58 memset(buf_u, 0, m_len_u);
59 memset(buf_d, 0, m_len_d);
63 ret = write(m_fd_u, buf_u, m_len_u);
64 assert(ret == m_len_u);
65 ret = write(m_fd_d, buf_d, m_len_d);
66 assert(ret == m_len_d);
68 m_stat_u = (
stream_statistics*)mmap(0, m_len_u, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd_u, 0);
69 assert(m_stat_u != MAP_FAILED);
70 m_stat_d = (
stream_statistics*)mmap(0, m_len_d, PROT_READ | PROT_WRITE, MAP_SHARED, m_fd_d, 0);
71 assert(m_stat_d != MAP_FAILED);
76 munmap(m_stat_u, m_len_u);
77 munmap(m_stat_d, m_len_d);