blob: 079815dcf26a35ceeaa473ea8e36a1bb72712c15 [file] [log] [blame]
William A. Kennington III891e6a32022-05-17 16:35:03 -07001#include <stdplus/fd/mmap.hpp>
2#include <stdplus/util/cexec.hpp>
3
4namespace stdplus
5{
6namespace fd
7{
8
9MMap::MMap(Fd& fd, std::span<std::byte> window, ProtFlags prot, MMapFlags flags,
10 off_t offset) :
11 mapping(fd.mmap(window, prot, flags, offset), fd)
12{
13}
14
15std::span<std::byte> MMap::get() const
16{
17 return *mapping;
18}
19
20void MMap::drop(std::span<std::byte>&& mapping, std::reference_wrapper<Fd>& fd)
21{
22 fd.get().munmap(mapping);
23}
24
25} // namespace fd
26} // namespace stdplus